From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03CC7C61DD8 for ; Sat, 14 Nov 2020 17:14:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FE5E20B80 for ; Sat, 14 Nov 2020 17:14:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="e+YxkalD"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="W6WLORTz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FE5E20B80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AvBnMstMrHxN5ethkZJy7FjhqZpGstLEDaDWp1hPZGw=; b=e+YxkalDSjTYDenW8UXL+Ieab 277jqOVcKfCfIJiVbDrA/newph3vKr67ni79ngkrWuRw4+wX8at6gZSxaI08tiAKt8NaibG4WAELh tAbY3Lr4eDknDyFlQw1rLIV8WBnFM9HiS1GusM8CHDibHwp4NkCvl8kTEh1zBYi0pPwTL/jbKRsQc cZ9Sdbkn+SOy4KsSB3OIJHGyXCnlHhzdcuXWWfsqB10tyrxpJ4GrUuATCxgeYf3Oy0Z5pfoEGg+TW 46oe/FZXrf0v8695Lybd041GssgliJBZePnCV6mouQI1MzdoneYjqe+7gfdAmu/uihXOZ0/OjQ1OC iiy9c6TeQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdz7W-0005LN-3E; Sat, 14 Nov 2020 17:13:50 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdz7S-0005KX-ES for linux-arm-kernel@lists.infradead.org; Sat, 14 Nov 2020 17:13:47 +0000 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F02E220B80; Sat, 14 Nov 2020 17:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605374025; bh=7Bx7OgTMf7K1V49Siex8+pfgI4ga4zani3QVJHYL0tc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=W6WLORTzjZDqjTxARI7WVd1eSW69I/gxp2zSSs047eoJG7N+HiaI/oCPEdKCNJ+QT EiC0JskYq/gYuh1RiPKi+S3p6fCoZXHMGYR8xh/0t23tHFVhgl1pX8YPDmn9prfNbW EFWY0a8Y1kyYGbOo2mW0HWuRxA5UikbhtVSXJa8Y= Date: Sat, 14 Nov 2020 17:13:40 +0000 From: Jonathan Cameron To: Alexandre Belloni Subject: Re: [PATCH 7/9] iio: adc: at91_adc: use devm_input_allocate_device Message-ID: <20201114171340.2bf0d61e@archlinux> In-Reply-To: <20201113212650.507680-8-alexandre.belloni@bootlin.com> References: <20201113212650.507680-1-alexandre.belloni@bootlin.com> <20201113212650.507680-8-alexandre.belloni@bootlin.com> X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201114_121346_623869_4AD13B43 X-CRM114-Status: GOOD ( 23.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ludovic Desroches , Peter Meerwald-Stadler , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 13 Nov 2020 22:26:48 +0100 Alexandre Belloni wrote: > Use devm_input_allocate_device to allocate the input device to simplify the > error and remove paths. > > Signed-off-by: Alexandre Belloni This one I'm less keen on. Whilst it's obviously not a problem in this particular case I'd ideally like to keep the remove order as the exact reverse of probe - that makes it easy to review changes quickly. Now, you could easily enough make this fine by using devm for the other items that happen before this (dev_add_action_or_reset needed in a few cases). Jonathan > --- > drivers/iio/adc/at91_adc.c | 25 +++---------------------- > 1 file changed, 3 insertions(+), 22 deletions(-) > > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c > index 76aeebce6f4d..d09ceb315c5a 100644 > --- a/drivers/iio/adc/at91_adc.c > +++ b/drivers/iio/adc/at91_adc.c > @@ -937,9 +937,8 @@ static int at91_ts_register(struct iio_dev *idev, > { > struct at91_adc_state *st = iio_priv(idev); > struct input_dev *input; > - int ret; > > - input = input_allocate_device(); > + input = devm_input_allocate_device(&pdev->dev); > if (!input) { > dev_err(&idev->dev, "Failed to allocate TS device!\n"); > return -ENOMEM; > @@ -964,8 +963,7 @@ static int at91_ts_register(struct iio_dev *idev, > if (st->touchscreen_type != ATMEL_ADC_TOUCHSCREEN_4WIRE) { > dev_err(&pdev->dev, > "This touchscreen controller only support 4 wires\n"); > - ret = -EINVAL; > - goto err; > + return -EINVAL; > } > > input_set_abs_params(input, ABS_X, 0, (1 << MAX_RLPOS_BITS) - 1, > @@ -977,20 +975,7 @@ static int at91_ts_register(struct iio_dev *idev, > st->ts_input = input; > input_set_drvdata(input, st); > > - ret = input_register_device(input); > - if (ret) > - goto err; > - > - return ret; > - > -err: > - input_free_device(st->ts_input); > - return ret; > -} > - > -static void at91_ts_unregister(struct at91_adc_state *st) > -{ > - input_unregister_device(st->ts_input); > + return input_register_device(input); > } > > static int at91_adc_probe(struct platform_device *pdev) > @@ -1203,8 +1188,6 @@ static int at91_adc_probe(struct platform_device *pdev) > if (!st->touchscreen_type) { > at91_adc_trigger_remove(idev); > at91_adc_buffer_remove(idev); > - } else { > - at91_ts_unregister(st); > } > error_disable_adc_clk: > clk_disable_unprepare(st->adc_clk); > @@ -1224,8 +1207,6 @@ static int at91_adc_remove(struct platform_device *pdev) > if (!st->touchscreen_type) { > at91_adc_trigger_remove(idev); > at91_adc_buffer_remove(idev); > - } else { > - at91_ts_unregister(st); > } > clk_disable_unprepare(st->adc_clk); > clk_disable_unprepare(st->clk); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel