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: light: tsl2563: Use i2c_smbus_write_word_data() in tsl2563_configure()

Driver already uses the word accessors when it makes sense, but
in the tsl2563_configure(). Switch the latter to use word accessor.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Ferry Toth <ftoth@exalondelft.nl>
Link: https://lore.kernel.org/r/20221207190348.9347-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
3c183534 027641b5

+19 -33
+19 -33
drivers/iio/light/tsl2563.c
··· 49 49 50 50 #define TSL2563_REG_CTRL 0x00 51 51 #define TSL2563_REG_TIMING 0x01 52 - #define TSL2563_REG_LOWLOW 0x02 /* data0 low threshold, 2 bytes */ 53 - #define TSL2563_REG_LOWHIGH 0x03 54 - #define TSL2563_REG_HIGHLOW 0x04 /* data0 high threshold, 2 bytes */ 55 - #define TSL2563_REG_HIGHHIGH 0x05 52 + #define TSL2563_REG_LOW 0x02 /* data0 low threshold, 2 bytes */ 53 + #define TSL2563_REG_HIGH 0x04 /* data0 high threshold, 2 bytes */ 56 54 #define TSL2563_REG_INT 0x06 57 55 #define TSL2563_REG_ID 0x0a 58 - #define TSL2563_REG_DATA0LOW 0x0c /* broadband sensor value, 2 bytes */ 59 - #define TSL2563_REG_DATA0HIGH 0x0d 60 - #define TSL2563_REG_DATA1LOW 0x0e /* infrared sensor value, 2 bytes */ 61 - #define TSL2563_REG_DATA1HIGH 0x0f 56 + #define TSL2563_REG_DATA0 0x0c /* broadband sensor value, 2 bytes */ 57 + #define TSL2563_REG_DATA1 0x0e /* infrared sensor value, 2 bytes */ 62 58 63 59 #define TSL2563_CMD_POWER_ON 0x03 64 60 #define TSL2563_CMD_POWER_OFF 0x00 ··· 157 161 chip->gainlevel->gaintime); 158 162 if (ret) 159 163 goto error_ret; 160 - ret = i2c_smbus_write_byte_data(chip->client, 161 - TSL2563_CMD | TSL2563_REG_HIGHLOW, 162 - chip->high_thres & 0xFF); 164 + ret = i2c_smbus_write_word_data(chip->client, 165 + TSL2563_CMD | TSL2563_REG_HIGH, 166 + chip->high_thres); 163 167 if (ret) 164 168 goto error_ret; 165 - ret = i2c_smbus_write_byte_data(chip->client, 166 - TSL2563_CMD | TSL2563_REG_HIGHHIGH, 167 - (chip->high_thres >> 8) & 0xFF); 169 + ret = i2c_smbus_write_word_data(chip->client, 170 + TSL2563_CMD | TSL2563_REG_LOW, 171 + chip->low_thres); 168 172 if (ret) 169 173 goto error_ret; 170 - ret = i2c_smbus_write_byte_data(chip->client, 171 - TSL2563_CMD | TSL2563_REG_LOWLOW, 172 - chip->low_thres & 0xFF); 173 - if (ret) 174 - goto error_ret; 175 - ret = i2c_smbus_write_byte_data(chip->client, 176 - TSL2563_CMD | TSL2563_REG_LOWHIGH, 177 - (chip->low_thres >> 8) & 0xFF); 178 174 /* 179 175 * Interrupt register is automatically written anyway if it is relevant 180 176 * so is not here. ··· 313 325 314 326 while (retry) { 315 327 ret = i2c_smbus_read_word_data(client, 316 - TSL2563_CMD | TSL2563_REG_DATA0LOW); 328 + TSL2563_CMD | TSL2563_REG_DATA0); 317 329 if (ret < 0) 318 330 goto out; 319 331 adc0 = ret; 320 332 321 333 ret = i2c_smbus_read_word_data(client, 322 - TSL2563_CMD | TSL2563_REG_DATA1LOW); 334 + TSL2563_CMD | TSL2563_REG_DATA1); 323 335 if (ret < 0) 324 336 goto out; 325 337 adc1 = ret; ··· 572 584 { 573 585 struct tsl2563_chip *chip = iio_priv(indio_dev); 574 586 int ret; 575 - u8 address; 587 + 588 + mutex_lock(&chip->lock); 576 589 577 590 if (dir == IIO_EV_DIR_RISING) 578 - address = TSL2563_REG_HIGHLOW; 591 + ret = i2c_smbus_write_word_data(chip->client, 592 + TSL2563_CMD | TSL2563_REG_HIGH, val); 579 593 else 580 - address = TSL2563_REG_LOWLOW; 581 - mutex_lock(&chip->lock); 582 - ret = i2c_smbus_write_byte_data(chip->client, TSL2563_CMD | address, 583 - val & 0xFF); 594 + ret = i2c_smbus_write_word_data(chip->client, 595 + TSL2563_CMD | TSL2563_REG_LOW, val); 584 596 if (ret) 585 597 goto error_ret; 586 - ret = i2c_smbus_write_byte_data(chip->client, 587 - TSL2563_CMD | (address + 1), 588 - (val >> 8) & 0xFF); 598 + 589 599 if (dir == IIO_EV_DIR_RISING) 590 600 chip->high_thres = val; 591 601 else