mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 04:23:35 +02:00
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>
This commit is contained in:
parent
df2a034aef
commit
4ea6e9b507
|
|
@ -867,10 +867,8 @@ static int sc27xx_adc_probe(struct platform_device *pdev)
|
|||
int ret;
|
||||
|
||||
pdata = of_device_get_match_data(dev);
|
||||
if (!pdata) {
|
||||
dev_err(dev, "No matching driver data found\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!pdata)
|
||||
return dev_err_probe(dev, -EINVAL, "No matching driver data found\n");
|
||||
|
||||
indio_dev = devm_iio_device_alloc(dev, sizeof(*sc27xx_data));
|
||||
if (!indio_dev)
|
||||
|
|
@ -879,56 +877,43 @@ static int sc27xx_adc_probe(struct platform_device *pdev)
|
|||
sc27xx_data = iio_priv(indio_dev);
|
||||
|
||||
sc27xx_data->regmap = dev_get_regmap(dev->parent, NULL);
|
||||
if (!sc27xx_data->regmap) {
|
||||
dev_err(dev, "failed to get ADC regmap\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
if (!sc27xx_data->regmap)
|
||||
return dev_err_probe(dev, -ENODEV, "failed to get ADC regmap\n");
|
||||
|
||||
ret = of_property_read_u32(np, "reg", &sc27xx_data->base);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to get ADC base address\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to get ADC base address\n");
|
||||
|
||||
sc27xx_data->irq = platform_get_irq(pdev, 0);
|
||||
if (sc27xx_data->irq < 0)
|
||||
return sc27xx_data->irq;
|
||||
|
||||
ret = of_hwspin_lock_get_id(np, 0);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to get hwspinlock id\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "failed to get hwspinlock id\n");
|
||||
|
||||
sc27xx_data->hwlock = devm_hwspin_lock_request_specific(dev, ret);
|
||||
if (!sc27xx_data->hwlock) {
|
||||
dev_err(dev, "failed to request hwspinlock\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
if (!sc27xx_data->hwlock)
|
||||
return dev_err_probe(dev, -ENXIO, "failed to request hwspinlock\n");
|
||||
|
||||
sc27xx_data->dev = dev;
|
||||
if (pdata->set_volref) {
|
||||
sc27xx_data->volref = devm_regulator_get(dev, "vref");
|
||||
if (IS_ERR(sc27xx_data->volref)) {
|
||||
ret = PTR_ERR(sc27xx_data->volref);
|
||||
return dev_err_probe(dev, ret, "failed to get ADC volref\n");
|
||||
}
|
||||
if (IS_ERR(sc27xx_data->volref))
|
||||
return dev_err_probe(dev, PTR_ERR(sc27xx_data->volref),
|
||||
"failed to get ADC volref\n");
|
||||
}
|
||||
|
||||
sc27xx_data->var_data = pdata;
|
||||
sc27xx_data->var_data->init_scale(sc27xx_data);
|
||||
|
||||
ret = sc27xx_adc_enable(sc27xx_data);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to enable ADC module\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to enable ADC module\n");
|
||||
|
||||
ret = devm_add_action_or_reset(dev, sc27xx_adc_disable, sc27xx_data);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to add ADC disable action\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to add ADC disable action\n");
|
||||
|
||||
indio_dev->name = dev_name(dev);
|
||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user