Linux IIO development
 help / color / mirror / Atom feed
From: Tomas Melin <tomas.melin@vaisala.com>
To: linux-iio@vger.kernel.org
Cc: jic23@kernel.org, lars@metafoo.de,
	andriy.shevchenko@linux.intel.com,
	u.kleine-koenig@pengutronix.de,
	Tomas Melin <tomas.melin@vaisala.com>
Subject: [PATCH] iio: adc: ti-ads1015: support deferred probe
Date: Mon,  4 Sep 2023 13:15:22 +0300	[thread overview]
Message-ID: <20230904101533.455896-1-tomas.melin@vaisala.com> (raw)

Support deferred probe for cases where communication on
i2c bus fails. These failures could happen for a variety of
reasons including bus arbitration error or power failure.

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
 drivers/iio/adc/ti-ads1015.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 075c75a87544..f7dfcb894408 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -1062,7 +1062,7 @@ static int ads1015_probe(struct i2c_client *client)
 		ret = regmap_update_bits(data->regmap, ADS1015_CFG_REG,
 					cfg_comp_mask, cfg_comp);
 		if (ret)
-			return ret;
+			goto out;
 
 		ret = devm_request_threaded_irq(&client->dev, client->irq,
 						NULL, ads1015_event_handler,
@@ -1074,7 +1074,7 @@ static int ads1015_probe(struct i2c_client *client)
 
 	ret = ads1015_set_conv_mode(data, ADS1015_CONTINUOUS);
 	if (ret)
-		return ret;
+		goto out;
 
 	data->conv_invalid = true;
 
@@ -1092,6 +1092,11 @@ static int ads1015_probe(struct i2c_client *client)
 	}
 
 	return 0;
+
+out:
+	if ((ret == -EAGAIN) || (ret == -ENXIO))
+		return -EPROBE_DEFER;
+	return ret;
 }
 
 static void ads1015_remove(struct i2c_client *client)
-- 
2.39.2


             reply	other threads:[~2023-09-04 10:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 10:15 Tomas Melin [this message]
2023-09-04 11:23 ` [PATCH] iio: adc: ti-ads1015: support deferred probe Andy Shevchenko
2023-09-04 13:12   ` Jonathan Cameron
2023-09-05 11:43     ` Tomas Melin
2023-09-05 12:31       ` Lars-Peter Clausen
2023-09-06  5:59         ` Tomas Melin
2023-09-05 12:38       ` Andy Shevchenko
2023-09-05  6:13   ` Tomas Melin
2023-09-05 10:45     ` Andy Shevchenko
2023-09-05 11:44       ` Tomas Melin

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=20230904101533.455896-1-tomas.melin@vaisala.com \
    --to=tomas.melin@vaisala.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox