iio: adc: cc10001: Add local struct device *dev variable to avoid repitition

There are lots of uses of this in probe() and we are about to introduce
some more, so add a local variable to simplify this.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20221016170950.387751-2-jic23@kernel.org
This commit is contained in:
Jonathan Cameron 2022-10-16 18:09:46 +01:00
parent 0a33755c4b
commit 26bfb58193

View file

@ -307,14 +307,15 @@ static int cc10001_adc_channel_init(struct iio_dev *indio_dev,
static int cc10001_adc_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct cc10001_adc_device *adc_dev;
unsigned long adc_clk_rate;
struct iio_dev *indio_dev;
unsigned long channel_map;
int ret;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev));
indio_dev = devm_iio_device_alloc(dev, sizeof(*adc_dev));
if (indio_dev == NULL)
return -ENOMEM;
@ -326,7 +327,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
channel_map &= ~ret;
}
adc_dev->reg = devm_regulator_get(&pdev->dev, "vref");
adc_dev->reg = devm_regulator_get(dev, "vref");
if (IS_ERR(adc_dev->reg))
return PTR_ERR(adc_dev->reg);
@ -334,7 +335,7 @@ static int cc10001_adc_probe(struct platform_device *pdev)
if (ret)
return ret;
indio_dev->name = dev_name(&pdev->dev);
indio_dev->name = dev_name(dev);
indio_dev->info = &cc10001_adc_info;
indio_dev->modes = INDIO_DIRECT_MODE;
@ -344,23 +345,23 @@ static int cc10001_adc_probe(struct platform_device *pdev)
goto err_disable_reg;
}
adc_dev->adc_clk = devm_clk_get(&pdev->dev, "adc");
adc_dev->adc_clk = devm_clk_get(dev, "adc");
if (IS_ERR(adc_dev->adc_clk)) {
dev_err(&pdev->dev, "failed to get the clock\n");
dev_err(dev, "failed to get the clock\n");
ret = PTR_ERR(adc_dev->adc_clk);
goto err_disable_reg;
}
ret = clk_prepare_enable(adc_dev->adc_clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable the clock\n");
dev_err(dev, "failed to enable the clock\n");
goto err_disable_reg;
}
adc_clk_rate = clk_get_rate(adc_dev->adc_clk);
if (!adc_clk_rate) {
ret = -EINVAL;
dev_err(&pdev->dev, "null clock rate!\n");
dev_err(dev, "null clock rate!\n");
goto err_disable_clk;
}