All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <anton@enomsg.org>
To: Haijun Zhang <Haijun.Zhang@freescale.com>
Cc: linux-mmc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	cjb@laptop.org, scottwood@freescale.com, AFLEMING@freescale.com
Subject: Re: [PATCH] mmc:of_spi: Update the code of getting voltage-ranges
Date: Thu, 8 Aug 2013 17:08:05 -0700	[thread overview]
Message-ID: <20130809000805.GA7427@lizard.mcd01528.sjc.wayport.net> (raw)
In-Reply-To: <1375251927-3330-3-git-send-email-Haijun.Zhang@freescale.com>

On Wed, Jul 31, 2013 at 02:25:27PM +0800, Haijun Zhang wrote:
>  	int num_ranges;
> +	u32 ocr_mask;
>  	int i;
>  	int ret = -EINVAL;
>  
> @@ -102,26 +103,11 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
>  	if (!oms)
>  		return NULL;
>  
> -	voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
> -	num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
> -	if (!voltage_ranges || !num_ranges) {
> -		dev_err(dev, "OF: voltage-ranges unspecified\n");
> +	ocr_mask = mmc_of_parse_voltage(np);
> +	if (ocr_mask <= 0)

'< 0' check for an unsigned type? :) I'd write just !ocr_mask...

But other than that the patch looks good to me...

Reviewed-by: Anton Vorontsov <anton@enomsg.org>

Thanks!

>  		goto err_ocr;
> -	}
> -
> -	for (i = 0; i < num_ranges; i++) {
> -		const int j = i * 2;
> -		u32 mask;
>  
> -		mask = mmc_vddrange_to_ocrmask(be32_to_cpu(voltage_ranges[j]),
> -					       be32_to_cpu(voltage_ranges[j + 1]));
> -		if (!mask) {
> -			ret = -EINVAL;
> -			dev_err(dev, "OF: voltage-range #%d is invalid\n", i);
> -			goto err_ocr;
> -		}
> -		oms->pdata.ocr_mask |= mask;
> -	}
> +	oms->pdata.ocr_mask |= ocr_mask;
>  
>  	for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) {
>  		enum of_gpio_flags gpio_flags;
> -- 
> 1.8.0

WARNING: multiple messages have this Message-ID (diff)
From: Anton Vorontsov <anton@enomsg.org>
To: Haijun Zhang <Haijun.Zhang@freescale.com>
Cc: scottwood@freescale.com, linuxppc-dev@lists.ozlabs.org,
	cjb@laptop.org, linux-mmc@vger.kernel.org,
	AFLEMING@freescale.com
Subject: Re: [PATCH] mmc:of_spi: Update the code of getting voltage-ranges
Date: Thu, 8 Aug 2013 17:08:05 -0700	[thread overview]
Message-ID: <20130809000805.GA7427@lizard.mcd01528.sjc.wayport.net> (raw)
In-Reply-To: <1375251927-3330-3-git-send-email-Haijun.Zhang@freescale.com>

On Wed, Jul 31, 2013 at 02:25:27PM +0800, Haijun Zhang wrote:
>  	int num_ranges;
> +	u32 ocr_mask;
>  	int i;
>  	int ret = -EINVAL;
>  
> @@ -102,26 +103,11 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
>  	if (!oms)
>  		return NULL;
>  
> -	voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
> -	num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
> -	if (!voltage_ranges || !num_ranges) {
> -		dev_err(dev, "OF: voltage-ranges unspecified\n");
> +	ocr_mask = mmc_of_parse_voltage(np);
> +	if (ocr_mask <= 0)

'< 0' check for an unsigned type? :) I'd write just !ocr_mask...

But other than that the patch looks good to me...

Reviewed-by: Anton Vorontsov <anton@enomsg.org>

Thanks!

>  		goto err_ocr;
> -	}
> -
> -	for (i = 0; i < num_ranges; i++) {
> -		const int j = i * 2;
> -		u32 mask;
>  
> -		mask = mmc_vddrange_to_ocrmask(be32_to_cpu(voltage_ranges[j]),
> -					       be32_to_cpu(voltage_ranges[j + 1]));
> -		if (!mask) {
> -			ret = -EINVAL;
> -			dev_err(dev, "OF: voltage-range #%d is invalid\n", i);
> -			goto err_ocr;
> -		}
> -		oms->pdata.ocr_mask |= mask;
> -	}
> +	oms->pdata.ocr_mask |= ocr_mask;
>  
>  	for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) {
>  		enum of_gpio_flags gpio_flags;
> -- 
> 1.8.0

  reply	other threads:[~2013-08-09  0:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-31  6:25 [PATCH 1/3 V2] mmc:core: parse voltage from device-tree Haijun Zhang
2013-07-31  6:25 ` Haijun Zhang
2013-07-31  6:25 ` [PATCH 3/3 V2] mmc:esdhc: add support to get " Haijun Zhang
2013-07-31  6:25   ` Haijun Zhang
2013-07-31  6:25 ` [PATCH] mmc:of_spi: Update the code of getting voltage-ranges Haijun Zhang
2013-07-31  6:25   ` Haijun Zhang
2013-08-09  0:08   ` Anton Vorontsov [this message]
2013-08-09  0:08     ` Anton Vorontsov
2013-08-07  1:28 ` [PATCH 1/3 V2] mmc:core: parse voltage from device-tree Zhang Haijun
2013-08-07  1:28   ` Zhang Haijun
2013-08-09  0:15 ` Anton Vorontsov
2013-08-09  0:15   ` Anton Vorontsov
2013-08-09  3:34   ` Zhang Haijun
2013-08-09  3:34     ` Zhang Haijun
2013-08-09 14:48 ` Kumar Gala
2013-08-09 14:48   ` Kumar Gala
2013-08-12  2:46   ` Zhang Haijun
2013-08-12  2:46     ` Zhang Haijun
2013-08-12 16:11     ` Scott Wood
2013-08-12 16:11       ` Scott Wood

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=20130809000805.GA7427@lizard.mcd01528.sjc.wayport.net \
    --to=anton@enomsg.org \
    --cc=AFLEMING@freescale.com \
    --cc=Haijun.Zhang@freescale.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=scottwood@freescale.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.