Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ti-ads1015: support deferred probe
@ 2023-09-04 10:15 Tomas Melin
  2023-09-04 11:23 ` Andy Shevchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Tomas Melin @ 2023-09-04 10:15 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, lars, andriy.shevchenko, u.kleine-koenig, Tomas Melin

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-09-06  5:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-04 10:15 [PATCH] iio: adc: ti-ads1015: support deferred probe Tomas Melin
2023-09-04 11:23 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox