Re: [PATCH 2/2] power: supply: Add Spreadtrum SC27XX fuel gauge unit driver

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

 



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.

-- Sebastian

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux