@@ -85,15 +85,15 @@ static int ms5611_read_prom(struct iio_dev *indio_dev)
85
85
struct ms5611_state * st = iio_priv (indio_dev );
86
86
87
87
for (i = 0 ; i < MS5611_PROM_WORDS_NB ; i ++ ) {
88
- ret = st -> read_prom_word (st , i , & st -> chip_info -> prom [i ]);
88
+ ret = st -> read_prom_word (st , i , & st -> prom [i ]);
89
89
if (ret < 0 ) {
90
90
dev_err (& indio_dev -> dev ,
91
91
"failed to read prom at %d\n" , i );
92
92
return ret ;
93
93
}
94
94
}
95
95
96
- if (!ms5611_prom_is_valid (st -> chip_info -> prom , MS5611_PROM_WORDS_NB )) {
96
+ if (!ms5611_prom_is_valid (st -> prom , MS5611_PROM_WORDS_NB )) {
97
97
dev_err (& indio_dev -> dev , "PROM integrity check failed\n" );
98
98
return - ENODEV ;
99
99
}
@@ -114,21 +114,20 @@ static int ms5611_read_temp_and_pressure(struct iio_dev *indio_dev,
114
114
return ret ;
115
115
}
116
116
117
- return st -> chip_info -> temp_and_pressure_compensate (st -> chip_info ,
118
- temp , pressure );
117
+ return st -> compensate_temp_and_pressure (st , temp , pressure );
119
118
}
120
119
121
- static int ms5611_temp_and_pressure_compensate (struct ms5611_chip_info * chip_info ,
120
+ static int ms5611_temp_and_pressure_compensate (struct ms5611_state * st ,
122
121
s32 * temp , s32 * pressure )
123
122
{
124
123
s32 t = * temp , p = * pressure ;
125
124
s64 off , sens , dt ;
126
125
127
- dt = t - (chip_info -> prom [5 ] << 8 );
128
- off = ((s64 )chip_info -> prom [2 ] << 16 ) + ((chip_info -> prom [4 ] * dt ) >> 7 );
129
- sens = ((s64 )chip_info -> prom [1 ] << 15 ) + ((chip_info -> prom [3 ] * dt ) >> 8 );
126
+ dt = t - (st -> prom [5 ] << 8 );
127
+ off = ((s64 )st -> prom [2 ] << 16 ) + ((st -> prom [4 ] * dt ) >> 7 );
128
+ sens = ((s64 )st -> prom [1 ] << 15 ) + ((st -> prom [3 ] * dt ) >> 8 );
130
129
131
- t = 2000 + ((chip_info -> prom [6 ] * dt ) >> 23 );
130
+ t = 2000 + ((st -> prom [6 ] * dt ) >> 23 );
132
131
if (t < 2000 ) {
133
132
s64 off2 , sens2 , t2 ;
134
133
@@ -154,17 +153,17 @@ static int ms5611_temp_and_pressure_compensate(struct ms5611_chip_info *chip_inf
154
153
return 0 ;
155
154
}
156
155
157
- static int ms5607_temp_and_pressure_compensate (struct ms5611_chip_info * chip_info ,
156
+ static int ms5607_temp_and_pressure_compensate (struct ms5611_state * st ,
158
157
s32 * temp , s32 * pressure )
159
158
{
160
159
s32 t = * temp , p = * pressure ;
161
160
s64 off , sens , dt ;
162
161
163
- dt = t - (chip_info -> prom [5 ] << 8 );
164
- off = ((s64 )chip_info -> prom [2 ] << 17 ) + ((chip_info -> prom [4 ] * dt ) >> 6 );
165
- sens = ((s64 )chip_info -> prom [1 ] << 16 ) + ((chip_info -> prom [3 ] * dt ) >> 7 );
162
+ dt = t - (st -> prom [5 ] << 8 );
163
+ off = ((s64 )st -> prom [2 ] << 17 ) + ((st -> prom [4 ] * dt ) >> 6 );
164
+ sens = ((s64 )st -> prom [1 ] << 16 ) + ((st -> prom [3 ] * dt ) >> 7 );
166
165
167
- t = 2000 + ((chip_info -> prom [6 ] * dt ) >> 23 );
166
+ t = 2000 + ((st -> prom [6 ] * dt ) >> 23 );
168
167
if (t < 2000 ) {
169
168
s64 off2 , sens2 , t2 , tmp ;
170
169
@@ -342,15 +341,6 @@ static int ms5611_write_raw(struct iio_dev *indio_dev,
342
341
343
342
static const unsigned long ms5611_scan_masks [] = {0x3 , 0 };
344
343
345
- static struct ms5611_chip_info chip_info_tbl [] = {
346
- [MS5611 ] = {
347
- .temp_and_pressure_compensate = ms5611_temp_and_pressure_compensate ,
348
- },
349
- [MS5607 ] = {
350
- .temp_and_pressure_compensate = ms5607_temp_and_pressure_compensate ,
351
- }
352
- };
353
-
354
344
static const struct iio_chan_spec ms5611_channels [] = {
355
345
{
356
346
.type = IIO_PRESSURE ,
@@ -433,7 +423,20 @@ int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
433
423
struct ms5611_state * st = iio_priv (indio_dev );
434
424
435
425
mutex_init (& st -> lock );
436
- st -> chip_info = & chip_info_tbl [type ];
426
+
427
+ switch (type ) {
428
+ case MS5611 :
429
+ st -> compensate_temp_and_pressure =
430
+ ms5611_temp_and_pressure_compensate ;
431
+ break ;
432
+ case MS5607 :
433
+ st -> compensate_temp_and_pressure =
434
+ ms5607_temp_and_pressure_compensate ;
435
+ break ;
436
+ default :
437
+ return - EINVAL ;
438
+ }
439
+
437
440
st -> temp_osr =
438
441
& ms5611_avail_temp_osr [ARRAY_SIZE (ms5611_avail_temp_osr ) - 1 ];
439
442
st -> pressure_osr =
0 commit comments