From patchwork Wed Mar 27 13:39:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Felsch X-Patchwork-Id: 10873493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 58F161575 for ; Wed, 27 Mar 2019 13:39:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42722285CE for ; Wed, 27 Mar 2019 13:39:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36B472863E; Wed, 27 Mar 2019 13:39:36 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 CDF6428462 for ; Wed, 27 Mar 2019 13:39:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728905AbfC0Nje (ORCPT ); Wed, 27 Mar 2019 09:39:34 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:45465 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728530AbfC0Njd (ORCPT ); Wed, 27 Mar 2019 09:39:33 -0400 Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.lab.pengutronix.de) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h98mC-0007dd-4n; Wed, 27 Mar 2019 14:39:32 +0100 Received: from mfe by dude02.lab.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1h98mB-0000P7-LC; Wed, 27 Mar 2019 14:39:31 +0100 From: Marco Felsch To: dmitry.torokhov@gmail.com, robh+dt@kernel.org Cc: kernel@pengutronix.de, linux-input@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/4] Input: ads7846 - convert to devm_ alloc functions Date: Wed, 27 Mar 2019 14:39:24 +0100 Message-Id: <20190327133927.1340-2-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190327133927.1340-1-m.felsch@pengutronix.de> References: <20190327133927.1340-1-m.felsch@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org 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 Convert to devm function to drop the 'no-mem' error handling path and strip down the remove funciton a bit. Signed-off-by: Marco Felsch --- drivers/input/touchscreen/ads7846.c | 37 ++++++++++++----------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index a2f45aefce08..5a7a8425d619 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -1283,13 +1283,17 @@ static int ads7846_probe(struct spi_device *spi) if (err < 0) return err; - ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL); - packet = kzalloc(sizeof(struct ads7846_packet), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!ts || !packet || !input_dev) { - err = -ENOMEM; - goto err_free_mem; - } + ts = devm_kzalloc(&spi->dev, sizeof(*ts), GFP_KERNEL); + if (!ts) + return -ENOMEM; + + packet = devm_kzalloc(&spi->dev, sizeof(*packet), GFP_KERNEL); + if (!packet) + return -ENOMEM; + + input_dev = devm_input_allocate_device(&spi->dev); + if (!input_dev) + return -ENOMEM; spi_set_drvdata(spi, ts); @@ -1303,10 +1307,8 @@ static int ads7846_probe(struct spi_device *spi) pdata = dev_get_platdata(&spi->dev); if (!pdata) { pdata = ads7846_probe_dt(&spi->dev); - if (IS_ERR(pdata)) { - err = PTR_ERR(pdata); - goto err_free_mem; - } + if (IS_ERR(pdata)) + return PTR_ERR(pdata); } ts->model = pdata->model ? : 7846; @@ -1321,7 +1323,7 @@ static int ads7846_probe(struct spi_device *spi) if (pdata->filter_init != NULL) { err = pdata->filter_init(pdata, &ts->filter_data); if (err < 0) - goto err_free_mem; + return err; } ts->filter = pdata->filter; ts->filter_cleanup = pdata->filter_cleanup; @@ -1352,7 +1354,6 @@ static int ads7846_probe(struct spi_device *spi) input_dev->name = ts->name; input_dev->phys = ts->phys; - input_dev->dev.parent = &spi->dev; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); @@ -1451,10 +1452,7 @@ static int ads7846_probe(struct spi_device *spi) err_cleanup_filter: if (ts->filter_cleanup) ts->filter_cleanup(ts->filter_data); - err_free_mem: - input_free_device(input_dev); - kfree(packet); - kfree(ts); + return err; } @@ -1467,8 +1465,6 @@ static int ads7846_remove(struct spi_device *spi) ads7846_disable(ts); free_irq(ts->spi->irq, ts); - input_unregister_device(ts->input); - ads784x_hwmon_unregister(spi, ts); regulator_put(ts->reg); @@ -1484,9 +1480,6 @@ static int ads7846_remove(struct spi_device *spi) if (ts->filter_cleanup) ts->filter_cleanup(ts->filter_data); - kfree(ts->packet); - kfree(ts); - dev_dbg(&spi->dev, "unregistered touchscreen\n"); return 0;