lkml.org 
[lkml]   [2018]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] power: supply: Add Spreadtrum SC27XX fuel gauge unit driver
Hi,

On 20 September 2018 at 08:36, Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
> Hi,
>
> On Mon, Sep 17, 2018 at 12:01:51PM +0800, Baolin Wang wrote:
> [...]
>> >> +static int sc27xx_fgu_parse_dt(struct sc27xx_fgu_data *data,
>> >> + struct device_node *np)
>> >> +{
>> >> + const __be32 *list;
>> >> + int i, len, size, ret;
>> >> +
>> >> + ret = of_property_read_u32(np, "reg", &data->base);
>> >> + if (ret) {
>> >> + dev_err(data->dev, "failed to get fgu address\n");
>> >> + return ret;
>> >> + }
>> >> +
>> >> + data->gpiod = devm_gpiod_get_optional(data->dev, "bat-detect", GPIOD_IN);
>> >> + if (IS_ERR(data->gpiod)) {
>> >> + dev_err(data->dev, "failed to get battery detection GPIO\n");
>> >> + return PTR_ERR(data->gpiod);
>> >> + }
>> >
>> > According to the binding (and the remaining code!) this gpio is not
>> > optional.
>>
>> Yes, they are not optional. If we can not get the detection GPIO, we
>> will return errors. So am I missing something else?
>>
>> Thanks for your comments.
>
> devm_gpiod_get_optional => devm_gpiod_get
>
> The _optional variant will return NULL if the GPIO is not specified in DT.
> The variant without _optional will return an error instead.

Ah, you are definitely correct. I missed _optional and thanks for
pointing this out.

--
Baolin Wang
Best Regards

\
 
 \ /
  Last update: 2018-09-20 02:41    [W:0.065 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site