Skip to content

Commit 0c4ffbf

Browse files
Sandhya-Bankargregkh
authored andcommitted
iio:chemical:atlas-ph-sensor: Fix use of 32 bit int to hold 16 bit big endian value
commit d1fe85e upstream. This will result in a random value being reported on big endian architectures. (thanks to Lars-Peter Clausen for pointing out the effects of this bug) Only effects a value printed to the log, but as this reports the settings of the probe in question it may be of direct interest to users. Also, fixes the following sparse endianness warnings: drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 drivers/iio/chemical/atlas-ph-sensor.c:215:9: warning: cast to restricted __be16 Signed-off-by: Sandhya Bankar <[email protected]> Fixes: e8dd92b ("iio: chemical: atlas-ph-sensor: add EC feature") Signed-off-by: Jonathan Cameron <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 52a1e76 commit 0c4ffbf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/iio/chemical/atlas-ph-sensor.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,14 @@ static int atlas_check_ec_calibration(struct atlas_data *data)
207207
struct device *dev = &data->client->dev;
208208
int ret;
209209
unsigned int val;
210+
__be16 rval;
210211

211-
ret = regmap_bulk_read(data->regmap, ATLAS_REG_EC_PROBE, &val, 2);
212+
ret = regmap_bulk_read(data->regmap, ATLAS_REG_EC_PROBE, &rval, 2);
212213
if (ret)
213214
return ret;
214215

215-
dev_info(dev, "probe set to K = %d.%.2d", be16_to_cpu(val) / 100,
216-
be16_to_cpu(val) % 100);
216+
val = be16_to_cpu(rval);
217+
dev_info(dev, "probe set to K = %d.%.2d", val / 100, val % 100);
217218

218219
ret = regmap_read(data->regmap, ATLAS_REG_EC_CALIB_STATUS, &val);
219220
if (ret)

0 commit comments

Comments
 (0)