summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelo Compagnucci <angelo.compagnucci@gmail.com>2017-06-29 00:53:10 +0300
committerJonathan Cameron <jic23@kernel.org>2017-07-02 12:24:52 +0300
commit6be72b9067d443a44065541853edfb92ffca0401 (patch)
tree3106e588b9b390f3f7b48d0c2e94c3de14ae968c
parente3169994f6563f7e80a357ea68d5e9b040cb126c (diff)
downloadlinux-6be72b9067d443a44065541853edfb92ffca0401.tar.xz
iio: adc: mcp3422: Checking for error on probe
Some part of the configuration are not touched after the probe and if something goes wrong on writing the initial one, the chip will misbehave. Adding an error checking ensures that the inital configuration will be written correctly. Moreover ensures that a sensible configuration will be saved in driver data and used subsequently as intended. Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> Reported-by: Maarten Brock <m.brock@vanmierlo.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/adc/mcp3422.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c
index 6737df8d9bdd..63de705086ed 100644
--- a/drivers/iio/adc/mcp3422.c
+++ b/drivers/iio/adc/mcp3422.c
@@ -382,7 +382,9 @@ static int mcp3422_probe(struct i2c_client *client,
| MCP3422_CHANNEL_VALUE(0)
| MCP3422_PGA_VALUE(MCP3422_PGA_1)
| MCP3422_SAMPLE_RATE_VALUE(MCP3422_SRATE_240));
- mcp3422_update_config(adc, config);
+ err = mcp3422_update_config(adc, config);
+ if (err < 0)
+ return err;
err = devm_iio_device_register(&client->dev, indio_dev);
if (err < 0)