All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH 4/5] iio: adc: cc10001: Use devm_ to call device power down.
Date: Sun, 16 Oct 2022 18:09:49 +0100	[thread overview]
Message-ID: <20221016170950.387751-5-jic23@kernel.org> (raw)
In-Reply-To: <20221016170950.387751-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

It is presumably safe to call the powerdown whether or not we are
in the commented shared state (the driver always did this).

The power down was previously out of order wrt to the probe() function
so move using devm_ will ensure it occurs after the userspace interfaces
are removed.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/cc10001_adc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c
index 332f0e06369f..b0daaec7ff16 100644
--- a/drivers/iio/adc/cc10001_adc.c
+++ b/drivers/iio/adc/cc10001_adc.c
@@ -310,6 +310,11 @@ static void cc10001_reg_disable(void *priv)
 	regulator_disable(priv);
 }
 
+static void cc10001_pd_cb(void *priv)
+{
+	cc10001_adc_power_down(priv);
+}
+
 static int cc10001_adc_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -375,6 +380,9 @@ static int cc10001_adc_probe(struct platform_device *pdev)
 	if (adc_dev->shared)
 		cc10001_adc_power_up(adc_dev);
 
+	ret = devm_add_action_or_reset(dev, cc10001_pd_cb, adc_dev);
+	if (ret)
+		return ret;
 	/* Setup the ADC channels available on the device */
 	ret = cc10001_adc_channel_init(indio_dev, channel_map);
 	if (ret < 0)
@@ -405,7 +413,6 @@ static int cc10001_adc_remove(struct platform_device *pdev)
 	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
 	struct cc10001_adc_device *adc_dev = iio_priv(indio_dev);
 
-	cc10001_adc_power_down(adc_dev);
 	iio_device_unregister(indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
 
-- 
2.37.2


  parent reply	other threads:[~2022-10-16 17:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-16 17:09 [PATCH 0/5] iio: adc: cc10001: Devm conversion Jonathan Cameron
2022-10-16 17:09 ` [PATCH 1/5] iio: adc: cc10001: Add local struct device *dev variable to avoid repitition Jonathan Cameron
2022-10-16 17:09 ` [PATCH 2/5] iio: adc: cc10001: Add devm_add_action_or_reset() to disable regulator Jonathan Cameron
2022-10-16 17:09 ` [PATCH 3/5] iio: adc: cc10001: Use devm_clk_get_enabled() to avoid boilerplate Jonathan Cameron
2022-10-31 11:19   ` Sa, Nuno
2022-10-16 17:09 ` Jonathan Cameron [this message]
2022-10-16 17:09 ` [PATCH 5/5] iio: adc: cc10001: Switch remaining IIO calls in probe to devm_ forms Jonathan Cameron
2022-10-31 11:17   ` Sa, Nuno
2022-10-29 12:43 ` [PATCH 0/5] iio: adc: cc10001: Devm conversion Jonathan Cameron
2022-10-31 11:19   ` Sa, Nuno
2022-11-06 11:48     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221016170950.387751-5-jic23@kernel.org \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.