diff options
author | Grant Likely <grant.likely@linaro.org> | 2014-03-04 03:44:10 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2014-03-04 03:44:10 -0500 |
commit | dab2310d9d90eded48625c5382c6a60389bf8ca9 (patch) | |
tree | 9327cc815d69dec23aebf03407e3fa82b6d2fbaa /drivers/iio/magnetometer/ak8975.c | |
parent | a3dbeb5b45af5b6113385db89fce2a8279278e8b (diff) | |
parent | 0414855fdc4a40da05221fc6062cccbc0c30f169 (diff) |
Merge tag 'v3.14-rc5' into HEAD
Linux 3.14-rc5
Diffstat (limited to 'drivers/iio/magnetometer/ak8975.c')
-rw-r--r-- | drivers/iio/magnetometer/ak8975.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index ff284e5afd95..05423543f89d 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c | |||
@@ -85,6 +85,7 @@ | |||
85 | #define AK8975_MAX_CONVERSION_TIMEOUT 500 | 85 | #define AK8975_MAX_CONVERSION_TIMEOUT 500 |
86 | #define AK8975_CONVERSION_DONE_POLL_TIME 10 | 86 | #define AK8975_CONVERSION_DONE_POLL_TIME 10 |
87 | #define AK8975_DATA_READY_TIMEOUT ((100*HZ)/1000) | 87 | #define AK8975_DATA_READY_TIMEOUT ((100*HZ)/1000) |
88 | #define RAW_TO_GAUSS(asa) ((((asa) + 128) * 3000) / 256) | ||
88 | 89 | ||
89 | /* | 90 | /* |
90 | * Per-instance context data for the device. | 91 | * Per-instance context data for the device. |
@@ -265,15 +266,15 @@ static int ak8975_setup(struct i2c_client *client) | |||
265 | * | 266 | * |
266 | * Since 1uT = 0.01 gauss, our final scale factor becomes: | 267 | * Since 1uT = 0.01 gauss, our final scale factor becomes: |
267 | * | 268 | * |
268 | * Hadj = H * ((ASA + 128) / 256) * 3/10 * 100 | 269 | * Hadj = H * ((ASA + 128) / 256) * 3/10 * 1/100 |
269 | * Hadj = H * ((ASA + 128) * 30 / 256 | 270 | * Hadj = H * ((ASA + 128) * 0.003) / 256 |
270 | * | 271 | * |
271 | * Since ASA doesn't change, we cache the resultant scale factor into the | 272 | * Since ASA doesn't change, we cache the resultant scale factor into the |
272 | * device context in ak8975_setup(). | 273 | * device context in ak8975_setup(). |
273 | */ | 274 | */ |
274 | data->raw_to_gauss[0] = ((data->asa[0] + 128) * 30) >> 8; | 275 | data->raw_to_gauss[0] = RAW_TO_GAUSS(data->asa[0]); |
275 | data->raw_to_gauss[1] = ((data->asa[1] + 128) * 30) >> 8; | 276 | data->raw_to_gauss[1] = RAW_TO_GAUSS(data->asa[1]); |
276 | data->raw_to_gauss[2] = ((data->asa[2] + 128) * 30) >> 8; | 277 | data->raw_to_gauss[2] = RAW_TO_GAUSS(data->asa[2]); |
277 | 278 | ||
278 | return 0; | 279 | return 0; |
279 | } | 280 | } |
@@ -428,8 +429,9 @@ static int ak8975_read_raw(struct iio_dev *indio_dev, | |||
428 | case IIO_CHAN_INFO_RAW: | 429 | case IIO_CHAN_INFO_RAW: |
429 | return ak8975_read_axis(indio_dev, chan->address, val); | 430 | return ak8975_read_axis(indio_dev, chan->address, val); |
430 | case IIO_CHAN_INFO_SCALE: | 431 | case IIO_CHAN_INFO_SCALE: |
431 | *val = data->raw_to_gauss[chan->address]; | 432 | *val = 0; |
432 | return IIO_VAL_INT; | 433 | *val2 = data->raw_to_gauss[chan->address]; |
434 | return IIO_VAL_INT_PLUS_MICRO; | ||
433 | } | 435 | } |
434 | return -EINVAL; | 436 | return -EINVAL; |
435 | } | 437 | } |