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: cm3232: Reset before reading HW ID

According to the datasheet, the chip requires a reset before any data
can be read. This commit moves the device identification logic to
occur after the reset to ensure proper initialization.

Cc: Kevin Tsai <ktsai@capellamicro.com>
Signed-off-by: Cibil Pankiras <cibil.pankiras@aerq.com>
Link: https://patch.msgid.link/20241114091323.7415-1-cibil.pankiras@aerq.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Cibil Pankiras and committed by
Jonathan Cameron
df81f90c 2d694193

+9 -9
+9 -9
drivers/iio/light/cm3232.c
··· 89 89 90 90 chip->als_info = &cm3232_als_info_default; 91 91 92 + /* Disable and reset device */ 93 + chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET; 94 + ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD, 95 + chip->regs_cmd); 96 + if (ret < 0) { 97 + dev_err(&chip->client->dev, "Error writing reg_cmd\n"); 98 + return ret; 99 + } 100 + 92 101 /* Identify device */ 93 102 ret = i2c_smbus_read_word_data(client, CM3232_REG_ADDR_ID); 94 103 if (ret < 0) { ··· 107 98 108 99 if ((ret & 0xFF) != chip->als_info->hw_id) 109 100 return -ENODEV; 110 - 111 - /* Disable and reset device */ 112 - chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET; 113 - ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD, 114 - chip->regs_cmd); 115 - if (ret < 0) { 116 - dev_err(&chip->client->dev, "Error writing reg_cmd\n"); 117 - return ret; 118 - } 119 101 120 102 /* Register default value */ 121 103 chip->regs_cmd = chip->als_info->regs_cmd_default;