Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp913244pxb; Sat, 18 Sep 2021 23:54:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz6V4UJyRxmSrvFZezDCAOTINC7Tf41V/GhOnHMbIQsK/3lx50aHOh5G5MB/IrlBABGrdD X-Received: by 2002:a5d:9355:: with SMTP id i21mr14976446ioo.12.1632034499247; Sat, 18 Sep 2021 23:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632034499; cv=none; d=google.com; s=arc-20160816; b=ClCv9dGTxDOmhN6O3IK6/EHeOFaxKh60CAXMIyrRgQfyrlhKl9G/hYjBCGFBF//9t+ /C3t8K5KnGtTqS3/S66q+tg+JxE3wOK3MD4vEPfChJwWav5DjGAXgmYvqIXcuv9DWarU HNEI60riQQSccVfqMqGpdLYoVw9sn38FNMfBnmX0aVlMnjizsILynudBE6xhr/n+cDO5 Vz7wKcxbzC8cADc3fNs3n74/SosfeGXRjksRB/Ih9yk4E+BU6L7TUBgHAxDH8IJGHS1R O/NYLKWmgNkfebpgDHzS//VpnbR2KlgRZzK7VFg5ysJjbqI4uZFv40gtVAQojjLpCMEk jukQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=sfYk+rR6LK3FAq09+qs0o5+3v8nn2jF6RMg/zzSz5IM=; b=nx5frSR6mdadDUXss4NYgxS2FPVQtTrOwBUybH/LafW5NrC0v0jKTwARkpQBOnJjTw QUOaiEx1ALaiixIlZnELfwV2OkEniWZoS5oXquc94ep5TwN2YuUcSjNdxhGE7Rioch9a Cw2tsAhzImbnRqO/a4dnkCX6MNxl1TTumFvxtc3K8jck9FiUVGpfPbZFBodHJSqLrQDE RRe5xZEiXK1015SJhL8kBI46/zRfu0SnuwlBYDp2NHQKRNZsBselfIRXqniR20TzwLlc ndwSQL+JcmAGx41oYfGngenRxyu2h9RYKX+v1h2wwVYjfoJKh5LmbJm65UR0aGfohWCf NzQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id a9si4603051ilt.69.2021.09.18.23.54.44; Sat, 18 Sep 2021 23:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S239786AbhIRR66 (ORCPT + 99 others); Sat, 18 Sep 2021 13:58:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:55284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231576AbhIRR65 (ORCPT ); Sat, 18 Sep 2021 13:58:57 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (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 E82626101B; Sat, 18 Sep 2021 17:57:32 +0000 (UTC) Date: Sat, 18 Sep 2021 19:01:12 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Subject: Re: [PATCH] iio: dac: ad7303: convert probe to full device-managed Message-ID: <20210918190112.7fa9df50@jic23-huawei> In-Reply-To: <20210913115121.300082-1-aardelean@deviqon.com> References: <20210913115121.300082-1-aardelean@deviqon.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 Sep 2021 14:51:21 +0300 Alexandru Ardelean wrote: > For this conversion, the regulators need to have some cleanup hooks > registered with devm_add_action_or_reset() and then the > devm_io_device_register() call can be used. > > Signed-off-by: Alexandru Ardelean Nice simple case. Applied to the togreg branch of iio.git and pushed out as testing for 0-day to see if it can find anything we missed. Thanks, Jonathan > --- > drivers/iio/dac/ad7303.c | 47 +++++++++++++++------------------------- > 1 file changed, 17 insertions(+), 30 deletions(-) > > diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c > index e1b6a92df12f..91eaaf793b3e 100644 > --- a/drivers/iio/dac/ad7303.c > +++ b/drivers/iio/dac/ad7303.c > @@ -198,6 +198,11 @@ static const struct iio_chan_spec ad7303_channels[] = { > AD7303_CHANNEL(1), > }; > > +static void ad7303_reg_disable(void *reg) > +{ > + regulator_disable(reg); > +} > + > static int ad7303_probe(struct spi_device *spi) > { > const struct spi_device_id *id = spi_get_device_id(spi); > @@ -210,7 +215,6 @@ static int ad7303_probe(struct spi_device *spi) > return -ENOMEM; > > st = iio_priv(indio_dev); > - spi_set_drvdata(spi, indio_dev); > > st->spi = spi; > > @@ -224,18 +228,27 @@ static int ad7303_probe(struct spi_device *spi) > if (ret) > return ret; > > + ret = devm_add_action_or_reset(&spi->dev, ad7303_reg_disable, st->vdd_reg); > + if (ret) > + return ret; > + > st->vref_reg = devm_regulator_get_optional(&spi->dev, "REF"); > if (IS_ERR(st->vref_reg)) { > ret = PTR_ERR(st->vref_reg); > if (ret != -ENODEV) > - goto err_disable_vdd_reg; > + return ret; > st->vref_reg = NULL; > } > > if (st->vref_reg) { > ret = regulator_enable(st->vref_reg); > if (ret) > - goto err_disable_vdd_reg; > + return ret; > + > + ret = devm_add_action_or_reset(&spi->dev, ad7303_reg_disable, > + st->vref_reg); > + if (ret) > + return ret; > > st->config |= AD7303_CFG_EXTERNAL_VREF; > } > @@ -246,32 +259,7 @@ static int ad7303_probe(struct spi_device *spi) > indio_dev->channels = ad7303_channels; > indio_dev->num_channels = ARRAY_SIZE(ad7303_channels); > > - ret = iio_device_register(indio_dev); > - if (ret) > - goto err_disable_vref_reg; > - > - return 0; > - > -err_disable_vref_reg: > - if (st->vref_reg) > - regulator_disable(st->vref_reg); > -err_disable_vdd_reg: > - regulator_disable(st->vdd_reg); > - return ret; > -} > - > -static int ad7303_remove(struct spi_device *spi) > -{ > - struct iio_dev *indio_dev = spi_get_drvdata(spi); > - struct ad7303_state *st = iio_priv(indio_dev); > - > - iio_device_unregister(indio_dev); > - > - if (st->vref_reg) > - regulator_disable(st->vref_reg); > - regulator_disable(st->vdd_reg); > - > - return 0; > + return devm_iio_device_register(&spi->dev, indio_dev); > } > > static const struct of_device_id ad7303_spi_of_match[] = { > @@ -292,7 +280,6 @@ static struct spi_driver ad7303_driver = { > .of_match_table = ad7303_spi_of_match, > }, > .probe = ad7303_probe, > - .remove = ad7303_remove, > .id_table = ad7303_spi_ids, > }; > module_spi_driver(ad7303_driver);