diff options
| author | Martin Kurbanov <mmkurbanov@salutedevices.com> | 2025-09-18 13:37:15 +0300 |
|---|---|---|
| committer | Dmitry Rokosov <rockosov@rulkc.org> | 2026-08-13 14:41:33 +0300 |
| commit | 548ab6622d5be598e06ae73ed80569c7be2b9047 (patch) | |
| tree | 1aa622cac867fae0472d59661539aeab1546c622 | |
| parent | 53e9e97750811c89b0ccae9ef49619d73d47ba18 (diff) | |
| download | linux-548ab6622d5be598e06ae73ed80569c7be2b9047.tar.gz linux-548ab6622d5be598e06ae73ed80569c7be2b9047.zip | |
iio: hx3203: switch to sparse friendly iio_device_claim/release_direct
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: Martin Kurbanov <mmkurbanov@salutedevices.com>
Signed-off-by: Dmitry Rokosov <rockosov@rulkc.org>
| -rw-r--r-- | drivers/iio/light/hx3203.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/drivers/iio/light/hx3203.c b/drivers/iio/light/hx3203.c index f69611336863..5e33b61c04fc 100644 --- a/drivers/iio/light/hx3203.c +++ b/drivers/iio/light/hx3203.c @@ -662,17 +662,16 @@ static int hx3203_read_raw_data(struct iio_dev *indio_dev, return -EINVAL; } - err = iio_device_claim_direct_mode(indio_dev); - if (err) { - dev_err(dev, "can't claim direct mode (%d)\n", err); - return err; + if (!iio_device_claim_direct(indio_dev)) { + dev_err(dev, "can't claim direct mode\n"); + return -EBUSY; } mutex_lock(&hx3203->lock); err = hx3203_get_chs(hx3203, chs); mutex_unlock(&hx3203->lock); - iio_device_release_direct_mode(indio_dev); + iio_device_release_direct(indio_dev); if (err) { dev_err(dev, "can't get channels data (%d)\n", err); @@ -707,17 +706,16 @@ static int hx3203_read_processed(struct iio_dev *indio_dev, return -EINVAL; } - err = iio_device_claim_direct_mode(indio_dev); - if (err) { - dev_err(dev, "can't claim direct mode (%d)\n", err); - return err; + if (!iio_device_claim_direct(indio_dev)) { + dev_err(dev, "can't claim direct mode\n"); + return -EBUSY; } mutex_lock(&hx3203->lock); err = hx3203_get_lux(hx3203, val); mutex_unlock(&hx3203->lock); - iio_device_release_direct_mode(indio_dev); + iio_device_release_direct(indio_dev); if (err) { dev_err(dev, "can't get lux measurement (%d)\n", err); @@ -822,10 +820,9 @@ static int hx3203_write_scale(struct iio_dev *indio_dev, if (chan->type != IIO_INTENSITY) return -EINVAL; - err = iio_device_claim_direct_mode(indio_dev); - if (err) { - dev_err(dev, "can't claim direct mode (%d)\n", err); - return err; + if (!iio_device_claim_direct(indio_dev)) { + dev_err(dev, "can't claim direct mode\n"); + return -EBUSY; } /* @@ -838,7 +835,7 @@ static int hx3203_write_scale(struct iio_dev *indio_dev, err = regmap_field_write(hx3203->fields[F_AGAIN], again); mutex_unlock(&hx3203->lock); - iio_device_release_direct_mode(indio_dev); + iio_device_release_direct(indio_dev); if (err) { dev_err(dev, "can't set again scale to %u (%d)\n", again, err); @@ -862,10 +859,9 @@ static int hx3203_write_int_time(struct iio_dev *indio_dev, return -EINVAL; } - err = iio_device_claim_direct_mode(indio_dev); - if (err) { - dev_err(dev, "can't claim direct mode (%d)\n", err); - return err; + if (!iio_device_claim_direct(indio_dev)) { + dev_err(dev, "can't claim direct mode\n"); + return -EBUSY; } err = -EINVAL; @@ -878,7 +874,7 @@ static int hx3203_write_int_time(struct iio_dev *indio_dev, break; } - iio_device_release_direct_mode(indio_dev); + iio_device_release_direct(indio_dev); if (err) dev_err(dev, |
