diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2015-08-18 05:16:33 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-08-31 11:29:52 -0400 |
commit | 7d87b3c5c8602df4ce6d615b33ae6dc15438fa29 (patch) | |
tree | bef0bea1b20eaf2bb7818db6f0ec3443bb4b409f | |
parent | aff268cd532e99ced3c8f48d01118912eb002bbf (diff) |
iio: tsl4531: fix error handling in tsl4531_check_id()
The tsl4531_check_id() function returned 1 on "found" and 0 on "not
found" and negative error codes on failure. This was non-standard and
bug prone. The caller treated all non-zero values including error codes
as "found".
This patch fixes it by changing the tsl4531_check_id() to return zero on
success or a negative error code, and updates the caller.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/light/tsl4531.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c index 26979183d27c..cf94ec72b181 100644 --- a/drivers/iio/light/tsl4531.c +++ b/drivers/iio/light/tsl4531.c | |||
@@ -158,9 +158,9 @@ static int tsl4531_check_id(struct i2c_client *client) | |||
158 | case TSL45313_ID: | 158 | case TSL45313_ID: |
159 | case TSL45315_ID: | 159 | case TSL45315_ID: |
160 | case TSL45317_ID: | 160 | case TSL45317_ID: |
161 | return 1; | ||
162 | default: | ||
163 | return 0; | 161 | return 0; |
162 | default: | ||
163 | return -ENODEV; | ||
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
@@ -180,9 +180,10 @@ static int tsl4531_probe(struct i2c_client *client, | |||
180 | data->client = client; | 180 | data->client = client; |
181 | mutex_init(&data->lock); | 181 | mutex_init(&data->lock); |
182 | 182 | ||
183 | if (!tsl4531_check_id(client)) { | 183 | ret = tsl4531_check_id(client); |
184 | if (ret) { | ||
184 | dev_err(&client->dev, "no TSL4531 sensor\n"); | 185 | dev_err(&client->dev, "no TSL4531 sensor\n"); |
185 | return -ENODEV; | 186 | return ret; |
186 | } | 187 | } |
187 | 188 | ||
188 | ret = i2c_smbus_write_byte_data(data->client, TSL4531_CONTROL, | 189 | ret = i2c_smbus_write_byte_data(data->client, TSL4531_CONTROL, |