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: sc27xx: Simplify with dev_err_probe

Use dev_err_probe() to make error code handling simpler and handle
deferred probe nicely (avoid spamming logs).

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Krzysztof Kozlowski and committed by
Jonathan Cameron
4ea6e9b5 df2a034a

+17 -32
+17 -32
drivers/iio/adc/sc27xx_adc.c
··· 867 867 int ret; 868 868 869 869 pdata = of_device_get_match_data(dev); 870 - if (!pdata) { 871 - dev_err(dev, "No matching driver data found\n"); 872 - return -EINVAL; 873 - } 870 + if (!pdata) 871 + return dev_err_probe(dev, -EINVAL, "No matching driver data found\n"); 874 872 875 873 indio_dev = devm_iio_device_alloc(dev, sizeof(*sc27xx_data)); 876 874 if (!indio_dev) ··· 877 879 sc27xx_data = iio_priv(indio_dev); 878 880 879 881 sc27xx_data->regmap = dev_get_regmap(dev->parent, NULL); 880 - if (!sc27xx_data->regmap) { 881 - dev_err(dev, "failed to get ADC regmap\n"); 882 - return -ENODEV; 883 - } 882 + if (!sc27xx_data->regmap) 883 + return dev_err_probe(dev, -ENODEV, "failed to get ADC regmap\n"); 884 884 885 885 ret = of_property_read_u32(np, "reg", &sc27xx_data->base); 886 - if (ret) { 887 - dev_err(dev, "failed to get ADC base address\n"); 888 - return ret; 889 - } 886 + if (ret) 887 + return dev_err_probe(dev, ret, "failed to get ADC base address\n"); 890 888 891 889 sc27xx_data->irq = platform_get_irq(pdev, 0); 892 890 if (sc27xx_data->irq < 0) 893 891 return sc27xx_data->irq; 894 892 895 893 ret = of_hwspin_lock_get_id(np, 0); 896 - if (ret < 0) { 897 - dev_err(dev, "failed to get hwspinlock id\n"); 898 - return ret; 899 - } 894 + if (ret < 0) 895 + return dev_err_probe(dev, ret, "failed to get hwspinlock id\n"); 900 896 901 897 sc27xx_data->hwlock = devm_hwspin_lock_request_specific(dev, ret); 902 - if (!sc27xx_data->hwlock) { 903 - dev_err(dev, "failed to request hwspinlock\n"); 904 - return -ENXIO; 905 - } 898 + if (!sc27xx_data->hwlock) 899 + return dev_err_probe(dev, -ENXIO, "failed to request hwspinlock\n"); 906 900 907 901 sc27xx_data->dev = dev; 908 902 if (pdata->set_volref) { 909 903 sc27xx_data->volref = devm_regulator_get(dev, "vref"); 910 - if (IS_ERR(sc27xx_data->volref)) { 911 - ret = PTR_ERR(sc27xx_data->volref); 912 - return dev_err_probe(dev, ret, "failed to get ADC volref\n"); 913 - } 904 + if (IS_ERR(sc27xx_data->volref)) 905 + return dev_err_probe(dev, PTR_ERR(sc27xx_data->volref), 906 + "failed to get ADC volref\n"); 914 907 } 915 908 916 909 sc27xx_data->var_data = pdata; 917 910 sc27xx_data->var_data->init_scale(sc27xx_data); 918 911 919 912 ret = sc27xx_adc_enable(sc27xx_data); 920 - if (ret) { 921 - dev_err(dev, "failed to enable ADC module\n"); 922 - return ret; 923 - } 913 + if (ret) 914 + return dev_err_probe(dev, ret, "failed to enable ADC module\n"); 924 915 925 916 ret = devm_add_action_or_reset(dev, sc27xx_adc_disable, sc27xx_data); 926 - if (ret) { 927 - dev_err(dev, "failed to add ADC disable action\n"); 928 - return ret; 929 - } 917 + if (ret) 918 + return dev_err_probe(dev, ret, "failed to add ADC disable action\n"); 930 919 931 920 indio_dev->name = dev_name(dev); 932 921 indio_dev->modes = INDIO_DIRECT_MODE;