* Re: [PATCH] fix IORESOURCE_MEM_xxx usage in dm9k driver
2016-06-25 3:53 [PATCH] fix IORESOURCE_MEM_xxx usage in dm9k driver zzs213
@ 2016-06-27 7:47 ` Sascha Hauer
2016-06-27 8:18 ` 张忠山
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sascha Hauer @ 2016-06-27 7:47 UTC (permalink / raw)
To: zzs213; +Cc: barebox
On Sat, Jun 25, 2016 at 11:53:00AM +0800, zzs213@126.com wrote:
> From: 张忠山 <zzs213@126.com>
>
> Because the const used in dm9k driver unmatch the new IORESOURCE_MEM_xxx
> macro. So whenever the driver start probe, the flowwing error message
> appear:
>
> Wrong io resource size
>
> This patch fix this.
>
> Signed-off-by: 张忠山 <zzs213@126.com>
> ---
> drivers/net/dm9k.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
> index ad402e3..7a41868 100644
> --- a/drivers/net/dm9k.c
> +++ b/drivers/net/dm9k.c
> @@ -732,14 +732,10 @@ static int dm9k_init_dev(struct eth_device *edev)
> static int dm9000_setup_buswidth(struct device_d *dev, struct dm9k *priv, uint32_t width)
> {
> switch (width) {
> - case 1:
> - priv->buswidth = IORESOURCE_MEM_8BIT;
> - break;
> - case 2:
> - priv->buswidth = IORESOURCE_MEM_16BIT;
> - break;
> - case 4:
> - priv->buswidth = IORESOURCE_MEM_32BIT;
> + case IORESOURCE_MEM_8BIT:
> + case IORESOURCE_MEM_16BIT:
> + case IORESOURCE_MEM_32BIT:
> + priv->buswidth = width;
> break;
> default:
> dev_err(dev, "Wrong io resource size\n");
This seems to fix platform data based probe but breaks device tree
support. The culprit is in:
d818f02 net: dm9k: add device tree support
I believe this should be like the attached patch. Could you confirm this
works for you?
Sascha
-----------------------------------8<-----------------------------
From 14d10daa084eb70afe96b044c58272fc991f94f3 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Mon, 27 Jun 2016 09:12:53 +0200
Subject: [PATCH] net: dm9k: Fix buswidth setting for platform data probe
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
priv->buswidth expects IORESOURCE_MEM_* macros which are not
identical to the integer byte bus width, so calling
dm9000_setup_buswidth() for the platform_data case is wrong.
fixes: d818f02 net: dm9k: add device tree support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported by: 张忠山 <zzs213@126.com>
---
drivers/net/dm9k.c | 42 ++++++++++++++++++------------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
index acc0abb..25f0860 100644
--- a/drivers/net/dm9k.c
+++ b/drivers/net/dm9k.c
@@ -729,26 +729,6 @@ static int dm9k_init_dev(struct eth_device *edev)
return 0;
}
-static int dm9000_setup_buswidth(struct device_d *dev, struct dm9k *priv, uint32_t width)
-{
- switch (width) {
- case 1:
- priv->buswidth = IORESOURCE_MEM_8BIT;
- break;
- case 2:
- priv->buswidth = IORESOURCE_MEM_16BIT;
- break;
- case 4:
- priv->buswidth = IORESOURCE_MEM_32BIT;
- break;
- default:
- dev_err(dev, "Wrong io resource size\n");
- return -EINVAL;
- }
-
- return 0;
-}
-
static int dm9000_parse_dt(struct device_d *dev, struct dm9k *priv)
{
struct device_node *np = dev->device_node;
@@ -768,19 +748,33 @@ static int dm9000_parse_dt(struct device_d *dev, struct dm9k *priv)
prop = 1;
}
- return dm9000_setup_buswidth(dev, priv, prop);
+ switch (prop) {
+ case 1:
+ priv->buswidth = IORESOURCE_MEM_8BIT;
+ break;
+ case 2:
+ priv->buswidth = IORESOURCE_MEM_16BIT;
+ break;
+ case 4:
+ priv->buswidth = IORESOURCE_MEM_32BIT;
+ break;
+ default:
+ dev_err(dev, "Wrong io resource size\n");
+ return -EINVAL;
+ }
+
+ return 0;
}
static int dm9000_parse_pdata(struct device_d *dev, struct dm9k *priv)
{
struct dm9000_platform_data *pdata = dev->platform_data;
- uint32_t width;
priv->srom = pdata->srom;
- width = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
+ priv->buswidth = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
- return dm9000_setup_buswidth(dev, priv, width);
+ return 0;
}
static int dm9k_probe(struct device_d *dev)
--
2.8.1
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread