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/net/davinci_emac.c | |
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/net/davinci_emac.c')
-rw-r--r-- | drivers/net/davinci_emac.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 9f8f0e1fa7..3dc4b16b67 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -516,6 +516,7 @@ out: static int davinci_emac_probe(struct device_d *dev) { + struct resource *iores; struct davinci_emac_platform_data *pdata; struct davinci_emac_priv *priv; uint64_t start; @@ -534,10 +535,25 @@ static int davinci_emac_probe(struct device_d *dev) priv->dev = dev; - priv->adap_emac = dev_request_mem_region(dev, 0); - priv->adap_ewrap = dev_request_mem_region(dev, 1); - priv->adap_mdio = dev_request_mem_region(dev, 2); - priv->emac_desc_base = dev_request_mem_region(dev, 3); + iores = dev_request_mem_resource(dev, 0); + if (IS_ERR(iores)) + return PTR_ERR(iores); + priv->adap_emac = IOMEM(iores->start); + + iores = dev_request_mem_resource(dev, 1); + if (IS_ERR(iores)) + return PTR_ERR(iores); + priv->adap_ewrap = IOMEM(iores->start); + + iores = dev_request_mem_resource(dev, 2); + if (IS_ERR(iores)) + return PTR_ERR(iores); + priv->adap_mdio = IOMEM(iores->start); + + iores = dev_request_mem_resource(dev, 3); + if (IS_ERR(iores)) + return PTR_ERR(iores); + priv->emac_desc_base = IOMEM(iores->start); /* EMAC descriptors */ priv->emac_rx_desc = priv->emac_desc_base + EMAC_RX_DESC_BASE; |