From: Mark Rutland <mark.rutland@arm.com>
To: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
"grant.likely@linaro.org" <grant.likely@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
John Crispin <blogic@openwrt.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 4/8] gpio-mm-lantiq: Use of_propery_read_u16
Date: Mon, 19 Jan 2015 10:57:53 +0000 [thread overview]
Message-ID: <20150119105753.GC21553@leverpostej> (raw)
In-Reply-To: <1421581173-28416-5-git-send-email-ricardo.ribalda@gmail.com>
On Sun, Jan 18, 2015 at 11:39:29AM +0000, Ricardo Ribalda Delgado wrote:
> Instead of parsing manually the shadow content, use the much simpler
> helper of_property_read_u16.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: John Crispin <blogic@openwrt.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
> drivers/gpio/gpio-mm-lantiq.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mm-lantiq.c b/drivers/gpio/gpio-mm-lantiq.c
> index 7d55161..b511a6b 100644
> --- a/drivers/gpio/gpio-mm-lantiq.c
> +++ b/drivers/gpio/gpio-mm-lantiq.c
> @@ -105,7 +105,6 @@ static void ltq_mm_save_regs(struct of_mm_gpio_chip *mm_gc)
> static int ltq_mm_probe(struct platform_device *pdev)
> {
> struct ltq_mm *chip;
> - const __be32 *shadow;
>
> chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
> if (!chip)
> @@ -117,9 +116,8 @@ static int ltq_mm_probe(struct platform_device *pdev)
> chip->mmchip.save_regs = ltq_mm_save_regs;
>
> /* store the shadow value if one was passed by the devicetree */
> - shadow = of_get_property(pdev->dev.of_node, "lantiq,shadow", NULL);
> - if (shadow)
> - chip->shadow = be32_to_cpu(*shadow);
> + of_property_read_u16(pdev->dev.of_node, "lantiq,shadow",
> + &chip->shadow);
The old code and new code aren't equivalent:
The binding doesn't specify the use of /bits/ 16 <...>, nor does the
only in-tree dts use it:
arch/mips/boot/dts/easy50712.dts: lantiq,shadow = <0xfff>;
So in the DTB, lantiq-shadow will be stored as a be32 value. The byte
stream will look like: [00 00 0f ff].
The existing code reads all 4 bytes, and converts them as required,
reading the expected value of 0xfff. If you use of_property_read_u16,
this will only take the first 2 bytes, and will incorrectly read 0.
You can instead use of_property_read_u32, which will function
equivalently to the existing code.
Thanks,
Mark.
next prev parent reply other threads:[~2015-01-19 10:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-18 11:39 [PATCH 0/8] Use of_mm_gpiochip_remove Ricardo Ribalda Delgado
2015-01-18 11:39 ` [PATCH 1/8] gpio/mpc5200: " Ricardo Ribalda Delgado
2015-01-20 10:06 ` Linus Walleij
2015-01-18 11:39 ` [PATCH 2/8] gpio/-mm-lantiq: Use devm_kzalloc Ricardo Ribalda Delgado
2015-01-20 10:07 ` Linus Walleij
2015-01-18 11:39 ` [PATCH 3/8] gpio/mm-lantiq: Do not replicate code Ricardo Ribalda Delgado
2015-01-20 10:09 ` Linus Walleij
2015-01-18 11:39 ` [PATCH 4/8] gpio-mm-lantiq: Use of_propery_read_u16 Ricardo Ribalda Delgado
2015-01-19 10:57 ` Mark Rutland [this message]
2015-01-19 11:27 ` [PATCH v2 4/8] gpio-mm-lantiq: Use of_property_read_u32 Ricardo Ribalda Delgado
2015-01-20 10:10 ` Linus Walleij
2015-01-19 11:28 ` [PATCH 4/8] gpio-mm-lantiq: Use of_propery_read_u16 Ricardo Ribalda Delgado
2015-01-18 11:39 ` [PATCH 5/8] gpio/gpio-mm-lantiq: Use of_mm_gpiochip_remove Ricardo Ribalda Delgado
2015-01-18 11:39 ` [PATCH 6/8] gpio/zevio: " Ricardo Ribalda Delgado
2015-01-18 11:39 ` [PATCH 7/8] gpio/mpc8xxx: Convert to platform device interface Ricardo Ribalda Delgado
2015-01-19 22:36 ` Peter Korsgaard
2015-01-19 22:48 ` Peter Korsgaard
2015-01-19 23:37 ` Ricardo Ribalda Delgado
2015-01-20 10:41 ` Peter Korsgaard
2015-01-20 10:54 ` Ricardo Ribalda Delgado
2015-01-20 2:03 ` Alexandre Courbot
2015-01-20 10:15 ` Linus Walleij
2015-01-18 11:39 ` [PATCH 8/8] gpio/mpc8xxx: Use of_mm_gpiochip_remove Ricardo Ribalda Delgado
2015-01-19 22:52 ` Peter Korsgaard
2015-01-19 23:10 ` Ricardo Ribalda Delgado
2015-01-20 10:40 ` Peter Korsgaard
2015-01-20 10:17 ` Linus Walleij
2015-01-20 10:31 ` Ricardo Ribalda Delgado
2015-01-21 16:45 ` Linus Walleij
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=20150119105753.GC21553@leverpostej \
--to=mark.rutland@arm.com \
--cc=blogic@openwrt.org \
--cc=devicetree@vger.kernel.org \
--cc=gnurou@gmail.com \
--cc=grant.likely@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ricardo.ribalda@gmail.com \
--cc=robh+dt@kernel.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