diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-02-18 11:38:58 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-03-07 08:57:56 +0100 |
commit | 3bd69ad077a955b469baa90d938fd83510297335 (patch) | |
tree | 94d314d51fd295e6cb7de9f682582c29fdd50eed /drivers/pwm | |
parent | fe7855bb4f2d82ac4559c46c586c2f29e9f123e2 (diff) | |
download | barebox-3bd69ad077a955b469baa90d938fd83510297335.tar.gz barebox-3bd69ad077a955b469baa90d938fd83510297335.tar.xz |
driver: replace dev_request_mem_region with dev_request_mem_resource
dev_request_mem_region doesn't work properly one some SoCs on which
PTR_ERR() values clash with valid return values from dev_request_mem_region.
Replace them with dev_request_mem_resource where possible.
This patch has been generated with the following semantic patch:
// <smpl>
@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
-if (IS_ERR(io)) {
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores)) {
...
- return PTR_ERR(io);
-}
+ return PTR_ERR(iores);
+}
+io = IOMEM(iores->start);
...+>
}
@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
-if (IS_ERR(io)) {
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores))
- return PTR_ERR(io);
-}
+ return PTR_ERR(iores);
+io = IOMEM(iores->start);
...+>
}
@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
-if (IS_ERR(io)) {
- ret = PTR_ERR(io);
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores)) {
+ ret = PTR_ERR(iores);
...
}
+io = IOMEM(iores->start);
...+>
}
@@
expression d;
expression n;
expression io;
identifier func;
@@
func(...) {
+struct resource *iores;
<+...
-io = dev_request_mem_region(d, n);
+iores = dev_request_mem_resource(d, n);
+if (IS_ERR(iores))
+ return PTR_ERR(iores);
+io = IOMEM(iores->start);
...+>
}
@@
identifier func;
@@
func(...) {
<+...
struct resource *iores;
-struct resource *iores;
...+>
}
// </smpl>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-imx.c | 8 | ||||
-rw-r--r-- | drivers/pwm/pwm-mxs.c | 8 | ||||
-rw-r--r-- | drivers/pwm/pxa_pwm.c | 6 |
3 files changed, 15 insertions, 7 deletions
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index bd99cf3198..0845c234fe 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -212,6 +212,7 @@ static struct of_device_id imx_pwm_dt_ids[] = { static int imx_pwm_probe(struct device_d *dev) { + struct resource *iores; const struct imx_pwm_data *data; struct imx_chip *imx; int ret = 0; @@ -226,9 +227,10 @@ static int imx_pwm_probe(struct device_d *dev) if (IS_ERR(imx->clk_per)) return PTR_ERR(imx->clk_per); - imx->mmio_base = dev_request_mem_region(dev, 0); - if (IS_ERR(imx->mmio_base)) - return PTR_ERR(imx->mmio_base); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + imx->mmio_base = IOMEM(iores->start); imx->chip.ops = &imx_pwm_ops; if (dev->device_node) { diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c index e66744288b..011d9002ba 100644 --- a/drivers/pwm/pwm-mxs.c +++ b/drivers/pwm/pwm-mxs.c @@ -110,6 +110,7 @@ static struct pwm_ops mxs_pwm_ops = { static int mxs_pwm_probe(struct device_d *dev) { + struct resource *iores; struct device_node *np = dev->device_node; struct mxs_pwm *mxs; int ret, i; @@ -117,9 +118,10 @@ static int mxs_pwm_probe(struct device_d *dev) mxs = xzalloc(sizeof(*mxs)); - mxs->base = dev_request_mem_region(dev, 0); - if (IS_ERR(mxs->base)) - return PTR_ERR(mxs->base); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + mxs->base = IOMEM(iores->start); mxs->clk = clk_get(dev, NULL); if (IS_ERR(mxs->clk)) diff --git a/drivers/pwm/pxa_pwm.c b/drivers/pwm/pxa_pwm.c index 8b2ebe4f6f..e399d03efd 100644 --- a/drivers/pwm/pxa_pwm.c +++ b/drivers/pwm/pxa_pwm.c @@ -130,12 +130,16 @@ static struct pwm_ops pxa_pwm_ops = { static int pxa_pwm_probe(struct device_d *dev) { + struct resource *iores; struct pxa_pwm_chip *chip; chip = xzalloc(sizeof(*chip)); chip->chip.devname = asprintf("pwm%d", dev->id); chip->chip.ops = &pxa_pwm_ops; - chip->iobase = dev_request_mem_region(dev, 0); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + chip->iobase = IOMEM(iores->start); chip->id = dev->id; dev->priv = chip; |