Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp913012pxb; Sat, 18 Sep 2021 23:54:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFtgUMMCncfWHspdcciouCrIKPPEiccM7l4vUGis+GuiqAThv25P6C8RgLDetKIRKHbkvz X-Received: by 2002:a92:cb43:: with SMTP id f3mr14083663ilq.261.1632034458152; Sat, 18 Sep 2021 23:54:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632034458; cv=none; d=google.com; s=arc-20160816; b=rn4OupwXeTcf8BWz445cdiWd89WRz3SjKnNag3Ocz+bo0YRd1v69ikuw4EfeehSX44 CMjYdcm+QxOLlk5MEAOhhjDl9RjficEIKcTv0d8BBu28d1raxGzVq/qT1Mn0WAxpREc9 3Pz/5+/Sv/pY2cF/CGnxHF+WcBB+ik4OS4T+0x0iZDJSFiUbrjxJ11PCjvekOnJK0X9j GT3sTen7dGcF3hYHSzaKnQ4AW/+6eYwVZj18zH0P7Y/BW4EfMZERIMKwWaaiYQSK2OIm SffTJNgSVW6OsiJ46GiVT6ecNRc1E656JB1DHfgH0mEESASloQNqyQN3HZllAvt02KNx UAKw== 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=VOY28FKR5eE7ShRZgZONIGiAkhQkkUg0gcesabhPR78=; b=GQUvyv8KOWQ8KZB56KuUtlaxQEjpE3eSRFcMPpCCxzeYZ7PLi/ImBQlDRZiKVPpr1O qc9hT9J8ypiFVxvxj6XEaI5DBCYLhI3fOm7ydcORUagt60bxwuLbsAACO8NTiiFCoJh5 lSLgGWpNXrSMNuSO/86BT3sPl9YDvwoMHDzzn8MttS9nmVqEn6fqtOdq9Cr4QZvT/J9/ 9jTvlMlvraiAiZuOjXhKdm2vtVEgYyaiQGV6dFLWp3xVMuJVA7ElK9Ypjm59SU4VtyZg cYHtw6WftdtzqH5LMvWDTg1W2SFxGufs+ICCITbCWstgiK01dWxXoYwyyLkoPYKawD0B YEWQ== 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 e28si19424ioc.25.2021.09.18.23.54.07; Sat, 18 Sep 2021 23:54:18 -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 S238481AbhIRSDg (ORCPT + 99 others); Sat, 18 Sep 2021 14:03:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:56586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238237AbhIRSDg (ORCPT ); Sat, 18 Sep 2021 14:03:36 -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 75AF0610E9; Sat, 18 Sep 2021 18:02:11 +0000 (UTC) Date: Sat, 18 Sep 2021 19:05:50 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Subject: Re: [PATCH] iio: dac: ad5064: convert probe to full device-managed Message-ID: <20210918190550.62a321ce@jic23-huawei> In-Reply-To: <20210913115237.301310-1-aardelean@deviqon.com> References: <20210913115237.301310-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:52:37 +0300 Alexandru Ardelean wrote: > This change converts the probe of the AD5064 driver to use only > device-managed functions. > > The regulator_bulk_disable() is passed on a devm_add_action_or_reset() hook > and the devm_iio_device_register() can be used to register the IIO device. > > The driver has both I2C and SPI hooks inside, so all these can be removed. > > Signed-off-by: Alexandru Ardelean Applied to the togreg branch of iio.git and pushed out as testing for all the normal tedious reasons about the fact we should actually build test it on lots of architectures etc :) Jonathan > --- > drivers/iio/dac/ad5064.c | 49 ++++++++++------------------------------ > 1 file changed, 12 insertions(+), 37 deletions(-) > > diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c > index dff623b65e4f..fd9cac4f6321 100644 > --- a/drivers/iio/dac/ad5064.c > +++ b/drivers/iio/dac/ad5064.c > @@ -843,6 +843,13 @@ static int ad5064_request_vref(struct ad5064_state *st, struct device *dev) > return ret; > } > > +static void ad5064_bulk_reg_disable(void *data) > +{ > + struct ad5064_state *st = data; > + > + regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); > +} > + > static int ad5064_probe(struct device *dev, enum ad5064_type type, > const char *name, ad5064_write_func write) > { > @@ -858,7 +865,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, > > st = iio_priv(indio_dev); > mutex_init(&st->lock); > - dev_set_drvdata(dev, indio_dev); > > st->chip_info = &ad5064_chip_info_tbl[type]; > st->dev = dev; > @@ -872,6 +878,10 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, > ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); > if (ret) > return ret; > + > + ret = devm_add_action_or_reset(dev, ad5064_bulk_reg_disable, st); > + if (ret) > + return ret; > } > > indio_dev->name = name; > @@ -887,30 +897,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, > st->dac_cache[i] = midscale; > } > > - ret = iio_device_register(indio_dev); > - if (ret) > - goto error_disable_reg; > - > - return 0; > - > -error_disable_reg: > - if (!st->use_internal_vref) > - regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); > - > - return ret; > -} > - > -static int ad5064_remove(struct device *dev) > -{ > - struct iio_dev *indio_dev = dev_get_drvdata(dev); > - struct ad5064_state *st = iio_priv(indio_dev); > - > - iio_device_unregister(indio_dev); > - > - if (!st->use_internal_vref) > - regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); > - > - return 0; > + return devm_iio_device_register(dev, indio_dev); > } > > #if IS_ENABLED(CONFIG_SPI_MASTER) > @@ -932,11 +919,6 @@ static int ad5064_spi_probe(struct spi_device *spi) > ad5064_spi_write); > } > > -static int ad5064_spi_remove(struct spi_device *spi) > -{ > - return ad5064_remove(&spi->dev); > -} > - > static const struct spi_device_id ad5064_spi_ids[] = { > {"ad5024", ID_AD5024}, > {"ad5025", ID_AD5025}, > @@ -963,7 +945,6 @@ static struct spi_driver ad5064_spi_driver = { > .name = "ad5064", > }, > .probe = ad5064_spi_probe, > - .remove = ad5064_spi_remove, > .id_table = ad5064_spi_ids, > }; > > @@ -1019,11 +1000,6 @@ static int ad5064_i2c_probe(struct i2c_client *i2c, > ad5064_i2c_write); > } > > -static int ad5064_i2c_remove(struct i2c_client *i2c) > -{ > - return ad5064_remove(&i2c->dev); > -} > - > static const struct i2c_device_id ad5064_i2c_ids[] = { > {"ad5625", ID_AD5625 }, > {"ad5625r-1v25", ID_AD5625R_1V25 }, > @@ -1081,7 +1057,6 @@ static struct i2c_driver ad5064_i2c_driver = { > .name = "ad5064", > }, > .probe = ad5064_i2c_probe, > - .remove = ad5064_i2c_remove, > .id_table = ad5064_i2c_ids, > }; >