Re: [PATCH v3 1/3] usb: typec: Separate USB Power Delivery from USB Type-C

From: Greg Kroah-Hartman
Date: Wed Apr 27 2022 - 04:50:58 EST


On Wed, Apr 27, 2022 at 11:17:49AM +0300, Heikki Krogerus wrote:
> On Wed, Apr 27, 2022 at 09:30:30AM +0200, Greg Kroah-Hartman wrote:
> > > > "struct pd" is just about the shortest structure name I've seen in the
> > > > kernel so far. How about using some more letters? :)
> > >
> > > Okay, I'll make it usbpd.
> >
> > How about some more vowels: "struct usb_power_delivery" please. This
> > isn't the 1980's :)
>
> "struct usb_power_delivery" is fine, but I would still really really
> want to use "struct usbpd_capabilities" instead of
> "struct usb_power_delivery_capabilities" - it's just too long.
> Is that okay?

Nah, spell it out please, we don't use "usbpd" anywhere, and again, we
don't have a limit of characters. Most editors should auto-complete
anyway :)

> > > > The kobject question above goes to the code as well. You are creating a
> > > > bunch of raw kobjects still, why? This should all fit into the driver
> > > > model and kobjects shouldn't be needed. Are you trying to nest too deep
> > > > in the attributes? If so, kobjects will not work as userspace tools
> > > > will not realize they are there and are attributes at all.
> > >
> > > They are not raw kobjects, they are all devices now. That header just
> > > needs to be fixed.
> >
> > You have loads of kobject attributes in the .c file. Either I read it
> > wrong, or you are doing something wrong, as that should never be the
> > case for a driver or device.
>
> Hmm, I'm probable still doing something wrong...

All of your sysfs callbacks should have a struct device, not a kobject.
You might just be getting lucky in that we are casting around a pointer
of the correct layout. But the compiler should have caught that
somewhere, please look into it.

thanks,

greg k-h