Re: [PATCH v5 5/7] gpio: davinci: add OF support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/11/2013 05:37 PM, Prabhakar Lad wrote:
Hi Grygorii,

Thanks for the review.

On Mon, Nov 11, 2013 at 8:48 PM, Grygorii Strashko
<grygorii.strashko@xxxxxx> wrote:
On 11/08/2013 12:11 PM, Prabhakar Lad wrote:
[Snip]
@@ -134,6 +137,40 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
       writel((1 << offset), value ? &g->set_data : &g->clr_data);
   }

+static struct davinci_gpio_platform_data *
+davinci_gpio_get_pdata(struct platform_device *pdev)

Minor: usually such functions have "_of" in their names:
  davinci_gpio_of_get_pdata()

Ahh but actual this function is intended to get pdata in both the
cases DT and NON-DT, so kept it generic :)

np


+{
+     struct device_node *dn = pdev->dev.of_node;
+     struct davinci_gpio_platform_data *pdata;
+     int ret;
+     u32 val;
+
+     if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
+             return pdev->dev.platform_data;
+
+     pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+     if (!pdata)
+             return NULL;
+
+     ret = of_property_read_u32(dn, "ti,ngpio", &val);
+     if (ret)
+             goto of_err;
+
+     pdata->ngpio = val;
+
+     ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked", &val);
+     if (ret)
+             goto of_err;
+
+     pdata->gpio_unbanked = val;
+
+     return pdata;
+
+of_err:
+     dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret);
+     return NULL;
+}
+
   static int davinci_gpio_probe(struct platform_device *pdev)
   {
       int i, base;
@@ -144,12 +181,14 @@ static int davinci_gpio_probe(struct platform_device *pdev)
       struct device *dev = &pdev->dev;
       struct resource *res;

-     pdata = dev->platform_data;
+     pdata = davinci_gpio_get_pdata(pdev);
       if (!pdata) {
               dev_err(dev, "No platform data found\n");
               return -EINVAL;
       }

+     dev->platform_data = pdata;
+

Pls, add following code to GPIO chip initialization:

@@ -233,6 +245,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
                 chips[i].chip.ngpio = ngpio - base;
                 if (chips[i].chip.ngpio > 32)
                         chips[i].chip.ngpio = 32;
+#ifdef CONFIG_OF_GPIO
+               chips[i].chip.of_node = dev->of_node;
+#endif


OK

Regards,
--Prabhakar Lad


--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux