[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0145edf4-aef9-45c2-9a74-8c15abb1286c@stanley.mountain>
Date: Tue, 22 Apr 2025 09:41:23 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Gabriel Shahrouzi <gshahrouzi@...il.com>
Cc: gregkh@...uxfoundation.org, jic23@...nel.org, lars@...afoo.de,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-staging@...ts.linux.dev, Michael.Hennerich@...log.com,
sonic.zhang@...log.com, vapier@...too.org,
skhan@...uxfoundation.org, linux-kernel-mentees@...ts.linux.dev
Subject: Re: [PATCH 4/5] staging: iio: adc: ad7816: Use chip_info for device
capabilities
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@...il.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
Powered by blists - more mailing lists