Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tiberiu Breana and committed by
Jonathan Cameron
003f4880 a858c7da

+7 -4
+7 -4
drivers/iio/accel/stk8ba50.c
··· 50 50 * 51 51 * Locally, the range is stored as a table index. 52 52 */ 53 - static const int stk8ba50_scale_table[][2] = { 53 + static const struct { 54 + u8 reg_val; 55 + u32 scale_val; 56 + } stk8ba50_scale_table[] = { 54 57 {3, 38400}, {5, 76700}, {8, 153400}, {12, 306900} 55 58 }; 56 59 ··· 117 114 return IIO_VAL_INT; 118 115 case IIO_CHAN_INFO_SCALE: 119 116 *val = 0; 120 - *val2 = stk8ba50_scale_table[data->range][1]; 117 + *val2 = stk8ba50_scale_table[data->range].scale_val; 121 118 return IIO_VAL_INT_PLUS_MICRO; 122 119 } 123 120 ··· 139 136 return -EINVAL; 140 137 141 138 for (i = 0; i < ARRAY_SIZE(stk8ba50_scale_table); i++) 142 - if (val2 == stk8ba50_scale_table[i][1]) { 139 + if (val2 == stk8ba50_scale_table[i].scale_val) { 143 140 index = i; 144 141 break; 145 142 } ··· 148 145 149 146 ret = i2c_smbus_write_byte_data(data->client, 150 147 STK8BA50_REG_RANGE, 151 - stk8ba50_scale_table[index][0]); 148 + stk8ba50_scale_table[index].reg_val); 152 149 if (ret < 0) 153 150 dev_err(&data->client->dev, 154 151 "failed to set measurement range\n");