On Sat, Apr 19, 2025 at 09:56:37AM -0400, Gabriel Shahrouzi wrote:
> Move device-specific capability information, like the presence of a
> BUSY pin, into the ad7816_chip_info structure.
>
> Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
> ---
> drivers/staging/iio/adc/ad7816.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
> index 39310ade770d0..ab7520a8a3da9 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -44,21 +44,25 @@
> struct ad7816_chip_info {
> const char *name;
> u8 max_channels;
> + bool has_busy_pin;
> };
>
> static const struct ad7816_chip_info ad7816_info_ad7816 = {
> .name = "ad7816",
> .max_channels = 0,
> + .has_busy_pin = true,
> };
>
> static const struct ad7816_chip_info ad7817_info_ad7817 = {
> .name = "ad7817",
> .max_channels = 3,
> + .has_busy_pin = true,
> };
>
> static const struct ad7816_chip_info ad7818_info_ad7818 = {
> .name = "ad7818",
> .max_channels = 1,
> + .has_busy_pin = false,
> };
>
> struct ad7816_state {
> @@ -98,7 +102,7 @@ static int ad7816_spi_read(struct ad7816_state *chip, u16 *data)
> gpiod_set_value(chip->convert_pin, 1);
> }
>
> - if (chip->chip_info == &ad7816_info_ad7816 || chip->chip_info == &ad7817_info_ad7817) {
> + if (chip->chip_info->has_busy_pin) {
> while (gpiod_get_value(chip->busy_pin))
> cpu_relax();
> }
Here we could just check if (chip->busy_pin)... The place you really need
to change is ad7816_probe().
regards,
dan carpenter