From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 09/13] staging:iio:ad7606: Let the common probe function return int
Date: Wed, 19 Oct 2016 19:07:04 +0200 [thread overview]
Message-ID: <1476896828-10544-10-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1476896828-10544-1-git-send-email-lars@metafoo.de>
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: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad7606.h | 7 +++----
drivers/staging/iio/adc/ad7606_core.c | 15 +++++++--------
drivers/staging/iio/adc/ad7606_par.c | 14 ++++----------
drivers/staging/iio/adc/ad7606_spi.c | 12 +++---------
4 files changed, 17 insertions(+), 31 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7606.h b/drivers/staging/iio/adc/ad7606.h
index 2257bdb..b4b25a2 100644
--- a/drivers/staging/iio/adc/ad7606.h
+++ b/drivers/staging/iio/adc/ad7606.h
@@ -78,10 +78,9 @@ struct ad7606_bus_ops {
int (*read_block)(struct device *, int, void *);
};
-struct iio_dev *ad7606_probe(struct device *dev, int irq,
- void __iomem *base_address,
- const char *name, unsigned int id,
- const struct ad7606_bus_ops *bops);
+int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
+ const char *name, unsigned int id,
+ const struct ad7606_bus_ops *bops);
int ad7606_remove(struct iio_dev *indio_dev, int irq);
int ad7606_reset(struct ad7606_state *st);
int ad7606_read_samples(struct ad7606_state *st);
diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index 13d8090..1ee7a29 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -443,10 +443,9 @@ static const struct iio_info ad7606_info_range = {
.attrs = &ad7606_attribute_group_range,
};
-struct iio_dev *ad7606_probe(struct device *dev, int irq,
- void __iomem *base_address,
- const char *name, unsigned int id,
- const struct ad7606_bus_ops *bops)
+int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
+ const char *name, unsigned int id,
+ const struct ad7606_bus_ops *bops)
{
struct ad7606_platform_data *pdata = dev->platform_data;
struct ad7606_state *st;
@@ -455,7 +454,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
if (!indio_dev)
- return ERR_PTR(-ENOMEM);
+ return -ENOMEM;
st = iio_priv(indio_dev);
@@ -469,7 +468,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
if (!IS_ERR(st->reg)) {
ret = regulator_enable(st->reg);
if (ret)
- return ERR_PTR(ret);
+ return ret;
}
st->pdata = pdata;
@@ -519,7 +518,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
dev_set_drvdata(dev, indio_dev);
- return indio_dev;
+ return 0;
error_unregister_ring:
ad7606_ring_cleanup(indio_dev);
@@ -532,7 +531,7 @@ error_free_gpios:
error_disable_reg:
if (!IS_ERR(st->reg))
regulator_disable(st->reg);
- return ERR_PTR(ret);
+ return ret;
}
EXPORT_SYMBOL_GPL(ad7606_probe);
diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c
index c273993..42eb9e0 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -51,7 +51,6 @@ static int ad7606_par_probe(struct platform_device *pdev)
{
const struct platform_device_id *id = platform_get_device_id(pdev);
struct resource *res;
- struct iio_dev *indio_dev;
void __iomem *addr;
resource_size_t remap_size;
int irq;
@@ -69,15 +68,10 @@ static int ad7606_par_probe(struct platform_device *pdev)
remap_size = resource_size(res);
- indio_dev = ad7606_probe(&pdev->dev, irq, addr,
- id->name, id->driver_data,
- remap_size > 1 ? &ad7606_par16_bops :
- &ad7606_par8_bops);
-
- if (IS_ERR(indio_dev))
- return PTR_ERR(indio_dev);
-
- return 0;
+ return ad7606_probe(&pdev->dev, irq, addr,
+ id->name, id->driver_data,
+ remap_size > 1 ? &ad7606_par16_bops :
+ &ad7606_par8_bops);
}
static int ad7606_par_remove(struct platform_device *pdev)
diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c
index 9abbc15..064c4c2 100644
--- a/drivers/staging/iio/adc/ad7606_spi.c
+++ b/drivers/staging/iio/adc/ad7606_spi.c
@@ -43,16 +43,10 @@ static const struct ad7606_bus_ops ad7606_spi_bops = {
static int ad7606_spi_probe(struct spi_device *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,
- id->name, id->driver_data,
- &ad7606_spi_bops);
-
- if (IS_ERR(indio_dev))
- return PTR_ERR(indio_dev);
-
- return 0;
+ return ad7606_probe(&spi->dev, spi->irq, NULL,
+ id->name, id->driver_data,
+ &ad7606_spi_bops);
}
static int ad7606_spi_remove(struct spi_device *spi)
--
2.1.4
next prev parent reply other threads:[~2016-10-19 17:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 17:06 [PATCH 00/13] staging:iio:ad7606: Towards moving out of staging Lars-Peter Clausen
2016-10-19 17:06 ` [PATCH 01/13] staging:iio:ad7606: Remove unused int_vref_mv field Lars-Peter Clausen
2016-10-22 15:22 ` Jonathan Cameron
2016-10-19 17:06 ` [PATCH 02/13] staging:iio:ad7606: Remove redundant name field from ad7606_chip_info Lars-Peter Clausen
2016-10-22 15:23 ` Jonathan Cameron
2016-10-19 17:06 ` [PATCH 03/13] staging:iio:ad7606: Remove default device configuration from platform data Lars-Peter Clausen
2016-10-22 15:24 ` Jonathan Cameron
2016-10-19 17:06 ` [PATCH 04/13] staging:iio:ad7606: Remove out-of-band error reporting Lars-Peter Clausen
2016-10-22 15:27 ` Jonathan Cameron
2016-10-19 17:07 ` [PATCH 05/13] staging:iio:ad7606: Use oversampling ratio of 1 for no oversampling Lars-Peter Clausen
2016-10-22 15:28 ` Jonathan Cameron
2016-10-19 17:07 ` [PATCH 06/13] staging:iio:ad7606: Avoid allocating buffer for each data capture Lars-Peter Clausen
2016-10-22 15:28 ` Jonathan Cameron
2016-10-19 17:07 ` [PATCH 07/13] staging:iio:ad7606: Factor out common code between periodic and one-shot capture Lars-Peter Clausen
2016-10-22 17:01 ` Jonathan Cameron
2016-10-22 17:02 ` Jonathan Cameron
2016-10-22 17:20 ` Lars-Peter Clausen
2016-10-22 17:33 ` Jonathan Cameron
2016-10-19 17:07 ` [PATCH 08/13] staging:iio:ad7606: Move set_drvdata() into common code Lars-Peter Clausen
2016-10-22 16:59 ` Jonathan Cameron
2016-10-19 17:07 ` Lars-Peter Clausen [this message]
2016-10-22 17:02 ` [PATCH 09/13] staging:iio:ad7606: Let the common probe function return int Jonathan Cameron
2016-10-19 17:07 ` [PATCH 10/13] staging:iio:ad7606: Let common remove function take a struct device * Lars-Peter Clausen
2016-10-22 17:09 ` Jonathan Cameron
2016-10-19 17:07 ` [PATCH 11/13] staging:iio:ad7606: Run trigger handler only once per trigger event Lars-Peter Clausen
2016-10-22 17:04 ` Jonathan Cameron
2016-10-19 17:07 ` [PATCH 12/13] staging:iio:ad7606: Use GPIO descriptor API Lars-Peter Clausen
2016-10-22 17:09 ` Jonathan Cameron
2016-10-19 17:07 ` [PATCH 13/13] staging:iio:ad7606: Move buffer code to main source file Lars-Peter Clausen
2016-10-22 17:11 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476896828-10544-10-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).