diff mbox

pinctrl: sirf: replace of_gpio_simple_xlate by sirf specific of_xlate

Message ID 1359971614-18681-1-git-send-email-Barry.Song@csr.com (mailing list archive)
State New, archived
Headers show

Commit Message

Barry Song Feb. 4, 2013, 9:53 a.m. UTC
From: Barry Song <Baohua.Song@csr.com>

the default of_gpio_simple_xlate() will make us fail while getting gpios
bigger than 32 by of_get_named_gpio() or related APIs.
this patch adds a specific of_xlate callback for sirf gpio_chip and fix
the problem.

Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
 drivers/pinctrl/pinctrl-sirf.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

Comments

Linus Walleij Feb. 5, 2013, 2:31 p.m. UTC | #1
On Mon, Feb 4, 2013 at 10:53 AM, Barry Song <Barry.Song@csr.com> wrote:

> From: Barry Song <Baohua.Song@csr.com>
>
> the default of_gpio_simple_xlate() will make us fail while getting gpios
> bigger than 32 by of_get_named_gpio() or related APIs.
> this patch adds a specific of_xlate callback for sirf gpio_chip and fix
> the problem.
>
> Signed-off-by: Barry Song <Baohua.Song@csr.com>

Patch applied, hope this will be the last thing on fixes
for this cycle. I really need to get the last fixes to Torvalds now.

Yours,
Linus Walleij
Barry Song Feb. 5, 2013, 2:40 p.m. UTC | #2
2013/2/5 Linus Walleij <linus.walleij@linaro.org>:
> On Mon, Feb 4, 2013 at 10:53 AM, Barry Song <Barry.Song@csr.com> wrote:
>
>> From: Barry Song <Baohua.Song@csr.com>
>>
>> the default of_gpio_simple_xlate() will make us fail while getting gpios
>> bigger than 32 by of_get_named_gpio() or related APIs.
>> this patch adds a specific of_xlate callback for sirf gpio_chip and fix
>> the problem.
>>
>> Signed-off-by: Barry Song <Baohua.Song@csr.com>
>
> Patch applied, hope this will be the last thing on fixes
> for this cycle. I really need to get the last fixes to Torvalds now.
>
at least it is my last :-)

> Yours,
> Linus Walleij
>
-barry
diff mbox

Patch

diff --git a/drivers/pinctrl/pinctrl-sirf.c b/drivers/pinctrl/pinctrl-sirf.c
index fc76f28..7051874 100644
--- a/drivers/pinctrl/pinctrl-sirf.c
+++ b/drivers/pinctrl/pinctrl-sirf.c
@@ -1246,6 +1246,22 @@  static void __iomem *sirfsoc_rsc_of_iomap(void)
 	return of_iomap(np, 0);
 }
 
+static int sirfsoc_gpio_of_xlate(struct gpio_chip *gc,
+       const struct of_phandle_args *gpiospec,
+       u32 *flags)
+{
+       if (gpiospec->args[0] > SIRFSOC_GPIO_NO_OF_BANKS * SIRFSOC_GPIO_BANK_SIZE)
+               return -EINVAL;
+
+       if (gc != &sgpio_bank[gpiospec->args[0] / SIRFSOC_GPIO_BANK_SIZE].chip.gc)
+               return -EINVAL;
+
+       if (flags)
+               *flags = gpiospec->args[1];
+
+       return gpiospec->args[0] % SIRFSOC_GPIO_BANK_SIZE;
+}
+
 static int sirfsoc_pinmux_probe(struct platform_device *pdev)
 {
 	int ret;
@@ -1747,6 +1763,8 @@  static int sirfsoc_gpio_probe(struct device_node *np)
 		bank->chip.gc.ngpio = SIRFSOC_GPIO_BANK_SIZE;
 		bank->chip.gc.label = kstrdup(np->full_name, GFP_KERNEL);
 		bank->chip.gc.of_node = np;
+		bank->chip.gc.of_xlate = sirfsoc_gpio_of_xlate;
+		bank->chip.gc.of_gpio_n_cells = 2;
 		bank->chip.regs = regs;
 		bank->id = i;
 		bank->is_marco = is_marco;