diff mbox series

[01/18] iio: light: apds9306: Switch to sparse friendly iio_device_claim/release_direct()

Message ID 20250309170633.1347476-2-jic23@kernel.org (mailing list archive)
State New
Headers show
Series iio: light: Sparse friendly claim of direct mode | expand

Commit Message

Jonathan Cameron March 9, 2025, 5:06 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
---
 drivers/iio/light/apds9306.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Subhajit Ghosh March 10, 2025, 6:35 a.m. UTC | #1
On 10/3/25 03:36, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> These new functions allow sparse to find failures to release
> direct mode reducing chances of bugs over the claim_direct_mode()
> functions that are deprecated.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
> ---
>   drivers/iio/light/apds9306.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
> index 69a0d609cffc..fca7e73a905c 100644
> --- a/drivers/iio/light/apds9306.c
> +++ b/drivers/iio/light/apds9306.c
> @@ -831,11 +831,10 @@ static int apds9306_read_raw(struct iio_dev *indio_dev,
>   		 * Changing device parameters during adc operation, resets
>   		 * the ADC which has to avoided.
>   		 */
> -		ret = iio_device_claim_direct_mode(indio_dev);
> -		if (ret)
> -			return ret;
> +		if (!iio_device_claim_direct(indio_dev))
> +			return -EBUSY;
>   		ret = apds9306_read_data(data, val, reg);
> -		iio_device_release_direct_mode(indio_dev);
> +		iio_device_release_direct(indio_dev);
>   		if (ret)
>   			return ret;
>   
Thank you Jonathan.
Jonathan Cameron March 10, 2025, 8:01 p.m. UTC | #2
On Mon, 10 Mar 2025 17:05:50 +1030
Subhajit Ghosh <subhajit.ghosh@tweaklogic.com> wrote:

> On 10/3/25 03:36, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > These new functions allow sparse to find failures to release
> > direct mode reducing chances of bugs over the claim_direct_mode()
> > functions that are deprecated.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
> > ---
> >   drivers/iio/light/apds9306.c | 7 +++----
> >   1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
> > index 69a0d609cffc..fca7e73a905c 100644
> > --- a/drivers/iio/light/apds9306.c
> > +++ b/drivers/iio/light/apds9306.c
> > @@ -831,11 +831,10 @@ static int apds9306_read_raw(struct iio_dev *indio_dev,
> >   		 * Changing device parameters during adc operation, resets
> >   		 * the ADC which has to avoided.
> >   		 */
> > -		ret = iio_device_claim_direct_mode(indio_dev);
> > -		if (ret)
> > -			return ret;
> > +		if (!iio_device_claim_direct(indio_dev))
> > +			return -EBUSY;
> >   		ret = apds9306_read_data(data, val, reg);
> > -		iio_device_release_direct_mode(indio_dev);
> > +		iio_device_release_direct(indio_dev);
> >   		if (ret)
> >   			return ret;
> >     
> Thank you Jonathan.
Maybe a tag if it looks fine to you?  Reviewed-by or Acked-by

Thanks,

Jonathan
diff mbox series

Patch

diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
index 69a0d609cffc..fca7e73a905c 100644
--- a/drivers/iio/light/apds9306.c
+++ b/drivers/iio/light/apds9306.c
@@ -831,11 +831,10 @@  static int apds9306_read_raw(struct iio_dev *indio_dev,
 		 * Changing device parameters during adc operation, resets
 		 * the ADC which has to avoided.
 		 */
-		ret = iio_device_claim_direct_mode(indio_dev);
-		if (ret)
-			return ret;
+		if (!iio_device_claim_direct(indio_dev))
+			return -EBUSY;
 		ret = apds9306_read_data(data, val, reg);
-		iio_device_release_direct_mode(indio_dev);
+		iio_device_release_direct(indio_dev);
 		if (ret)
 			return ret;