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: magnetometer: yas530: Add IIO scaling to "chip_info"

Add IIO scaling to the "chip_info" structure to ease the handling to
different YAS variants.

Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/a12f892633bbee13a8856c231dc793ebbc5d3a03.1660337264.git.jahau@rocketmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Jakob Hauser and committed by
Jonathan Cameron
913fd409 dd9bd44f

+7 -21
+7 -21
drivers/iio/magnetometer/yamaha-yas530.c
··· 130 130 * @version_names: version letters or namings 131 131 * @volatile_reg: device-specific volatile registers 132 132 * @volatile_reg_qty: quantity of device-specific volatile registers 133 + * @scaling_val2: scaling value for IIO_CHAN_INFO_SCALE 133 134 */ 134 135 struct yas5xx_chip_info { 135 136 unsigned int devid; ··· 138 137 char *version_names[2]; 139 138 const int *volatile_reg; 140 139 int volatile_reg_qty; 140 + u32 scaling_val2; 141 141 }; 142 142 143 143 /** ··· 506 504 } 507 505 return IIO_VAL_INT; 508 506 case IIO_CHAN_INFO_SCALE: 509 - switch (ci->devid) { 510 - case YAS530_DEVICE_ID: 511 - /* 512 - * Raw values of YAS530 are in picotesla. Divide by 513 - * 100000000 (10^8) to get Gauss. 514 - */ 515 - *val = 1; 516 - *val2 = 100000000; 517 - break; 518 - case YAS532_DEVICE_ID: 519 - /* 520 - * Raw values of YAS532 are in nanotesla. Divide by 521 - * 100000 (10^5) to get Gauss. 522 - */ 523 - *val = 1; 524 - *val2 = 100000; 525 - break; 526 - default: 527 - dev_err(yas5xx->dev, "unknown device type\n"); 528 - return -EINVAL; 529 - } 507 + *val = 1; 508 + *val2 = ci->scaling_val2; 530 509 return IIO_VAL_FRACTIONAL; 531 510 default: 532 511 /* Unknown request */ ··· 934 951 .version_names = { "A", "B" }, 935 952 .volatile_reg = yas530_volatile_reg, 936 953 .volatile_reg_qty = ARRAY_SIZE(yas530_volatile_reg), 954 + .scaling_val2 = 100000000, /* picotesla to Gauss */ 937 955 }, 938 956 [yas532] = { 939 957 .devid = YAS532_DEVICE_ID, ··· 942 958 .version_names = { "AB", "AC" }, 943 959 .volatile_reg = yas530_volatile_reg, 944 960 .volatile_reg_qty = ARRAY_SIZE(yas530_volatile_reg), 961 + .scaling_val2 = 100000, /* nanotesla to Gauss */ 945 962 }, 946 963 [yas533] = { 947 964 .devid = YAS532_DEVICE_ID, ··· 950 965 .version_names = { "AB", "AC" }, 951 966 .volatile_reg = yas530_volatile_reg, 952 967 .volatile_reg_qty = ARRAY_SIZE(yas530_volatile_reg), 968 + .scaling_val2 = 100000, /* nanotesla to Gauss */ 953 969 }, 954 970 }; 955 971