Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1980540pxb; Sat, 14 Nov 2020 08:48:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGhjCk7/slRDXwl9jaMsUyX5h0b3lWGnzhEGgjTt37mYaMukbcQu7s7HUWHYRwCFdZLr7o X-Received: by 2002:aa7:cd56:: with SMTP id v22mr8338256edw.245.1605372519030; Sat, 14 Nov 2020 08:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605372519; cv=none; d=google.com; s=arc-20160816; b=Ur5vzOi+MEWd3dkYGTajV5BhGZKzuD7Dobz1rlDHOOqjYAXH5qOatX5lh796MNP5HD L2/cmpUw+MOXShGHrBIf/excdr9uqrdwMZ9fld+Ovzis2tC4L4nyG6KRhyqkJnYsSh6g jCwDPuxacoFNnvDuVO0XhNq+5REJnfUSSbJLiM4yriWj3t+0MbTfNa39heCt1jKdYT5h WV3z+r+HzGA3l0+OBFpp4xyQ8JRae8kSUtzFM3dA1ZHIBlcYoVJnPdFI3Z8yN/PNOVvx m13hwbmA/yP/wqsLPnRdmS8jRIQ+NfOrnjWFWjmda4Tn4a6/4l1cKf1adX/Noutjg19N v5bQ== 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 :dkim-signature; bh=fhT35JWyd7VLqIbVKaB+EWd9pP3O3ekcjz8ev6O6j/I=; b=svwtmXYQXED+I+tlc1EIQ+MvqeLMZTU+EoV5UybKFeIhzt7kYu7Ekh1qGvC0715QkK W/pqBhHQ5wlKeVzfohx0mKJri36UQo2GL387R6Mt2722M7/mzkCyGtavZSfRYoaKVMSD XWtcjFlKXdGRc7LGgT18HI4zHorTFv/rC+4vHNThQZZ92QnCyZTGa0q0ZWP7259NVe13 B/wo/iEqCu2M+BqWvp05yQ+XrTBg9fiF9iB9wxIYRFcBu47BhblDVn5SJPjvpJ6jgbVb NE+wRBhvRw3hHPLHno+FNcGDTd/HxO20SZcWLnVrLJBh+UnVV8mgggER8d0uXnxMF2hj YHkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=smiogYkv; 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 qc4si7937777ejb.200.2020.11.14.08.48.15; Sat, 14 Nov 2020 08:48:39 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=smiogYkv; 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 S1727057AbgKNQp0 (ORCPT + 99 others); Sat, 14 Nov 2020 11:45:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:58196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgKNQp0 (ORCPT ); Sat, 14 Nov 2020 11:45:26 -0500 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 200FD20709; Sat, 14 Nov 2020 16:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605372325; bh=lqmUdGXvXeFpV1VchJqGcV78YmFZYTBbB0Vd5Oq4PhY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=smiogYkvmgXcLweGt9e6gO4uAkR4UsBxjNbzwoIKSNGjnBV/qrRB8TeXQOVTcdjkP gxIMZEFdbCZbIKJvOQQjYpEZLBlvo7dd9TeeQUwMdnffqgQqvN7cDSBu3Wk1cm9JGg 6uprmVUZTsEc+KKJ39pcQUpkuMwEz2r9nWibQ6a8= Date: Sat, 14 Nov 2020 16:45:17 +0000 From: Jonathan Cameron To: Alexandru Ardelean Cc: , Subject: Re: [PATCH] iio: adc: ad7887: convert probe to device-managed functions Message-ID: <20201114164517.31796bef@archlinux> In-Reply-To: <20201113091648.148589-1-alexandru.ardelean@analog.com> References: <20201113091648.148589-1-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; 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 Fri, 13 Nov 2020 11:16:48 +0200 Alexandru Ardelean wrote: > This is conversion of the driver to use device-managed functions. > The IIO registration and triggered buffer setup both have device-managed > versions. > The regulator disable needs to be handled via an action_or_reset handler. > > With these changes, the remove hook is removed, and the error path is > cleaned up in probe. > > Signed-off-by: Alexandru Ardelean Applied. Thanks, Jonathan > --- > drivers/iio/adc/ad7887.c | 43 ++++++++++++++-------------------------- > 1 file changed, 15 insertions(+), 28 deletions(-) > > diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c > index 99a480ad3985..4f6f0e0e03ee 100644 > --- a/drivers/iio/adc/ad7887.c > +++ b/drivers/iio/adc/ad7887.c > @@ -232,6 +232,13 @@ static const struct iio_info ad7887_info = { > .read_raw = &ad7887_read_raw, > }; > > +static void ad7887_reg_disable(void *data) > +{ > + struct regulator *reg = data; > + > + regulator_disable(reg); > +} > + > static int ad7887_probe(struct spi_device *spi) > { > struct ad7887_platform_data *pdata = spi->dev.platform_data; > @@ -258,6 +265,10 @@ static int ad7887_probe(struct spi_device *spi) > ret = regulator_enable(st->reg); > if (ret) > return ret; > + > + ret = devm_add_action_or_reset(&spi->dev, ad7887_reg_disable, st->reg); > + if (ret) > + return ret; > } > > st->chip_info = > @@ -316,36 +327,13 @@ static int ad7887_probe(struct spi_device *spi) > indio_dev->num_channels = st->chip_info->num_channels; > } > > - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, > + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, > + &iio_pollfunc_store_time, > &ad7887_trigger_handler, &ad7887_ring_setup_ops); > if (ret) > - goto error_disable_reg; > - > - ret = iio_device_register(indio_dev); > - if (ret) > - goto error_unregister_ring; > - > - return 0; > -error_unregister_ring: > - iio_triggered_buffer_cleanup(indio_dev); > -error_disable_reg: > - if (st->reg) > - regulator_disable(st->reg); > - > - return ret; > -} > - > -static int ad7887_remove(struct spi_device *spi) > -{ > - struct iio_dev *indio_dev = spi_get_drvdata(spi); > - struct ad7887_state *st = iio_priv(indio_dev); > - > - iio_device_unregister(indio_dev); > - iio_triggered_buffer_cleanup(indio_dev); > - if (st->reg) > - regulator_disable(st->reg); > + return ret; > > - return 0; > + return devm_iio_device_register(&spi->dev, indio_dev); > } > > static const struct spi_device_id ad7887_id[] = { > @@ -359,7 +347,6 @@ static struct spi_driver ad7887_driver = { > .name = "ad7887", > }, > .probe = ad7887_probe, > - .remove = ad7887_remove, > .id_table = ad7887_id, > }; > module_spi_driver(ad7887_driver);