iio: adc: clean up claims on direct mode in ad7* drivers
Subsystems (3)
cover iio: adc: clean up claims on direct mode in ad7* drivers
This set looks at the ad7* drivers and migrates them to use the iio helper functions iio_device_claim|release_direct_mode().
The first three (7266,7791,7793) were not already holding a lock on direct mode, so this will be a change in behavior for those drivers.
The last four (7476,7887,7923,799x) were already locking so these are migrations to the claim/release helper functions.
Worth noting: This does not clean up all mlock (ab-)uses in ad799x. This driver is still using mlock in a few other places not associated with locking down direct mode.
Alison Schofield (7):
iio: adc: ad7266: claim direct mode during sensor read
iio: adc: ad7791: claim direct mode when writing frequency
iio: adc: ad7793: claim direct mode when writing frequency
iio: adc: ad7476: use iio helper function to guarantee direct mode
iio: adc: ad7887: use iio helper function to guarantee direct mode
iio: adc: ad7923: use iio helper function to guarantee direct mode
iio: adc: ad799x: use iio helper function to guarantee direct mode
drivers/iio/adc/ad7266.c | 7 +++---- drivers/iio/adc/ad7476.c | 11 +++++------ drivers/iio/adc/ad7791.c | 15 ++++----------- drivers/iio/adc/ad7793.c | 13 ++++--------- drivers/iio/adc/ad7887.c | 11 +++++------ drivers/iio/adc/ad7923.c | 11 +++++------ drivers/iio/adc/ad799x.c | 24 +++++++++--------------- 7 files changed, 35 insertions(+), 57 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/7 iio: adc: ad7266: claim direct mode during sensor read
Driver was checking for direct mode but not locking it down. Use iio_device_claim_direct_mode() to guarantee device stays in direct mode.
--- drivers/iio/adc/ad7266.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/adc/ad7266.c +3 -4
@@ -154,12 +154,11 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -if (iio_buffer_enabled (indio_dev)) -return -EBUSY ; - - ret =ad7266_read_single (st, val, chan->address); + ret =iio_device_claim_direct_mode (indio_dev);if (ret)return ret; + ret =ad7266_read_single (st, val, chan->address); +iio_device_release_direct_mode (indio_dev); *val = (*val >>2 ) &0xfff ;if (chan->scan_type.sign =='s' )
Signature · 1 line
2.1.4
Re: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read
Quoted 6 lines · Alison Schofield
Driver was checking for direct mode but not locking it down. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Quoted 25 lines
--- drivers/iio/adc/ad7266.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/iio/adc/ad7266.c +3
-5@@ -154,12 +154,11 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -if (iio_buffer_enabled (indio_dev)) -return -EBUSY ; - - ret =ad7266_read_single (st, val, chan->address); + ret =iio_device_claim_direct_mode (indio_dev);if (ret)return ret; + ret =ad7266_read_single (st, val, chan->address); +iio_device_release_direct_mode (indio_dev); *val = (*val >>2 ) &0xfff ;if (chan->scan_type.sign =='s' ) --
Jonathan Cameron
maintainerRe: [PATCH 1/7] iio: adc: ad7266: claim direct mode during sensor read
Quoted 9 lines · Daniel Baluta
Quoted 6 lines · Alison Schofield
Driver was checking for direct mode but not locking it down. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Acked-by Daniel Baluta <[email protected]>
Looks good.
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 31 lines
Quoted 16 lines
--- drivers/iio/adc/ad7266.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/iio/adc/ad7266.c +0
-3@@ -154,12 +154,11 @@ static int ad7266_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -if (iio_buffer_enabled (indio_dev)) -return -EBUSY ; -drivers/iio/adc/ad7266.c static int ad7266_read_raw(struct iio_dev *indio_dev,
Quoted 10 lines
drivers/iio/adc/ad7266.c +3
-2- ret =ad7266_read_single (st, val, chan->address); + ret =iio_device_claim_direct_mode (indio_dev);if (ret)return ret; + ret =ad7266_read_single (st, val, chan->address); +iio_device_release_direct_mode (indio_dev); *val = (*val >>2 ) &0xfff ;if (chan->scan_type.sign =='s' ) ----
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/7 iio: adc: ad7791: claim direct mode when writing frequency
In reply to Alison SchofieldDriver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use iio_device_claim_direct_mode() to guarantee device stays in direct mode.
--- drivers/iio/adc/ad7791.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/iio/adc/ad7791.c +4 -11
@@ -272,24 +272,17 @@ static ssize_t ad7791_write_frequency(struct device *dev,struct ad7791_state *st =iio_priv (indio_dev);int i, ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { -mutex_unlock (&indio_dev->mlock); -return -EBUSY ; - } -mutex_unlock (&indio_dev->mlock); - - ret = -EINVAL ; -for (i =0 ; i <ARRAY_SIZE (ad7791_sample_freq_avail); i++) {if (sysfs_streq (ad7791_sample_freq_avail[i], buf)) { -mutex_lock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; st->filter &= ~AD7791_FILTER_RATE_MASK ; st->filter |= i;ad_sd_write_reg (&st->sd,AD7791_REG_FILTER ,sizeof (st->filter), st->filter); -mutex_unlock (&indio_dev->mlock); +iio_device_release_direct_mode (indio_dev); ret =0 ;break ; }
Signature · 1 line
2.1.4
Re: [PATCH 2/7] iio: adc: ad7791: claim direct mode when writing frequency
Quoted 7 lines · Alison Schofield
Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Looks good to me. We could use an Acked-by from Lars here.
Quoted 44 lines
--- drivers/iio/adc/ad7791.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/iio/adc/ad7791.c +4
-12@@ -272,24 +272,17 @@ static ssize_t ad7791_write_frequency(struct device *dev,struct ad7791_state *st =iio_priv (indio_dev);int i, ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { -mutex_unlock (&indio_dev->mlock); -return -EBUSY ; - } -mutex_unlock (&indio_dev->mlock); - - ret = -EINVAL ; -for (i =0 ; i <ARRAY_SIZE (ad7791_sample_freq_avail); i++) {if (sysfs_streq (ad7791_sample_freq_avail[i], buf)) { -mutex_lock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; st->filter &= ~AD7791_FILTER_RATE_MASK ; st->filter |= i;ad_sd_write_reg (&st->sd,AD7791_REG_FILTER ,sizeof (st->filter), st->filter); -mutex_unlock (&indio_dev->mlock); +iio_device_release_direct_mode (indio_dev); ret =0 ;break ; } --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerRe: [PATCH 2/7] iio: adc: ad7791: claim direct mode when writing frequency
Quoted 6 lines · Daniel Baluta
Quoted 5 lines · Alison Schofield
Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Looks good to me. We could use an Acked-by from Lars here.
Acked-by Daniel Baluta <[email protected]>
This one is a little more interesting. I wonder if we wouldn't be better off taking the lock for the whole function rather than dropping it for short periods.
Can apply such a change at a later date however.
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 45 lines
Quoted 45 lines
--- drivers/iio/adc/ad7791.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/iio/adc/ad7791.c +4
-12@@ -272,24 +272,17 @@ static ssize_t ad7791_write_frequency(struct device *dev,struct ad7791_state *st =iio_priv (indio_dev);int i, ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { -mutex_unlock (&indio_dev->mlock); -return -EBUSY ; - } -mutex_unlock (&indio_dev->mlock); - - ret = -EINVAL ; -for (i =0 ; i <ARRAY_SIZE (ad7791_sample_freq_avail); i++) {if (sysfs_streq (ad7791_sample_freq_avail[i], buf)) { -mutex_lock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; st->filter &= ~AD7791_FILTER_RATE_MASK ; st->filter |= i;ad_sd_write_reg (&st->sd,AD7791_REG_FILTER ,sizeof (st->filter), st->filter); -mutex_unlock (&indio_dev->mlock); +iio_device_release_direct_mode (indio_dev); ret =0 ;break ; } --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerRe: [PATCH 2/7] iio: adc: ad7791: claim direct mode when writing frequency
Quoted 13 lines · Jonathan Cameron
Quoted 6 lines · Daniel Baluta
Quoted 5 lines · Alison Schofield
Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.Quoted 6 lines
Quoted 2 lines
Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Looks good to me. We could use an Acked-by from Lars here.
Acked-by Daniel Baluta <[email protected]>
Quoted 8 lines
This one is a little more interesting. I wonder if we wouldn't be better off taking the lock for the whole function rather than dropping it for short periods.
Can apply such a change at a later date however.
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.
Actually haven't seen Daniel suggesting an Ack from Lars might be good for this one I've backed it out for now.
Lars?
Quoted 56 lines
Thanks,
Jonathan
Quoted 41 lines
Quoted 41 lines
--- drivers/iio/adc/ad7791.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/iio/adc/ad7791.c +4
-12@@ -272,24 +272,17 @@ static ssize_t ad7791_write_frequency(struct device *dev,struct ad7791_state *st =iio_priv (indio_dev);int i, ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { -mutex_unlock (&indio_dev->mlock); -return -EBUSY ; - } -mutex_unlock (&indio_dev->mlock); - - ret = -EINVAL ; -for (i =0 ; i <ARRAY_SIZE (ad7791_sample_freq_avail); i++) {if (sysfs_streq (ad7791_sample_freq_avail[i], buf)) { -mutex_lock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; st->filter &= ~AD7791_FILTER_RATE_MASK ; st->filter |= i;ad_sd_write_reg (&st->sd,AD7791_REG_FILTER ,sizeof (st->filter), st->filter); -mutex_unlock (&indio_dev->mlock); +iio_device_release_direct_mode (indio_dev); ret =0 ;break ; } --2.1.4
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/7] iio: adc: ad7791: claim direct mode when writing frequency
In reply to Jonathan CameronQuoted 10 lines · Jonathan Cameron
Quoted 9 lines · Daniel Baluta
Quoted 7 lines · Alison Schofield
Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Quoted 6 lines
Quoted 3 lines
Looks good to me. We could use an Acked-by from Lars here.
Acked-by Daniel Baluta <[email protected]>This one is a little more interesting. I wonder if we wouldn't be better off taking the lock for the whole function rather than dropping it for short periods.
It will only be locked once. sysfs_streq() will only match for a single item. But you are right the code could be refactored to make that more clearer. First run the lookup look and then apply afterwards.
PATCH 3/7 iio: adc: ad7793: claim direct mode when writing frequency
In reply to Alison SchofieldDriver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use iio_device_claim_direct_mode() to guarantee device stays in direct mode.
--- drivers/iio/adc/ad7793.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/iio/adc/ad7793.c +4 -9
@@ -369,13 +369,6 @@ static ssize_t ad7793_write_frequency(struct device *dev,long lval;int i, ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { -mutex_unlock (&indio_dev->mlock); -return -EBUSY ; - } -mutex_unlock (&indio_dev->mlock); - ret =kstrtol (buf,10 , &lval);if (ret)return ret;
@@ -387,12 +380,14 @@ static ssize_t ad7793_write_frequency(struct device *dev,for (i =0 ; i <16 ; i++)if (lval == st->chip_info->sample_freq_avail[i]) { -mutex_lock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; st->mode &= ~AD7793_MODE_RATE (-1 ); st->mode |=AD7793_MODE_RATE (i);ad_sd_write_reg (&st->sd,AD7793_REG_MODE ,sizeof (st->mode), st->mode); -mutex_unlock (&indio_dev->mlock); +iio_device_release_direct_mode (indio_dev); ret =0 ; }
Signature · 1 line
2.1.4
Re: [PATCH 3/7] iio: adc: ad7793: claim direct mode when writing frequency
Quoted 7 lines · Alison Schofield
Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Quoted 40 lines
--- drivers/iio/adc/ad7793.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/iio/adc/ad7793.c +4
-10@@ -369,13 +369,6 @@ static ssize_t ad7793_write_frequency(struct device *dev,long lval;int i, ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { -mutex_unlock (&indio_dev->mlock); -return -EBUSY ; - } -mutex_unlock (&indio_dev->mlock); - ret =kstrtol (buf,10 , &lval);if (ret)return ret;@@ -387,12 +380,14 @@ static ssize_t ad7793_write_frequency(struct device *dev,for (i =0 ; i <16 ; i++)if (lval == st->chip_info->sample_freq_avail[i]) { -mutex_lock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; st->mode &= ~AD7793_MODE_RATE (-1 ); st->mode |=AD7793_MODE_RATE (i);ad_sd_write_reg (&st->sd,AD7793_REG_MODE ,sizeof (st->mode), st->mode); -mutex_unlock (&indio_dev->mlock); +iio_device_release_direct_mode (indio_dev); ret =0 ; } --
Jonathan Cameron
maintainerRe: [PATCH 3/7] iio: adc: ad7793: claim direct mode when writing frequency
Quoted 10 lines · Daniel Baluta
Quoted 7 lines · Alison Schofield
Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Acked-by Daniel Baluta <[email protected]>
Again, this one is not quite so trivial so I'll wait for Lars to take a look even though I'm happy with it.
Thanks,
Jonathan
Quoted 46 lines
Quoted 31 lines
--- drivers/iio/adc/ad7793.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/iio/adc/ad7793.c +3
-8@@ -369,13 +369,6 @@ static ssize_t ad7793_write_frequency(struct device *dev,long lval;int i, ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { -mutex_unlock (&indio_dev->mlock); -return -EBUSY ; - } -mutex_unlock (&indio_dev->mlock); - ret =kstrtol (buf,10 , &lval);if (ret)return ret;@@ -387,12 +380,14 @@ static ssize_t ad7793_write_frequency(struct device *dev,for (i =0 ; i <16 ; i++)if (lval == st->chip_info->sample_freq_avail[i]) { -mutex_lock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret;drivers/iio/adc/ad7793.c static ssize_t ad7793_write_frequency(struct device *dev,
Quoted 10 lines
drivers/iio/adc/ad7793.c +1
-2st->mode &= ~AD7793_MODE_RATE (-1 ); st->mode |=AD7793_MODE_RATE (i);ad_sd_write_reg (&st->sd,AD7793_REG_MODE ,sizeof (st->mode), st->mode); -mutex_unlock (&indio_dev->mlock); +iio_device_release_direct_mode (indio_dev); ret =0 ; } ----
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Lars-Peter Clausen
Acked-byRe: [PATCH 3/7] iio: adc: ad7793: claim direct mode when writing frequency
Quoted 7 lines · Jonathan Cameron
Quoted 6 lines · Daniel Baluta
Quoted 5 lines · Alison Schofield
Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use
iio_device_claim_direct_mode()to guarantee device stays in direct mode.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Acked-by Daniel Baluta <[email protected]>Again, this one is not quite so trivial so I'll wait for Lars to take a look even though I'm happy with it.
Same as patch too. Looks good otherwise.
PATCH 4/7 iio: adc: ad7476: use iio helper function to guarantee direct mode
In reply to Alison SchofieldReplace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same.
--- drivers/iio/adc/ad7476.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/adc/ad7476.c +5 -6
@@ -106,12 +106,11 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7476_scan_direct (st); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7476_scan_direct (st); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret;
Signature · 1 line
2.1.4
Re: [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Quoted 33 lines
--- drivers/iio/adc/ad7476.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/adc/ad7476.c +5
-7@@ -106,12 +106,11 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7476_scan_direct (st); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7476_scan_direct (st); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerRe: [PATCH 4/7] iio: adc: ad7476: use iio helper function to guarantee direct mode
Quoted 8 lines · Daniel Baluta
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Acked-by Daniel Baluta <[email protected]>
Straight forward one. Applied.
Thanks,
Quoted 34 lines
Quoted 34 lines
--- drivers/iio/adc/ad7476.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/adc/ad7476.c +5
-7@@ -106,12 +106,11 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7476_scan_direct (st); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7476_scan_direct (st); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/7 iio: adc: ad7887: use iio helper function to guarantee direct mode
In reply to Alison SchofieldReplace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same.
--- drivers/iio/adc/ad7887.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/adc/ad7887.c +5 -6
@@ -156,12 +156,11 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7887_scan_direct (st, chan->address); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7887_scan_direct (st, chan->address); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret;
Signature · 1 line
2.1.4
Re: [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Quoted 27 lines
--- drivers/iio/adc/ad7887.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/adc/ad7887.c +5
-7@@ -156,12 +156,11 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7887_scan_direct (st, chan->address); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7887_scan_direct (st, chan->address); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; --
Jonathan Cameron
maintainerRe: [PATCH 5/7] iio: adc: ad7887: use iio helper function to guarantee direct mode
Quoted 8 lines · Daniel Baluta
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Acked-by Daniel Baluta <[email protected]>
Applied - thanks.
Jonathan
Quoted 33 lines
Quoted 18 lines
--- drivers/iio/adc/ad7887.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/adc/ad7887.c +0
-5@@ -156,12 +156,11 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7887_scan_direct (st, chan->address);drivers/iio/adc/ad7887.c static int ad7887_read_raw(struct iio_dev *indio_dev,
Quoted 10 lines
drivers/iio/adc/ad7887.c +5
-2-mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7887_scan_direct (st, chan->address); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; ----
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/7 iio: adc: ad7923: use iio helper function to guarantee direct mode
In reply to Alison SchofieldReplace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same.
--- drivers/iio/adc/ad7923.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/iio/adc/ad7923.c +5 -6
@@ -233,12 +233,11 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7923_scan_direct (st, chan->address); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7923_scan_direct (st, chan->address); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret;
Signature · 1 line
2.1.4
Re: [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Quoted 33 lines
--- drivers/iio/adc/ad7923.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/adc/ad7923.c +5
-7@@ -233,12 +233,11 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7923_scan_direct (st, chan->address); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7923_scan_direct (st, chan->address); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/7] iio: adc: ad7923: use iio helper function to guarantee direct mode
Quoted 8 lines · Daniel Baluta
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Acked-by Daniel Baluta <[email protected]>
Applied, - thanks
Jonathan
Quoted 35 lines
Quoted 35 lines
--- drivers/iio/adc/ad7923.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/iio/adc/ad7923.c +5
-7@@ -233,12 +233,11 @@ static int ad7923_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad7923_scan_direct (st, chan->address); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad7923_scan_direct (st, chan->address); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret; --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/7 iio: adc: ad799x: use iio helper function to guarantee direct mode
In reply to Alison SchofieldReplace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same.
--- drivers/iio/adc/ad799x.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/iio/adc/ad799x.c +9 -15
@@ -282,12 +282,11 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad799x_scan_direct (st, chan->scan_index); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad799x_scan_direct (st, chan->scan_index); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret;
@@ -395,11 +394,9 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,struct ad799x_state *st =iio_priv (indio_dev);int ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { - ret = -EBUSY ; - goto done; - } + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret;if (state) st->config |=BIT (chan->scan_index) <<AD799X_CHANNEL_SHIFT ;
@@ -412,10 +409,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev, st->config &= ~AD7998_ALERT_EN ; ret =ad799x_write_config (st, st->config); - -done: -mutex_unlock (&indio_dev->mlock); - +iio_device_release_direct_mode (indio_dev);return ret; }
Signature · 1 line
2.1.4
Re: [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>
Quoted 54 lines
--- drivers/iio/adc/ad799x.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)drivers/iio/adc/ad799x.c +9
-16@@ -282,12 +282,11 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad799x_scan_direct (st, chan->scan_index); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad799x_scan_direct (st, chan->scan_index); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret;@@ -395,11 +394,9 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,struct ad799x_state *st =iio_priv (indio_dev);int ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { - ret = -EBUSY ; - goto done; - } + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret;if (state) st->config |=BIT (chan->scan_index) <<AD799X_CHANNEL_SHIFT ;@@ -412,10 +409,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev, st->config &= ~AD7998_ALERT_EN ; ret =ad799x_write_config (st, st->config); - -done: -mutex_unlock (&indio_dev->mlock); - +iio_device_release_direct_mode (indio_dev);return ret; } --
Jonathan Cameron
maintainerRe: [PATCH 7/7] iio: adc: ad799x: use iio helper function to guarantee direct mode
Quoted 8 lines · Daniel Baluta
Quoted 5 lines · Alison Schofield
Replace the code that guarantees the device stays in direct mode with
iio_device_claim_direct_mode()which does same.Signed-off-by Alison Schofield <[email protected]>Cc Daniel Baluta <[email protected]>Acked-by Daniel Baluta <[email protected]>
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 61 lines
Quoted 46 lines
--- drivers/iio/adc/ad799x.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)drivers/iio/adc/ad799x.c +8
-11@@ -282,12 +282,11 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,switch (m) {case IIO_CHAN_INFO_RAW : -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) - ret = -EBUSY ; -else - ret =ad799x_scan_direct (st, chan->scan_index); -mutex_unlock (&indio_dev->mlock); + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret; + ret =ad799x_scan_direct (st, chan->scan_index); +iio_device_release_direct_mode (indio_dev);if (ret <0 )return ret;@@ -395,11 +394,9 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev,struct ad799x_state *st =iio_priv (indio_dev);int ret; -mutex_lock (&indio_dev->mlock); -if (iio_buffer_enabled (indio_dev)) { - ret = -EBUSY ; - goto done; - } + ret =iio_device_claim_direct_mode (indio_dev); +if (ret) +return ret;if (state) st->config |=BIT (chan->scan_index) <<AD799X_CHANNEL_SHIFT ;@@ -412,10 +409,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev, st->config &= ~AD7998_ALERT_EN ;drivers/iio/adc/ad799x.c static int ad799x_write_event_config(struct iio_dev *indio_dev,
Quoted 10 lines
drivers/iio/adc/ad799x.c +1
-5ret =ad799x_write_config (st, st->config); - -done: -mutex_unlock (&indio_dev->mlock); - +iio_device_release_direct_mode (indio_dev);return ret; } ----
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html