Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1583037ybh; Sun, 15 Mar 2020 06:19:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vutUl8BuDwo8QwOsAxinnLBxa+zbnz6YzPnF62pzLZNZRqCKuDD7P8VwNh4LAFs9Jc0WhpD X-Received: by 2002:a9d:7a47:: with SMTP id z7mr19854798otm.341.1584278344569; Sun, 15 Mar 2020 06:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584278344; cv=none; d=google.com; s=arc-20160816; b=jBlwsHCiA4onsaTJumVJNA2tElb3Vv47/5LsCAZg2WdpaNk5ob0ZAZ6grZdYYl+3bl 5twN9KnnT5z2veomtp1R212IIbWwUvIGJuE8+lvi3iiBtHWU5NNHel2z8SLil0z+rX8Q pGE5/AhJVVSi1VexWI3DkKTmGUiWOzvH7pnUK4blG/Gwbid608yAaPFBjRz2PiYguB+n 6hOUVN+hXp6hLpvGHySCwAZWKpO7eVD2ozVba0p2SYVPHBIy1FuCY3ZbNpKiKEBgMYBZ Wjn0/U4yWpqKiFpwqMxyJzYqf/9ycnaWRZPU2mOj2lyh7lDqsM8og2IyUh3bpNHJ3k+d J5ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=5VWSNP32G5w9wJdK/P/7UdSpkvkfUmXTf7daoyoER1c=; b=nTh3kvKmwsK2fJUxsh4CpbX8IXPCGLcPTVmmQ4MKpriYC7/cklKHiexWlKO4iASWrB NZkj14nS8MQ2IFckrFCc227q/RJVEhSe1GXQAuxOEJq4R2tGpXpA7fVwT1e1w6Jihb6u PrWSe2zNPcGooOa7TwZDoX7pDttVUMjuM28HrdWOph3TCoeKxfuGbQS9+7LbyHBoA3mY 6zkCGSYfJMIRTIRBshxmogxEBjBJ5DrF2hVy6gQLuOUP4GO21658yZNtBi20ojhnAssj V26UjIrO2+ADUk7wlcyE/0D5Lmy1Qtr0qv5px28UNrnzfGJexEmpS/Sb1F66Nd6xpweo MaQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zjewLdDE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11si197969oic.147.2020.03.15.06.18.52; Sun, 15 Mar 2020 06:19:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zjewLdDE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728616AbgCONSL (ORCPT + 99 others); Sun, 15 Mar 2020 09:18:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:48842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728582AbgCONSK (ORCPT ); Sun, 15 Mar 2020 09:18:10 -0400 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 0A174205ED; Sun, 15 Mar 2020 13:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584278290; bh=yTPTl73CTAwKU6Ah85qCz1tQR34Dwu1cFkkC/QJoE70=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=zjewLdDEvo4y9+eZeZC0RKI5OnCMigfRye3pm4PvjZfWnmtcceo0pbiNGwEAg692R YnN0nSjrGapRe6X0Oc1m4VqVCZOz1BH9LEPUx+LLHBSxJcNnNt8+XGwcen9xlBoWOq O/boVQUUWsjgtzUJAGiAYvOOs1OSyiHLob20GibU= Date: Sun, 15 Mar 2020 13:18:06 +0000 From: Jonathan Cameron To: Beniamin Bia Cc: , , , , , Subject: Re: [PATCH 4/4] iio: adc: ad7476: implement devm_add_action_or_reset Message-ID: <20200315131806.61e1d3f8@archlinux> In-Reply-To: <20200311084328.17680-4-beniamin.bia@analog.com> References: <20200311084328.17680-1-beniamin.bia@analog.com> <20200311084328.17680-4-beniamin.bia@analog.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Mar 2020 10:43:28 +0200 Beniamin Bia wrote: > Use devm_add_action_or_reset to automatically disable the device > when it is removed or an error occurs during probe routine. > > Signed-off-by: Beniamin Bia Applied, Thanks, Jonathan > --- > drivers/iio/adc/ad7476.c | 25 ++++++++++++------------- > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c > index cd7d42df2033..e9984a38fc4c 100644 > --- a/drivers/iio/adc/ad7476.c > +++ b/drivers/iio/adc/ad7476.c > @@ -256,6 +256,13 @@ static const struct iio_info ad7476_info = { > .read_raw = &ad7476_read_raw, > }; > > +static void ad7476_reg_disable(void *data) > +{ > + struct ad7476_state *st = data; > + > + regulator_disable(st->reg); > +} > + > static int ad7476_probe(struct spi_device *spi) > { > struct ad7476_state *st; > @@ -278,6 +285,11 @@ static int ad7476_probe(struct spi_device *spi) > if (ret) > return ret; > > + ret = devm_add_action_or_reset(&spi->dev, ad7476_reg_disable, > + st); > + if (ret) > + return ret; > + > st->convst_gpio = devm_gpiod_get_optional(&spi->dev, > "adi,conversion-start", > GPIOD_OUT_LOW); > @@ -328,18 +340,6 @@ static int ad7476_probe(struct spi_device *spi) > return ret; > } > > -static int ad7476_remove(struct spi_device *spi) > -{ > - struct iio_dev *indio_dev = spi_get_drvdata(spi); > - struct ad7476_state *st = iio_priv(indio_dev); > - > - iio_device_unregister(indio_dev); > - iio_triggered_buffer_cleanup(indio_dev); > - regulator_disable(st->reg); > - > - return 0; > -} > - > static const struct spi_device_id ad7476_id[] = { > {"ad7091", ID_AD7091R}, > {"ad7091r", ID_AD7091R}, > @@ -377,7 +377,6 @@ static struct spi_driver ad7476_driver = { > .name = "ad7476", > }, > .probe = ad7476_probe, > - .remove = ad7476_remove, > .id_table = ad7476_id, > }; > module_spi_driver(ad7476_driver);