Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: dac: ad5360: converting to guard(mutex)

Converting mutex_lock and mutex_unlock to guard(mutex)

Signed-off-by: Menderes Sabaz <sabazmenderes@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Menderes Sabaz and committed by
Jonathan Cameron
6662283a 1bceffda

+9 -20
+9 -20
drivers/iio/dac/ad5360.c
··· 206 206 static int ad5360_write(struct iio_dev *indio_dev, unsigned int cmd, 207 207 unsigned int addr, unsigned int val, unsigned int shift) 208 208 { 209 - int ret; 210 209 struct ad5360_state *st = iio_priv(indio_dev); 211 210 212 - mutex_lock(&st->lock); 213 - ret = ad5360_write_unlocked(indio_dev, cmd, addr, val, shift); 214 - mutex_unlock(&st->lock); 215 - 216 - return ret; 211 + guard(mutex)(&st->lock); 212 + return ad5360_write_unlocked(indio_dev, cmd, addr, val, shift); 217 213 } 218 214 219 215 static int ad5360_read(struct iio_dev *indio_dev, unsigned int type, ··· 228 232 }, 229 233 }; 230 234 231 - mutex_lock(&st->lock); 235 + guard(mutex)(&st->lock); 232 236 233 237 st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) | 234 238 AD5360_ADDR(AD5360_REG_SF_READBACK) | ··· 236 240 AD5360_READBACK_ADDR(addr)); 237 241 238 242 ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); 239 - if (ret >= 0) 240 - ret = be32_to_cpu(st->data[1].d32) & 0xffff; 243 + if (ret < 0) 244 + return ret; 241 245 242 - mutex_unlock(&st->lock); 243 - 244 - return ret; 246 + return be32_to_cpu(st->data[1].d32) & 0xffff; 245 247 } 246 248 247 249 static ssize_t ad5360_read_dac_powerdown(struct device *dev, ··· 256 262 unsigned int clr) 257 263 { 258 264 struct ad5360_state *st = iio_priv(indio_dev); 259 - int ret; 260 265 261 - mutex_lock(&st->lock); 266 + guard(mutex)(&st->lock); 262 267 263 268 st->ctrl |= set; 264 269 st->ctrl &= ~clr; 265 270 266 - ret = ad5360_write_unlocked(indio_dev, AD5360_CMD_SPECIAL_FUNCTION, 267 - AD5360_REG_SF_CTRL, st->ctrl, 0); 268 - 269 - mutex_unlock(&st->lock); 270 - 271 - return ret; 271 + return ad5360_write_unlocked(indio_dev, AD5360_CMD_SPECIAL_FUNCTION, 272 + AD5360_REG_SF_CTRL, st->ctrl, 0); 272 273 } 273 274 274 275 static ssize_t ad5360_write_dac_powerdown(struct device *dev,