RE: [PATCH v5 3/5] power: supply: Add 'usb_type' property and supporting code
From: Adam Thomson
Date: Thu Mar 22 2018 - 06:27:48 EST
On 22 March 2018 04:08, Guenter Roeck wrote:
> > +static ssize_t power_supply_show_usb_type(struct device *dev,
> > + enum power_supply_usb_type
> *usb_types,
> > + ssize_t num_usb_types,
> > + union power_supply_propval *value,
> > + char *buf)
> > +{
> > + enum power_supply_usb_type usb_type;
> > + ssize_t count = 0;
> > + bool match = false;
> > + int i;
> > +
> > + if ((!usb_types) || (num_usb_types <= 0)) {
>
> Unnecessary ( )
Fine, can remove.
>
> > + dev_warn(dev, "driver has no valid connected types\n");
>
> Are those warnings useful or do they just clog the log ? Either case, if that happens,
> wouldn't it be better to detect the situation during registration and abort ?
This is added as an optional property for supply drivers. This will only show
up if a supply driver adds the USB_TYPE property to its list, and then someone
attempts to access it. Actually there's no current checking for the psy_desc
information provided to the register function, so for example if it's NULL then
the kernel will dump when it tries to dereference. I'll take a look at this and
see if I can add something, including checks on the usb_type property.