@@ -302,7 +302,8 @@ static int dht11_probe(struct platform_device *pdev)
dht11->dev = dev;
dht11->gpiod = devm_gpiod_get(dev, NULL, GPIOD_IN);
if (IS_ERR(dht11->gpiod))
- return PTR_ERR(dht11->gpiod);
+ return dev_err_probe(dev, PTR_ERR(dht11->gpiod),
+ "Failed to aquire GPIO\n");
dht11->irq = gpiod_to_irq(dht11->gpiod);
if (dht11->irq < 0) {
@@ -323,7 +324,11 @@ static int dht11_probe(struct platform_device *pdev)
iio->channels = dht11_chan_spec;
iio->num_channels = ARRAY_SIZE(dht11_chan_spec);
- return devm_iio_device_register(dev, iio);
+ ret = devm_iio_device_register(dev, iio);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "Failed to register iio device\n");
+
+ return 0;
}
static struct platform_driver dht11_driver = {
There are two exit points in the driver's probe function that fail silently. From a user perspective this is unsatisfactory because the device is unusable but there is no hint in the kernel log about the actual problem which makes it unnecessarily hard to fix the problem. Make use of dev_err_probe() to emit a problem indication which also does the right thing if requesting the gpio return -EPROBE_DEFER. Signed-off-by: Uwe Kleine-König <ukleinek@debian.org> --- drivers/iio/humidity/dht11.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)