From patchwork Thu Mar 9 14:31:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 9613457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41A0C602B4 for ; Thu, 9 Mar 2017 14:33:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 352FA2863D for ; Thu, 9 Mar 2017 14:33:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A00A2863F; Thu, 9 Mar 2017 14:33:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CECD22863D for ; Thu, 9 Mar 2017 14:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932433AbdCIOc2 (ORCPT ); Thu, 9 Mar 2017 09:32:28 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34830 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754542AbdCIOcH (ORCPT ); Thu, 9 Mar 2017 09:32:07 -0500 Received: by mail-wm0-f67.google.com with SMTP id z63so11232314wmg.2 for ; Thu, 09 Mar 2017 06:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yn7jijL1NBJXY94Bqocrfl9INsyKxlz7jydVibgRwzM=; b=RoK/7uGJnxRW7WQ8Hqvl2odq+9rGz2Y0I4pNWHb3W2xEL4EHlDnS+ZbEvAzJEedK0L BKBVyHUqV7uQti8JaXHCIewW6j3tc3cXzDPt6fEJkAK1W0uyncF5gQW+fTBjqIT/kq1D 2QRRslEMEOP02SFB2FBZSuMRzE+vfl1+X1CMGyS+pG82xj0FlnJjmzX2l9apc13PkXww M53NpZ1t61JZQd1HBIwleMTvinLzd32N3CSVL3sBwmyuzBabubodHDGbpUpGxdPg77NN 1N+BoDsXaKtoPY49PqgRBUl8lfLpNXHb/NnKpe4WlcLZNvm/XDo4lhc8ULb2VjtmxocX dLOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yn7jijL1NBJXY94Bqocrfl9INsyKxlz7jydVibgRwzM=; b=HCYshsr4OPE9wOv3uSBrGje/kR8+lkNe1MqifO9f7OH1DncHr39BLPOjEiZqNzC+Tz UlqoFyIZStf5C3D8tdkhyKsj8MDblJLmR1/vNKdzKP06O6kHT2GG4k8PbG52hRbk0dt8 xrNsafedaNYnSX9XwqLhUa5kvM/+E9HRIrH3Nan7Zmxk8VOdia9FCztFcU72bEzbZ+NH omAHqnFOQqU3nNvv9jQBXhjlKqjMnIFZBYxY5AH1zaSHA9I6+BdJD+Al90djlJt3cnqj d1BIEnP0QzP4a05eFnAFSvaRmvvZjG3NYY/GVJ1sQkDXJIRuRFTU5hGKKshQrJfLccPv SeIg== X-Gm-Message-State: AMke39nJLs4hfhYWwbFGtwxPmpZBcoPYMuysh4LpKnHZiBeblnHbZz62rIsgOZsCgFxcYg== X-Received: by 10.28.31.139 with SMTP id f133mr28674058wmf.25.1489069898856; Thu, 09 Mar 2017 06:31:38 -0800 (PST) Received: from development1.visionsystems.de (mail.visionsystems.de. [213.209.99.202]) by smtp.gmail.com with ESMTPSA id 94sm8427744wrl.50.2017.03.09.06.31.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 06:31:38 -0800 (PST) From: yegorslists@googlemail.com To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, lee.jones@linaro.org, robh@kernel.org, mark.rutland@arm.com, andrej.skvortzov@gmail.com, nsekhar@ti.com, khilman@baylibre.com, Yegor Yefremov Subject: [PATCH v2 1/3] tps6507x-ts: update to devm_* API Date: Thu, 9 Mar 2017 15:31:07 +0100 Message-Id: <1489069869-3849-2-git-send-email-yegorslists@googlemail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1489069869-3849-1-git-send-email-yegorslists@googlemail.com> References: <1489069869-3849-1-git-send-email-yegorslists@googlemail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yegor Yefremov Update the code to use devm_* API so that driver core will manage resources. Signed-off-by: Yegor Yefremov --- drivers/input/touchscreen/tps6507x-ts.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c index a340bfc..fbaa2f68 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c @@ -226,7 +226,7 @@ static int tps6507x_ts_probe(struct platform_device *pdev) */ init_data = tps_board->tps6507x_ts_init_data; - tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL); + tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL); if (!tsc) { dev_err(tps6507x_dev->dev, "failed to allocate driver data\n"); return -ENOMEM; @@ -240,11 +240,10 @@ static int tps6507x_ts_probe(struct platform_device *pdev) snprintf(tsc->phys, sizeof(tsc->phys), "%s/input0", dev_name(tsc->dev)); - poll_dev = input_allocate_polled_device(); + poll_dev = devm_input_allocate_polled_device(&pdev->dev); if (!poll_dev) { dev_err(tsc->dev, "Failed to allocate polled input device.\n"); - error = -ENOMEM; - goto err_free_mem; + return -ENOMEM; } tsc->poll_dev = poll_dev; @@ -274,34 +273,15 @@ static int tps6507x_ts_probe(struct platform_device *pdev) error = tps6507x_adc_standby(tsc); if (error) - goto err_free_polled_dev; + return error; error = input_register_polled_device(poll_dev); if (error) - goto err_free_polled_dev; + return error; platform_set_drvdata(pdev, tsc); return 0; - -err_free_polled_dev: - input_free_polled_device(poll_dev); -err_free_mem: - kfree(tsc); - return error; -} - -static int tps6507x_ts_remove(struct platform_device *pdev) -{ - struct tps6507x_ts *tsc = platform_get_drvdata(pdev); - struct input_polled_dev *poll_dev = tsc->poll_dev; - - input_unregister_polled_device(poll_dev); - input_free_polled_device(poll_dev); - - kfree(tsc); - - return 0; } static struct platform_driver tps6507x_ts_driver = { @@ -309,7 +289,6 @@ static struct platform_driver tps6507x_ts_driver = { .name = "tps6507x-ts", }, .probe = tps6507x_ts_probe, - .remove = tps6507x_ts_remove, }; module_platform_driver(tps6507x_ts_driver);