From patchwork Fri Nov 9 15:27:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1720981 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 168E6DF264 for ; Fri, 9 Nov 2012 15:28:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754190Ab2KIP2B (ORCPT ); Fri, 9 Nov 2012 10:28:01 -0500 Received: from mail-pb0-f46.google.com ([209.85.160.46]:43523 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754025Ab2KIP2A (ORCPT ); Fri, 9 Nov 2012 10:28:00 -0500 Received: by mail-pb0-f46.google.com with SMTP id rr4so2903062pbb.19 for ; Fri, 09 Nov 2012 07:28:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=8SAMgO3fqeIort2DQFmcgl3+kYFh8IkKcwsKqmgpAKY=; b=kAHEcgcGTDpwxuctSslim9sBCcz3Iv17PTn370mgWT7H0PTkAyKSmfxwcy2FO/gg+2 8qmcDp5Ue2NoRpd5eUpc+EvbJ4LN1u2Gi+nkwiMH1CYqxQyylpXzp2FG6r+sTZJ0Trrf 8T1cbpgC1fS2kubYy3c60xdNcPVGOVumd3zD6FhyNtlrV+tw9DySVeurZ7QvALMdhqqY hU/Bzo2f9NmbD1LTwTh+vVbFkNXx/vRroD2vquPGum6k1i91g4Zd3mWiYwQxJ24BpB74 yZLRp7OsStlsm+21urjcryN1u0opecfIS8A2gSYyqK8EHR55g5FPtQtV0EHFSkNaof0C RFpA== Received: by 10.68.143.201 with SMTP id sg9mr35275843pbb.32.1352474879922; Fri, 09 Nov 2012 07:27:59 -0800 (PST) Received: from localhost ([122.167.207.71]) by mx.google.com with ESMTPS id v2sm16383649paz.27.2012.11.09.07.27.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Nov 2012 07:27:59 -0800 (PST) From: Viresh Kumar To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, spear-devel@list.st.com, Viresh Kumar Subject: [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines Date: Fri, 9 Nov 2012 20:57:48 +0530 Message-Id: <3d6f34ca5960203a5efb761f4d56b4e10ee24827.1352474824.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e X-Gm-Message-State: ALoCoQmyrEYERH4IYCI4psg06DTp5aOriVmE7Daz6TPWX62hV1D+RV31cKprKQe3VDyiXFrJMotW Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This patch frees stmpe-keyboard driver from tension of freeing resources :) devm_* derivatives of multiple routines are used while allocating resources, which would be freed automatically by kernel. Signed-off-by: Viresh Kumar --- drivers/input/keyboard/stmpe-keypad.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c index 470a877..6e25497 100644 --- a/drivers/input/keyboard/stmpe-keypad.c +++ b/drivers/input/keyboard/stmpe-keypad.c @@ -275,15 +275,14 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev) if (irq < 0) return irq; - keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL); + keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad), + GFP_KERNEL); if (!keypad) return -ENOMEM; - input = input_allocate_device(); - if (!input) { - ret = -ENOMEM; - goto out_freekeypad; - } + input = devm_input_allocate_device(&pdev->dev); + if (!input) + return -ENOMEM; input->name = "STMPE keypad"; input->id.bustype = BUS_I2C; @@ -294,7 +293,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev) STMPE_KEYPAD_MAX_COLS, keypad->keymap, input); if (ret) - goto out_freeinput; + return ret; input_set_capability(input, EV_MSC, MSC_SCAN); if (!plat->no_autorepeat) @@ -314,17 +313,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev) ret = stmpe_keypad_chip_init(keypad); if (ret < 0) - goto out_freeinput; + return ret; ret = input_register_device(input); if (ret) { dev_err(&pdev->dev, "unable to register input device: %d\n", ret); - goto out_freeinput; + return ret; } - ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT, - "stmpe-keypad", keypad); + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, stmpe_keypad_irq, + IRQF_ONESHOT, "stmpe-keypad", keypad); if (ret) { dev_err(&pdev->dev, "unable to get irq: %d\n", ret); goto out_unregisterinput; @@ -336,11 +335,6 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev) out_unregisterinput: input_unregister_device(input); - input = NULL; -out_freeinput: - input_free_device(input); -out_freekeypad: - kfree(keypad); return ret; } @@ -348,14 +342,9 @@ static int __devexit stmpe_keypad_remove(struct platform_device *pdev) { struct stmpe_keypad *keypad = platform_get_drvdata(pdev); struct stmpe *stmpe = keypad->stmpe; - int irq = platform_get_irq(pdev, 0); stmpe_disable(stmpe, STMPE_BLOCK_KEYPAD); - - free_irq(irq, keypad); input_unregister_device(keypad->input); - platform_set_drvdata(pdev, NULL); - kfree(keypad); return 0; }