iio: adc: hx711: use dev_err_probe()
Use dev_err_probe() to simplify error returns in the probe function. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Andreas Klinger <ak@it-klinger.de> Link: https://patch.msgid.link/20240621-iio-regulator-refactor-round-2-v1-4-49e50cd0b99a@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
bfe339ee8e
commit
95e17a54e4
@@ -464,10 +464,8 @@ static int hx711_probe(struct platform_device *pdev)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
indio_dev = devm_iio_device_alloc(dev, sizeof(struct hx711_data));
|
indio_dev = devm_iio_device_alloc(dev, sizeof(struct hx711_data));
|
||||||
if (!indio_dev) {
|
if (!indio_dev)
|
||||||
dev_err(dev, "failed to allocate IIO device\n");
|
return dev_err_probe(dev, -ENOMEM, "failed to allocate IIO device\n");
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
hx711_data = iio_priv(indio_dev);
|
hx711_data = iio_priv(indio_dev);
|
||||||
hx711_data->dev = dev;
|
hx711_data->dev = dev;
|
||||||
@@ -479,22 +477,18 @@ static int hx711_probe(struct platform_device *pdev)
|
|||||||
* in the driver it is an output
|
* in the driver it is an output
|
||||||
*/
|
*/
|
||||||
hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW);
|
hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW);
|
||||||
if (IS_ERR(hx711_data->gpiod_pd_sck)) {
|
if (IS_ERR(hx711_data->gpiod_pd_sck))
|
||||||
dev_err(dev, "failed to get sck-gpiod: err=%ld\n",
|
return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_pd_sck),
|
||||||
PTR_ERR(hx711_data->gpiod_pd_sck));
|
"failed to get sck-gpiod\n");
|
||||||
return PTR_ERR(hx711_data->gpiod_pd_sck);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DOUT stands for serial data output of HX711
|
* DOUT stands for serial data output of HX711
|
||||||
* for the driver it is an input
|
* for the driver it is an input
|
||||||
*/
|
*/
|
||||||
hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN);
|
hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN);
|
||||||
if (IS_ERR(hx711_data->gpiod_dout)) {
|
if (IS_ERR(hx711_data->gpiod_dout))
|
||||||
dev_err(dev, "failed to get dout-gpiod: err=%ld\n",
|
return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_dout),
|
||||||
PTR_ERR(hx711_data->gpiod_dout));
|
"failed to get dout-gpiod\n");
|
||||||
return PTR_ERR(hx711_data->gpiod_dout);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = devm_regulator_get_enable_read_voltage(dev, "avdd");
|
ret = devm_regulator_get_enable_read_voltage(dev, "avdd");
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -548,16 +542,13 @@ static int hx711_probe(struct platform_device *pdev)
|
|||||||
ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
|
ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
|
||||||
iio_pollfunc_store_time,
|
iio_pollfunc_store_time,
|
||||||
hx711_trigger, NULL);
|
hx711_trigger, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
dev_err(dev, "setup of iio triggered buffer failed\n");
|
return dev_err_probe(dev, ret,
|
||||||
return ret;
|
"setup of iio triggered buffer failed\n");
|
||||||
}
|
|
||||||
|
|
||||||
ret = devm_iio_device_register(dev, indio_dev);
|
ret = devm_iio_device_register(dev, indio_dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
dev_err(dev, "Couldn't register the device\n");
|
return dev_err_probe(dev, ret, "Couldn't register the device\n");
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user