lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51670532.5060101@pengutronix.de>
Date:	Thu, 11 Apr 2013 20:47:14 +0200
From:	Marc Kleine-Budde <mkl@...gutronix.de>
To:	Christoph Fritz <chf.fritz@...glemail.com>
CC:	Wolfgang Grandegger <wg@...ndegger.com>,
	Rob Herring <rob.herring@...xeda.com>,
	Grant Likely <grant.likely@...retlab.ca>,
	linux-can@...r.kernel.org,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	Andreas Larsson <andreas@...sler.com>,
	"Hans J. Koch" <hjk@...sjkoch.de>,
	Bill Pemberton <wfp5p@...ginia.edu>,
	Daniel Mack <daniel@...que.org>
Subject: Re: [PATCH v2] can: sja1000: fix endian on arm

On 04/11/2013 08:44 PM, Christoph Fritz wrote:
> To get correct endian on arm cpus while reading device tree properties,
> this patch replaces of_get_property() with of_property_read_u32().
> 
> Signed-off-by: Christoph Fritz <chf.fritz@...glemail.com>

looks good, one nitpick inline

> ---
>  drivers/net/can/sja1000/sja1000_of_platform.c |   32 ++++++++++++-------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/can/sja1000/sja1000_of_platform.c b/drivers/net/can/sja1000/sja1000_of_platform.c
> index 6433b81..dd8b031 100644
> --- a/drivers/net/can/sja1000/sja1000_of_platform.c
> +++ b/drivers/net/can/sja1000/sja1000_of_platform.c
> @@ -96,8 +96,8 @@ static int sja1000_ofp_probe(struct platform_device *ofdev)
>  	struct net_device *dev;
>  	struct sja1000_priv *priv;
>  	struct resource res;
> -	const u32 *prop;
> -	int err, irq, res_size, prop_size;
> +	u32 prop;
> +	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;
> +	err = of_property_read_u32(np, "nxp,external-clock-frequency", &prop);
> +	if (!err)
> +		priv->can.clock.freq = 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;
> +	err = of_property_read_u32(np, "nxp,tx-output-mode", &prop);
> +	if (!err)
> +		priv->ocr |= 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;
> +	err = of_property_read_u32(np, "nxp,tx-output-config", &prop);
> +	if (!err)
> +		priv->ocr |= (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;
> +	err = of_property_read_u32(np, "nxp,clock-out-frequency", &prop);
> +	if (!err) {
> +		u32 divider = priv->can.clock.freq * 2 / prop;
>  
>  		if (divider > 1)
>  			priv->cdr |= divider / 2 - 1;
> @@ -168,8 +168,8 @@ static int sja1000_ofp_probe(struct platform_device *ofdev)
>  		priv->cdr |= CDR_CLK_OFF; /* default */
>  	}
>  
> -	prop = of_get_property(np, "nxp,no-comparator-bypass", NULL);
> -	if (!prop)
> +	err = of_property_read_u32(np, "nxp,no-comparator-bypass", &prop);

What about using of_property_read_bool instead?

> +	if (err)
>  		priv->cdr |= CDR_CBP; /* default */
>  
>  	priv->irq_flags = IRQF_SHARED;
> 

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


Download attachment "signature.asc" of type "application/pgp-signature" (264 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ