mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
iio: accel: STK8BA50: replace scale table with a struct
Replaced the stk8ba50_scale_table with an identically named struct in order to make the code a bit more readable. Signed-off-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
a858c7dab4
commit
003f4880bd
1 changed files with 7 additions and 4 deletions
|
@ -50,7 +50,10 @@
|
||||||
*
|
*
|
||||||
* Locally, the range is stored as a table index.
|
* Locally, the range is stored as a table index.
|
||||||
*/
|
*/
|
||||||
static const int stk8ba50_scale_table[][2] = {
|
static const struct {
|
||||||
|
u8 reg_val;
|
||||||
|
u32 scale_val;
|
||||||
|
} stk8ba50_scale_table[] = {
|
||||||
{3, 38400}, {5, 76700}, {8, 153400}, {12, 306900}
|
{3, 38400}, {5, 76700}, {8, 153400}, {12, 306900}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,7 +117,7 @@ static int stk8ba50_read_raw(struct iio_dev *indio_dev,
|
||||||
return IIO_VAL_INT;
|
return IIO_VAL_INT;
|
||||||
case IIO_CHAN_INFO_SCALE:
|
case IIO_CHAN_INFO_SCALE:
|
||||||
*val = 0;
|
*val = 0;
|
||||||
*val2 = stk8ba50_scale_table[data->range][1];
|
*val2 = stk8ba50_scale_table[data->range].scale_val;
|
||||||
return IIO_VAL_INT_PLUS_MICRO;
|
return IIO_VAL_INT_PLUS_MICRO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +139,7 @@ static int stk8ba50_write_raw(struct iio_dev *indio_dev,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(stk8ba50_scale_table); i++)
|
for (i = 0; i < ARRAY_SIZE(stk8ba50_scale_table); i++)
|
||||||
if (val2 == stk8ba50_scale_table[i][1]) {
|
if (val2 == stk8ba50_scale_table[i].scale_val) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +148,7 @@ static int stk8ba50_write_raw(struct iio_dev *indio_dev,
|
||||||
|
|
||||||
ret = i2c_smbus_write_byte_data(data->client,
|
ret = i2c_smbus_write_byte_data(data->client,
|
||||||
STK8BA50_REG_RANGE,
|
STK8BA50_REG_RANGE,
|
||||||
stk8ba50_scale_table[index][0]);
|
stk8ba50_scale_table[index].reg_val);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(&data->client->dev,
|
dev_err(&data->client->dev,
|
||||||
"failed to set measurement range\n");
|
"failed to set measurement range\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue