From: Gernot Vormayr <gvormayr@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
Michal Simek <michal.simek@xilinx.com>,
linux-gpio@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Gernot Vormayr <gvormayr@gmail.com>
Subject: [PATCH 1/1] gpio: Fix ngpio in gpio-xilinx driver
Date: Thu, 18 Sep 2014 11:03:52 +0200 [thread overview]
Message-ID: <1411031032-20649-1-git-send-email-gvormayr@gmail.com> (raw)
If one adds 'gpio-controller;' to the chip in the devicetree, then
initialization fails with 'gpiochip_find_base: cannot find free range',
because ngpio is 0. This patch fixes the bug.
Tested on ml507 board.
Signed-off-by: Gernot Vormayr <gvormayr@gmail.com>
---
drivers/gpio/gpio-xilinx.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 1248186..4606ad2 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -197,6 +197,7 @@ static int xgpio_of_probe(struct device_node *np)
struct xgpio_instance *chip;
int status = 0;
const u32 *tree_info;
+ u32 ngpio;
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
if (!chip)
@@ -215,8 +216,9 @@ static int xgpio_of_probe(struct device_node *np)
chip->mmchip.gc.ngpio = 32;
/* Check device node and parent device node for device width */
- of_property_read_u32(np, "xlnx,gpio-width",
- (u32 *)&chip->mmchip.gc.ngpio);
+ status = of_property_read_u32(np, "xlnx,gpio-width", &ngpio);
+ if (status == 0)
+ chip->mmchip.gc.ngpio = (u16)ngpio;
spin_lock_init(&chip->gpio_lock);
@@ -262,8 +264,9 @@ static int xgpio_of_probe(struct device_node *np)
chip->mmchip.gc.ngpio = 32;
/* Check device node and parent device node for device width */
- of_property_read_u32(np, "xlnx,gpio2-width",
- (u32 *)&chip->mmchip.gc.ngpio);
+ status = of_property_read_u32(np, "xlnx,gpio2-width", &ngpio);
+ if (status == 0)
+ chip->mmchip.gc.ngpio = (u16)ngpio;
spin_lock_init(&chip->gpio_lock);
--
2.1.0
next reply other threads:[~2014-09-18 9:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 9:03 Gernot Vormayr [this message]
2014-09-23 15:38 ` [PATCH 1/1] gpio: Fix ngpio in gpio-xilinx driver Linus Walleij
2014-09-23 22:48 ` Gernot Vormayr
2014-09-23 22:58 ` [PATCH v2 " Gernot Vormayr
2014-09-24 11:38 ` 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=1411031032-20649-1-git-send-email-gvormayr@gmail.com \
--to=gvormayr@gmail.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.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).