iio: dac: ad5360: converting to guard(mutex)
Subsystems (2)
PATCH 1/1 iio: dac: ad5360: converting to guard(mutex)
Converting mutex_lock and mutex_unlock to guard(mutex)
--- drivers/iio/dac/ad5360.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
drivers/iio/dac/ad5360.c +9 -20
@@ -206,14 +206,10 @@ static int ad5360_write_unlocked(struct iio_dev *indio_dev,static int ad5360_write (struct iio_dev *indio_dev,unsigned int cmd,unsigned int addr,unsigned int val,unsigned int shift) { -int ret;struct ad5360_state *st =iio_priv (indio_dev); -mutex_lock (&st->lock); - ret =ad5360_write_unlocked (indio_dev, cmd, addr, val, shift); -mutex_unlock (&st->lock); - -return ret; +guard (mutex)(&st->lock); +return ad5360_write_unlocked (indio_dev, cmd, addr, val, shift); } static int ad5360_read(struct iio_dev *indio_dev, unsigned int type,
@@ -232,7 +228,7 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, }, }; -mutex_lock (&st->lock); +guard (mutex)(&st->lock); st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) | AD5360_ADDR(AD5360_REG_SF_READBACK) |
@@ -240,12 +236,10 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, AD5360_READBACK_ADDR(addr)); ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t)); -if (ret >=0 ) - ret =be32_to_cpu (st->data[1 ].d32) &0xffff ; - -mutex_unlock (&st->lock); +if (ret <0 ) +return ret; -return ret; +return be32_to_cpu (st->data[1 ].d32) &0xffff ; } static ssize_t ad5360_read_dac_powerdown(struct device *dev,
@@ -262,19 +256,14 @@ static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set, unsigned int clr) {struct ad5360_state *st =iio_priv (indio_dev); -int ret; -mutex_lock (&st->lock); +guard (mutex)(&st->lock); st->ctrl |= set; st->ctrl &= ~clr; - ret =ad5360_write_unlocked (indio_dev,AD5360_CMD_SPECIAL_FUNCTION , -AD5360_REG_SF_CTRL , st->ctrl,0 ); - -mutex_unlock (&st->lock); - -return ret; +return ad5360_write_unlocked (indio_dev,AD5360_CMD_SPECIAL_FUNCTION , +AD5360_REG_SF_CTRL , st->ctrl,0 ); } static ssize_t ad5360_write_dac_powerdown(struct device *dev,
Signature · 1 line
2.52.0
David Lechner
reviewerI'm confused. Is this supposed to be v3 or v4?
See https://www.kernel.org/doc/html/latest/process/submitting-patches.html
Quoted 2 lines · Menderes Sabaz
Converting
mutex_lockandmutex_unlockto guard(mutex)
I gave my Reviewed-by: tag. It should have been picked up here or an explanation given why it was not. (Also explained in the link above.)
Quoted 2 lines
Signed-off-by Menderes Sabaz <[email protected]>---
A changelog should go here on what was changed since the last revision. (Also explained in the link above.)
Quoted 59 lines
drivers/iio/dac/ad5360.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)drivers/iio/dac/ad5360.c +7
-14@@ -206,14 +206,10 @@ static int ad5360_write_unlocked(struct iio_dev *indio_dev,static int ad5360_write (struct iio_dev *indio_dev,unsigned int cmd,unsigned int addr,unsigned int val,unsigned int shift) { -int ret;struct ad5360_state *st =iio_priv (indio_dev); -mutex_lock (&st->lock); - ret =ad5360_write_unlocked (indio_dev, cmd, addr, val, shift); -mutex_unlock (&st->lock); - -return ret; +guard (mutex)(&st->lock); +return ad5360_write_unlocked (indio_dev, cmd, addr, val, shift); } static int ad5360_read(struct iio_dev *indio_dev, unsigned int type,@@ -232,7 +228,7 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, }, }; -mutex_lock (&st->lock); +guard (mutex)(&st->lock); st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) | AD5360_ADDR(AD5360_REG_SF_READBACK) |@@ -240,12 +236,10 @@ static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, AD5360_READBACK_ADDR(addr)); ret =spi_sync_transfer (st->spi, t,ARRAY_SIZE (t)); -if (ret >=0 ) - ret =be32_to_cpu (st->data[1 ].d32) &0xffff ; - -mutex_unlock (&st->lock); +if (ret <0 ) +return ret; -return ret; +return be32_to_cpu (st->data[1 ].d32) &0xffff ; } static ssize_t ad5360_read_dac_powerdown(struct device *dev,@@ -262,19 +256,14 @@ static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set, unsigned int clr) {struct ad5360_state *st =iio_priv (indio_dev); -int ret; -mutex_lock (&st->lock); +guard (mutex)(&st->lock); st->ctrl |= set;
drivers/iio/dac/ad5360.c static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set, · line 266
Quoted 10 lines
drivers/iio/dac/ad5360.c +2
-6st->ctrl &= ~clr; - ret =ad5360_write_unlocked (indio_dev,AD5360_CMD_SPECIAL_FUNCTION , -AD5360_REG_SF_CTRL , st->ctrl,0 ); - -mutex_unlock (&st->lock); - -return ret; +return ad5360_write_unlocked (indio_dev,AD5360_CMD_SPECIAL_FUNCTION , +AD5360_REG_SF_CTRL , st->ctrl,0 );
Not sure the alignment is still quite right here. "indio_dev" and "AD5360_REG_SF_CTRL" should be starting on the same column. Running ./scipts/checkpatch.pl should give a warning if they are not.
Quoted 3 lines
drivers/iio/dac/ad5360.c +0
-0} static ssize_t ad5360_write_dac_powerdown(struct device *dev,