lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 11 Nov 2013 17:44:12 +0200
From:	Grygorii Strashko <grygorii.strashko@...com>
To:	Prabhakar Lad <prabhakar.csengg@...il.com>
CC:	Sekhar Nori <nsekhar@...com>,
	Linus Walleij <linus.walleij@...aro.org>,
	LKML <linux-kernel@...r.kernel.org>,
	DLOS <davinci-linux-open-source@...ux.davincidsp.com>,
	LAK <linux-arm-kernel@...ts.infradead.org>,
	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
	LDOC <linux-doc@...r.kernel.org>,
	Rob Herring <rob.herring@...xeda.com>,
	Pawel Moll <pawel.moll@....com>,
	Mark Rutland <mark.rutland@....com>,
	Stephen Warren <swarren@...dotorg.org>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Rob Landley <rob@...dley.net>,
	Grant Likely <grant.likely@...aro.org>
Subject: Re: [PATCH v5 5/7] gpio: davinci: add OF support

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@...com> 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-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ