netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Christoph Fritz <chf.fritz@googlemail.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Rob Herring <rob.herring@calxeda.com>,
	Bill Pemberton <wfp5p@virginia.edu>,
	Andreas Larsson <andreas@gaisler.com>,
	linux-can@vger.kernel.org,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"Hans J. Koch" <hjk@hansjkoch.de>,
	Daniel Mack <daniel@zonque.org>
Subject: Re: [PATCH] can: sja1000: use cpu endian
Date: Mon, 08 Apr 2013 15:57:09 +0200	[thread overview]
Message-ID: <5162CCB5.3000605@pengutronix.de> (raw)
In-Reply-To: <1365428932.5760.52.camel@lovely>

[-- Attachment #1: Type: text/plain, Size: 2987 bytes --]

On 04/08/2013 03:48 PM, Christoph Fritz wrote:

Please add a patch description to the patch, as some subsystem
maintainers don't take patches without it.

What about using of_property_read_u32, instead of open coding it?

Marc

> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  drivers/net/can/sja1000/sja1000_of_platform.c |   26 ++++++++++++------------
>  1 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/can/sja1000/sja1000_of_platform.c b/drivers/net/can/sja1000/sja1000_of_platform.c
> index 6433b81..83a13d2 100644
> --- a/drivers/net/can/sja1000/sja1000_of_platform.c
> +++ b/drivers/net/can/sja1000/sja1000_of_platform.c
> @@ -97,7 +97,7 @@ static int sja1000_ofp_probe(struct platform_device *ofdev)
>  	struct sja1000_priv *priv;
>  	struct resource res;
>  	const u32 *prop;
> -	int err, irq, res_size, prop_size;
> +	int err, irq, res_size;
>  	void __iomem *base;
>  
>  	err = of_address_to_resource(np, 0, &res);
> @@ -138,27 +138,27 @@ static int sja1000_ofp_probe(struct platform_device *ofdev)
>  	priv->read_reg = sja1000_ofp_read_reg;
>  	priv->write_reg = sja1000_ofp_write_reg;
>  
> -	prop = of_get_property(np, "nxp,external-clock-frequency", &prop_size);
> -	if (prop && (prop_size ==  sizeof(u32)))
> -		priv->can.clock.freq = *prop / 2;
> +	prop = of_get_property(np, "nxp,external-clock-frequency", NULL);
> +	if (prop)
> +		priv->can.clock.freq = be32_to_cpup(prop) / 2;
>  	else
>  		priv->can.clock.freq = SJA1000_OFP_CAN_CLOCK; /* default */
>  
> -	prop = of_get_property(np, "nxp,tx-output-mode", &prop_size);
> -	if (prop && (prop_size == sizeof(u32)))
> -		priv->ocr |= *prop & OCR_MODE_MASK;
> +	prop = of_get_property(np, "nxp,tx-output-mode", NULL);
> +	if (prop)
> +		priv->ocr |= be32_to_cpup(prop) & OCR_MODE_MASK;
>  	else
>  		priv->ocr |= OCR_MODE_NORMAL; /* default */
>  
> -	prop = of_get_property(np, "nxp,tx-output-config", &prop_size);
> -	if (prop && (prop_size == sizeof(u32)))
> -		priv->ocr |= (*prop << OCR_TX_SHIFT) & OCR_TX_MASK;
> +	prop = of_get_property(np, "nxp,tx-output-config", NULL);
> +	if (prop)
> +		priv->ocr |= (be32_to_cpup(prop) << OCR_TX_SHIFT) & OCR_TX_MASK;
>  	else
>  		priv->ocr |= OCR_TX0_PULLDOWN; /* default */
>  
> -	prop = of_get_property(np, "nxp,clock-out-frequency", &prop_size);
> -	if (prop && (prop_size == sizeof(u32)) && *prop) {
> -		u32 divider = priv->can.clock.freq * 2 / *prop;
> +	prop = of_get_property(np, "nxp,clock-out-frequency", NULL);
> +	if (prop) {
> +		u32 divider = priv->can.clock.freq * 2 / be32_to_cpup(prop);
>  
>  		if (divider > 1)
>  			priv->cdr |= divider / 2 - 1;
> 


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  reply	other threads:[~2013-04-08 13:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-08 13:48 [PATCH] can: sja1000: use cpu endian Christoph Fritz
2013-04-08 13:57 ` Marc Kleine-Budde [this message]
2013-04-11 18:44   ` [PATCH v2] can: sja1000: fix endian on arm Christoph Fritz
2013-04-11 18:47     ` Marc Kleine-Budde
2013-04-11 18:53       ` Christoph Fritz
2013-04-11 19:14         ` [PATCH v3] " Christoph Fritz
2013-04-11 19:21           ` Marc Kleine-Budde
2013-04-11 19:32             ` [PATCH v4] " Christoph Fritz
2013-04-11 19:38               ` Marc Kleine-Budde
2013-04-12 11:18               ` Marc Kleine-Budde

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=5162CCB5.3000605@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=andreas@gaisler.com \
    --cc=chf.fritz@googlemail.com \
    --cc=daniel@zonque.org \
    --cc=grant.likely@secretlab.ca \
    --cc=hjk@hansjkoch.de \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    --cc=wfp5p@virginia.edu \
    --cc=wg@grandegger.com \
    /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).