Skip to content

Commit 10ecf78

Browse files
andy-shevjic23
authored andcommitted
iio: magnetometer: yamaha-yas530: Get rid of i2c_client_get_device_id()
Instead of relying on the name from ID table, which might be ambiguous in some cases, use explicit product label in the driver data. With that being done, get rid of i2c_client_get_device_id() call. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 4452b86 commit 10ecf78

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/iio/magnetometer/yamaha-yas530.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct yas5xx;
168168
/**
169169
* struct yas5xx_chip_info - device-specific data and function pointers
170170
* @devid: device ID number
171+
* @product_label: product label used in Linux
171172
* @product_name: product name of the YAS variant
172173
* @version_names: version letters or namings
173174
* @volatile_reg: device-specific volatile registers
@@ -189,6 +190,7 @@ struct yas5xx;
189190
*/
190191
struct yas5xx_chip_info {
191192
unsigned int devid;
193+
const char *product_label;
192194
const char *product_name;
193195
const char *version_names[2];
194196
const int *volatile_reg;
@@ -1323,6 +1325,7 @@ static int yas537_power_on(struct yas5xx *yas5xx)
13231325
static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
13241326
[yas530] = {
13251327
.devid = YAS530_DEVICE_ID,
1328+
.product_label = "yas530",
13261329
.product_name = "YAS530 MS-3E",
13271330
.version_names = { "A", "B" },
13281331
.volatile_reg = yas530_volatile_reg,
@@ -1338,6 +1341,7 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
13381341
},
13391342
[yas532] = {
13401343
.devid = YAS532_DEVICE_ID,
1344+
.product_label = "yas532",
13411345
.product_name = "YAS532 MS-3R",
13421346
.version_names = { "AB", "AC" },
13431347
.volatile_reg = yas530_volatile_reg,
@@ -1353,6 +1357,7 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
13531357
},
13541358
[yas533] = {
13551359
.devid = YAS532_DEVICE_ID,
1360+
.product_label = "yas533",
13561361
.product_name = "YAS533 MS-3F",
13571362
.version_names = { "AB", "AC" },
13581363
.volatile_reg = yas530_volatile_reg,
@@ -1368,6 +1373,7 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
13681373
},
13691374
[yas537] = {
13701375
.devid = YAS537_DEVICE_ID,
1376+
.product_label = "yas537",
13711377
.product_name = "YAS537 MS-3T",
13721378
.version_names = { "v0", "v1" }, /* version naming unknown */
13731379
.volatile_reg = yas537_volatile_reg,
@@ -1385,7 +1391,6 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
13851391

13861392
static int yas5xx_probe(struct i2c_client *i2c)
13871393
{
1388-
const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
13891394
struct iio_dev *indio_dev;
13901395
struct device *dev = &i2c->dev;
13911396
struct yas5xx *yas5xx;
@@ -1443,7 +1448,7 @@ static int yas5xx_probe(struct i2c_client *i2c)
14431448
if (id_check != ci->devid) {
14441449
ret = dev_err_probe(dev, -ENODEV,
14451450
"device ID %02x doesn't match %s\n",
1446-
id_check, id->name);
1451+
id_check, ci->product_label);
14471452
goto assert_reset;
14481453
}
14491454

@@ -1469,7 +1474,7 @@ static int yas5xx_probe(struct i2c_client *i2c)
14691474
indio_dev->info = &yas5xx_info;
14701475
indio_dev->available_scan_masks = yas5xx_scan_masks;
14711476
indio_dev->modes = INDIO_DIRECT_MODE;
1472-
indio_dev->name = id->name;
1477+
indio_dev->name = ci->product_label;
14731478
indio_dev->channels = yas5xx_channels;
14741479
indio_dev->num_channels = ARRAY_SIZE(yas5xx_channels);
14751480

0 commit comments

Comments
 (0)