diff options
author | Hartmut Knaack <knaack.h@gmx.de> | 2014-10-25 14:09:11 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-10-25 15:55:56 -0400 |
commit | 345b48307d6961183be77748fc0ae5dd660c91a8 (patch) | |
tree | 02e24480a1a2e8bd58395f212f3b76b9dff89d11 | |
parent | acd8256723f286b7217801fbed24503f8565b91e (diff) |
iio:humidity:si7020: cleanup read_raw and probe
When reading temperature or humidity values, a shift of two bits to the right
needs to be applied, and only for the humidity channel a mask of the lower
12 bits needs to be applied. This reduces code repetition.
During probe, i2c_set_clientdata() was used, although its counterpart was not,
so drop it.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/humidity/si7020.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c index e336af713f20..69e49f58a455 100644 --- a/drivers/iio/humidity/si7020.c +++ b/drivers/iio/humidity/si7020.c | |||
@@ -56,10 +56,9 @@ static int si7020_read_raw(struct iio_dev *indio_dev, | |||
56 | SI7020CMD_RH_HOLD); | 56 | SI7020CMD_RH_HOLD); |
57 | if (ret < 0) | 57 | if (ret < 0) |
58 | return ret; | 58 | return ret; |
59 | if (chan->type == IIO_TEMP) | 59 | *val = ret >> 2; |
60 | *val = ret >> 2; | 60 | if (chan->type == IIO_HUMIDITYRELATIVE) |
61 | else | 61 | *val &= GENMASK(11, 0); |
62 | *val = (ret & 0x3FFF) >> 2; | ||
63 | return IIO_VAL_INT; | 62 | return IIO_VAL_INT; |
64 | case IIO_CHAN_INFO_SCALE: | 63 | case IIO_CHAN_INFO_SCALE: |
65 | if (chan->type == IIO_TEMP) | 64 | if (chan->type == IIO_TEMP) |
@@ -133,7 +132,6 @@ static int si7020_probe(struct i2c_client *client, | |||
133 | 132 | ||
134 | data = iio_priv(indio_dev); | 133 | data = iio_priv(indio_dev); |
135 | *data = client; | 134 | *data = client; |
136 | i2c_set_clientdata(client, indio_dev); | ||
137 | 135 | ||
138 | indio_dev->dev.parent = &client->dev; | 136 | indio_dev->dev.parent = &client->dev; |
139 | indio_dev->name = dev_name(&client->dev); | 137 | indio_dev->name = dev_name(&client->dev); |