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 devm_regulator_get_enable_read_voltage()

Use the devm_regulator_get_enable_read_voltage() helper to simplify the
code.

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-2-49e50cd0b99a@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
0099e82b 9a36aa0f

+2 -18
+2 -18
drivers/iio/adc/hx711.c
··· 80 80 struct device *dev; 81 81 struct gpio_desc *gpiod_pd_sck; 82 82 struct gpio_desc *gpiod_dout; 83 - struct regulator *reg_avdd; 84 83 int gain_set; /* gain set on device */ 85 84 int gain_chan_a; /* gain for channel A */ 86 85 struct mutex lock; ··· 496 497 return PTR_ERR(hx711_data->gpiod_dout); 497 498 } 498 499 499 - hx711_data->reg_avdd = devm_regulator_get(dev, "avdd"); 500 - if (IS_ERR(hx711_data->reg_avdd)) 501 - return PTR_ERR(hx711_data->reg_avdd); 502 - 503 - ret = regulator_enable(hx711_data->reg_avdd); 500 + ret = devm_regulator_get_enable_read_voltage(dev, "avdd"); 504 501 if (ret < 0) 505 502 return ret; 506 503 ··· 512 517 * approximately to fit into a 32 bit number: 513 518 * 1 LSB = (AVDD * 100) / GAIN / 1678 [10^-9 mV] 514 519 */ 515 - ret = regulator_get_voltage(hx711_data->reg_avdd); 516 - if (ret < 0) 517 - goto error_regulator; 518 520 519 521 /* we need 10^-9 mV */ 520 522 ret *= 100; ··· 551 559 hx711_trigger, NULL); 552 560 if (ret < 0) { 553 561 dev_err(dev, "setup of iio triggered buffer failed\n"); 554 - goto error_regulator; 562 + return ret; 555 563 } 556 564 557 565 ret = iio_device_register(indio_dev); ··· 565 573 error_buffer: 566 574 iio_triggered_buffer_cleanup(indio_dev); 567 575 568 - error_regulator: 569 - regulator_disable(hx711_data->reg_avdd); 570 - 571 576 return ret; 572 577 } 573 578 574 579 static void hx711_remove(struct platform_device *pdev) 575 580 { 576 - struct hx711_data *hx711_data; 577 581 struct iio_dev *indio_dev; 578 582 579 583 indio_dev = platform_get_drvdata(pdev); 580 - hx711_data = iio_priv(indio_dev); 581 584 582 585 iio_device_unregister(indio_dev); 583 - 584 586 iio_triggered_buffer_cleanup(indio_dev); 585 - 586 - regulator_disable(hx711_data->reg_avdd); 587 587 } 588 588 589 589 static const struct of_device_id of_hx711_match[] = {