mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC] net: dm9k: add device tree support
Date: Thu, 11 Sep 2014 08:23:38 +0200	[thread overview]
Message-ID: <20140911062338.GG4992@pengutronix.de> (raw)
In-Reply-To: <1410335628-13200-1-git-send-email-antonynpavlov@gmail.com>

On Wed, Sep 10, 2014 at 11:53:48AM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  drivers/net/dm9k.c | 46 +++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 39 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
> index e525a84..9e7b415 100644
> --- a/drivers/net/dm9k.c
> +++ b/drivers/net/dm9k.c
> @@ -707,16 +707,30 @@ static int dm9k_init_dev(struct eth_device *edev)
>  	return 0;
>  }
>  
> +static struct dm9000_platform_data *dm9000_parse_dt(struct device_d *dev)
> +{
> +	struct dm9000_platform_data *pdata;
> +	struct device_node *np = dev->device_node;
> +
> +	if (!IS_ENABLED(CONFIG_OF) || !np)
> +		return NULL;
> +
> +	pdata = xzalloc(sizeof(*pdata));
> +
> +	pdata->srom = 0;

Please don't allocate platform_data for the device tree case. Instead,
add a srom variable to struct dm9k and set it either from platform_data
or device tree.

> -	priv->buswidth = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> +	switch (resource_size(&dev->resource[0])) {
> +	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");
> +		priv->buswidth = 0;
> +	}

Does this work for device tree?

Sascha

-- 
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

      reply	other threads:[~2014-09-11  6:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10  7:53 Antony Pavlov
2014-09-11  6:23 ` Sascha Hauer [this message]

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=20140911062338.GG4992@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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