Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

David Lechner and committed by
Jonathan Cameron
95e17a54 bfe339ee

+13 -22
+13 -22
drivers/iio/adc/hx711.c
··· 464 464 int i; 465 465 466 466 indio_dev = devm_iio_device_alloc(dev, sizeof(struct hx711_data)); 467 - if (!indio_dev) { 468 - dev_err(dev, "failed to allocate IIO device\n"); 469 - return -ENOMEM; 470 - } 467 + if (!indio_dev) 468 + return dev_err_probe(dev, -ENOMEM, "failed to allocate IIO device\n"); 471 469 472 470 hx711_data = iio_priv(indio_dev); 473 471 hx711_data->dev = dev; ··· 477 479 * in the driver it is an output 478 480 */ 479 481 hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); 480 - if (IS_ERR(hx711_data->gpiod_pd_sck)) { 481 - dev_err(dev, "failed to get sck-gpiod: err=%ld\n", 482 - PTR_ERR(hx711_data->gpiod_pd_sck)); 483 - return PTR_ERR(hx711_data->gpiod_pd_sck); 484 - } 482 + if (IS_ERR(hx711_data->gpiod_pd_sck)) 483 + return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_pd_sck), 484 + "failed to get sck-gpiod\n"); 485 485 486 486 /* 487 487 * DOUT stands for serial data output of HX711 488 488 * for the driver it is an input 489 489 */ 490 490 hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN); 491 - if (IS_ERR(hx711_data->gpiod_dout)) { 492 - dev_err(dev, "failed to get dout-gpiod: err=%ld\n", 493 - PTR_ERR(hx711_data->gpiod_dout)); 494 - return PTR_ERR(hx711_data->gpiod_dout); 495 - } 491 + if (IS_ERR(hx711_data->gpiod_dout)) 492 + return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_dout), 493 + "failed to get dout-gpiod\n"); 496 494 497 495 ret = devm_regulator_get_enable_read_voltage(dev, "avdd"); 498 496 if (ret < 0) ··· 542 548 ret = devm_iio_triggered_buffer_setup(dev, indio_dev, 543 549 iio_pollfunc_store_time, 544 550 hx711_trigger, NULL); 545 - if (ret < 0) { 546 - dev_err(dev, "setup of iio triggered buffer failed\n"); 547 - return ret; 548 - } 551 + if (ret < 0) 552 + return dev_err_probe(dev, ret, 553 + "setup of iio triggered buffer failed\n"); 549 554 550 555 ret = devm_iio_device_register(dev, indio_dev); 551 - if (ret < 0) { 552 - dev_err(dev, "Couldn't register the device\n"); 553 - return ret; 554 - } 556 + if (ret < 0) 557 + return dev_err_probe(dev, ret, "Couldn't register the device\n"); 555 558 556 559 return 0; 557 560 }