Commit 71faca73 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

staging:iio:ad7606: Let the common probe function return int

The common probe function for the ad7606 currently returns a struct iio_dev
pointer. The returned value is not used by the individual driver probe
functions other than for error checking.

Let the common probe function return a int instead to report the error
value directly (or 0 on success). This allows to simplify the code.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 382a4777
...@@ -78,8 +78,7 @@ struct ad7606_bus_ops { ...@@ -78,8 +78,7 @@ struct ad7606_bus_ops {
int (*read_block)(struct device *, int, void *); int (*read_block)(struct device *, int, void *);
}; };
struct iio_dev *ad7606_probe(struct device *dev, int irq, int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
void __iomem *base_address,
const char *name, unsigned int id, const char *name, unsigned int id,
const struct ad7606_bus_ops *bops); const struct ad7606_bus_ops *bops);
int ad7606_remove(struct iio_dev *indio_dev, int irq); int ad7606_remove(struct iio_dev *indio_dev, int irq);
......
...@@ -443,8 +443,7 @@ static const struct iio_info ad7606_info_range = { ...@@ -443,8 +443,7 @@ static const struct iio_info ad7606_info_range = {
.attrs = &ad7606_attribute_group_range, .attrs = &ad7606_attribute_group_range,
}; };
struct iio_dev *ad7606_probe(struct device *dev, int irq, int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
void __iomem *base_address,
const char *name, unsigned int id, const char *name, unsigned int id,
const struct ad7606_bus_ops *bops) const struct ad7606_bus_ops *bops)
{ {
...@@ -455,7 +454,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, ...@@ -455,7 +454,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (!indio_dev) if (!indio_dev)
return ERR_PTR(-ENOMEM); return -ENOMEM;
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
...@@ -469,7 +468,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, ...@@ -469,7 +468,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
if (!IS_ERR(st->reg)) { if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg); ret = regulator_enable(st->reg);
if (ret) if (ret)
return ERR_PTR(ret); return ret;
} }
st->pdata = pdata; st->pdata = pdata;
...@@ -519,7 +518,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, ...@@ -519,7 +518,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
dev_set_drvdata(dev, indio_dev); dev_set_drvdata(dev, indio_dev);
return indio_dev; return 0;
error_unregister_ring: error_unregister_ring:
ad7606_ring_cleanup(indio_dev); ad7606_ring_cleanup(indio_dev);
...@@ -532,7 +531,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, ...@@ -532,7 +531,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
error_disable_reg: error_disable_reg:
if (!IS_ERR(st->reg)) if (!IS_ERR(st->reg))
regulator_disable(st->reg); regulator_disable(st->reg);
return ERR_PTR(ret); return ret;
} }
EXPORT_SYMBOL_GPL(ad7606_probe); EXPORT_SYMBOL_GPL(ad7606_probe);
......
...@@ -51,7 +51,6 @@ static int ad7606_par_probe(struct platform_device *pdev) ...@@ -51,7 +51,6 @@ static int ad7606_par_probe(struct platform_device *pdev)
{ {
const struct platform_device_id *id = platform_get_device_id(pdev); const struct platform_device_id *id = platform_get_device_id(pdev);
struct resource *res; struct resource *res;
struct iio_dev *indio_dev;
void __iomem *addr; void __iomem *addr;
resource_size_t remap_size; resource_size_t remap_size;
int irq; int irq;
...@@ -69,15 +68,10 @@ static int ad7606_par_probe(struct platform_device *pdev) ...@@ -69,15 +68,10 @@ static int ad7606_par_probe(struct platform_device *pdev)
remap_size = resource_size(res); remap_size = resource_size(res);
indio_dev = ad7606_probe(&pdev->dev, irq, addr, return ad7606_probe(&pdev->dev, irq, addr,
id->name, id->driver_data, id->name, id->driver_data,
remap_size > 1 ? &ad7606_par16_bops : remap_size > 1 ? &ad7606_par16_bops :
&ad7606_par8_bops); &ad7606_par8_bops);
if (IS_ERR(indio_dev))
return PTR_ERR(indio_dev);
return 0;
} }
static int ad7606_par_remove(struct platform_device *pdev) static int ad7606_par_remove(struct platform_device *pdev)
......
...@@ -43,16 +43,10 @@ static const struct ad7606_bus_ops ad7606_spi_bops = { ...@@ -43,16 +43,10 @@ static const struct ad7606_bus_ops ad7606_spi_bops = {
static int ad7606_spi_probe(struct spi_device *spi) static int ad7606_spi_probe(struct spi_device *spi)
{ {
const struct spi_device_id *id = spi_get_device_id(spi); const struct spi_device_id *id = spi_get_device_id(spi);
struct iio_dev *indio_dev;
indio_dev = ad7606_probe(&spi->dev, spi->irq, NULL, return ad7606_probe(&spi->dev, spi->irq, NULL,
id->name, id->driver_data, id->name, id->driver_data,
&ad7606_spi_bops); &ad7606_spi_bops);
if (IS_ERR(indio_dev))
return PTR_ERR(indio_dev);
return 0;
} }
static int ad7606_spi_remove(struct spi_device *spi) static int ad7606_spi_remove(struct spi_device *spi)
......
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