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

iio: temperature: ltc2983: Use single error path to put OF node

There are several, possibly copied'n'pasted, places in the functions,
where OF node is put and error returned directly, while the common
exit point exists. Unify all these cases to use a single error path.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220307203606.87258-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Andy Shevchenko and committed by
Jonathan Cameron
e59b18a2 8868a172

+11 -10
+11 -10
drivers/iio/temperature/ltc2983.c
··· 653 653 654 654 phandle = of_parse_phandle(child, "adi,cold-junction-handle", 0); 655 655 if (phandle) { 656 - int ret; 657 - 658 656 ret = of_property_read_u32(phandle, "reg", 659 657 &thermo->cold_junction_chan); 660 658 if (ret) { ··· 661 663 * the error right away. 662 664 */ 663 665 dev_err(&st->spi->dev, "Property reg must be given\n"); 664 - of_node_put(phandle); 665 - return ERR_PTR(-EINVAL); 666 + goto fail; 666 667 } 667 668 } 668 669 ··· 673 676 propname, false, 674 677 16384, true); 675 678 if (IS_ERR(thermo->custom)) { 676 - of_node_put(phandle); 677 - return ERR_CAST(thermo->custom); 679 + ret = PTR_ERR(thermo->custom); 680 + goto fail; 678 681 } 679 682 } 680 683 ··· 684 687 685 688 of_node_put(phandle); 686 689 return &thermo->sensor; 690 + 691 + fail: 692 + of_node_put(phandle); 693 + return ERR_PTR(ret); 687 694 } 688 695 689 696 static struct ltc2983_sensor *ltc2983_rtd_new(const struct device_node *child, ··· 804 803 "adi,custom-rtd", 805 804 false, 2048, false); 806 805 if (IS_ERR(rtd->custom)) { 807 - of_node_put(phandle); 808 - return ERR_CAST(rtd->custom); 806 + ret = PTR_ERR(rtd->custom); 807 + goto fail; 809 808 } 810 809 } 811 810 ··· 927 926 steinhart, 928 927 64, false); 929 928 if (IS_ERR(thermistor->custom)) { 930 - of_node_put(phandle); 931 - return ERR_CAST(thermistor->custom); 929 + ret = PTR_ERR(thermistor->custom); 930 + goto fail; 932 931 } 933 932 } 934 933 /* set common parameters */