Patch "iio: adc: ad9467: fix reset gpio handling" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    iio: adc: ad9467: fix reset gpio handling

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     iio-adc-ad9467-fix-reset-gpio-handling.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 754dc78a4d3b0ded06d94d3814102cb17f439174
Author: Nuno Sa <nuno.sa@xxxxxxxxxx>
Date:   Thu Dec 7 13:39:24 2023 +0100

    iio: adc: ad9467: fix reset gpio handling
    
    [ Upstream commit 76f028539cf360f750efd8cde560edda298e4c6b ]
    
    The reset gpio was being handled with inverted polarity. This means that
    as far as gpiolib is concerned we were actually leaving the pin asserted
    (in theory, this would mean reset). However, inverting the polarity in
    devicetree made things work. Fix it by doing it the proper way and how
    gpiolib expects it to be done.
    
    While at it, moved the handling to it's own function and dropped
    'reset_gpio' from the 'struct ad9467_state' as we only need it during
    probe. On top of that, refactored things so that we now request the gpio
    asserted (i.e in reset) and then de-assert it. Also note that we now use
    gpiod_set_value_cansleep() instead of gpiod_direction_output() as we
    already request the pin as output.
    
    Fixes: ad6797120238 ("iio: adc: ad9467: add support AD9467 ADC")
    Reviewed-by: David Lechner <dlechner@xxxxxxxxxxxx>
    Signed-off-by: Nuno Sa <nuno.sa@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231207-iio-backend-prep-v2-1-a4a33bc4d70e@xxxxxxxxxx
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
index 92837dcbc170..f2620dcd2a2c 100644
--- a/drivers/iio/adc/ad9467.c
+++ b/drivers/iio/adc/ad9467.c
@@ -121,7 +121,6 @@ struct ad9467_state {
 	unsigned int			output_mode;
 
 	struct gpio_desc		*pwrdown_gpio;
-	struct gpio_desc		*reset_gpio;
 };
 
 static int ad9467_spi_read(struct spi_device *spi, unsigned int reg)
@@ -378,6 +377,21 @@ static int ad9467_preenable_setup(struct adi_axi_adc_conv *conv)
 	return ad9467_outputmode_set(st->spi, st->output_mode);
 }
 
+static int ad9467_reset(struct device *dev)
+{
+	struct gpio_desc *gpio;
+
+	gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR_OR_NULL(gpio))
+		return PTR_ERR_OR_ZERO(gpio);
+
+	fsleep(1);
+	gpiod_set_value_cansleep(gpio, 0);
+	fsleep(10 * USEC_PER_MSEC);
+
+	return 0;
+}
+
 static int ad9467_probe(struct spi_device *spi)
 {
 	const struct ad9467_chip_info *info;
@@ -406,18 +420,9 @@ static int ad9467_probe(struct spi_device *spi)
 	if (IS_ERR(st->pwrdown_gpio))
 		return PTR_ERR(st->pwrdown_gpio);
 
-	st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset",
-						 GPIOD_OUT_LOW);
-	if (IS_ERR(st->reset_gpio))
-		return PTR_ERR(st->reset_gpio);
-
-	if (st->reset_gpio) {
-		udelay(1);
-		ret = gpiod_direction_output(st->reset_gpio, 1);
-		if (ret)
-			return ret;
-		mdelay(10);
-	}
+	ret = ad9467_reset(&spi->dev);
+	if (ret)
+		return ret;
 
 	spi_set_drvdata(spi, st);
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux