Commit 5e63d7a2 authored by Shreeya Patel's avatar Shreeya Patel Committed by Jonathan Cameron

iio: adc: rockchip_saradc: Use dev_err_probe

Use dev_err_probe instead of dev_err in probe function,
which simplifies code a little bit and prints the error
code.
Signed-off-by: default avatarShreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230603185340.13838-7-shreeya.patel@collabora.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 10bec68f
...@@ -425,25 +425,23 @@ static int rockchip_saradc_probe(struct platform_device *pdev) ...@@ -425,25 +425,23 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info)); indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
if (!indio_dev) { if (!indio_dev)
dev_err(&pdev->dev, "failed allocating iio device\n"); return dev_err_probe(&pdev->dev, -ENOMEM,
return -ENOMEM; "failed allocating iio device\n");
}
info = iio_priv(indio_dev); info = iio_priv(indio_dev);
match_data = of_device_get_match_data(&pdev->dev); match_data = of_device_get_match_data(&pdev->dev);
if (!match_data) { if (!match_data)
dev_err(&pdev->dev, "failed to match device\n"); return dev_err_probe(&pdev->dev, -ENODEV,
return -ENODEV; "failed to match device\n");
}
info->data = match_data; info->data = match_data;
/* Sanity check for possible later IP variants with more channels */ /* Sanity check for possible later IP variants with more channels */
if (info->data->num_channels > SARADC_MAX_CHANNELS) { if (info->data->num_channels > SARADC_MAX_CHANNELS)
dev_err(&pdev->dev, "max channels exceeded"); return dev_err_probe(&pdev->dev, -EINVAL,
return -EINVAL; "max channels exceeded");
}
info->regs = devm_platform_ioremap_resource(pdev, 0); info->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(info->regs)) if (IS_ERR(info->regs))
...@@ -491,23 +489,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev) ...@@ -491,23 +489,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
* This may become user-configurable in the future. * This may become user-configurable in the future.
*/ */
ret = clk_set_rate(info->clk, info->data->clk_rate); ret = clk_set_rate(info->clk, info->data->clk_rate);
if (ret < 0) { if (ret < 0)
dev_err(&pdev->dev, "failed to set adc clk rate, %d\n", ret); return dev_err_probe(&pdev->dev, ret,
return ret; "failed to set adc clk rate\n");
}
ret = regulator_enable(info->vref); ret = regulator_enable(info->vref);
if (ret < 0) { if (ret < 0)
dev_err(&pdev->dev, "failed to enable vref regulator\n"); return dev_err_probe(&pdev->dev, ret,
return ret; "failed to enable vref regulator\n");
}
ret = devm_add_action_or_reset(&pdev->dev, ret = devm_add_action_or_reset(&pdev->dev,
rockchip_saradc_regulator_disable, info); rockchip_saradc_regulator_disable, info);
if (ret) { if (ret)
dev_err(&pdev->dev, "failed to register devm action, %d\n", return dev_err_probe(&pdev->dev, ret,
ret); "failed to register devm action\n");
return ret;
}
ret = regulator_get_voltage(info->vref); ret = regulator_get_voltage(info->vref);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment