Re: [PATCH v3] PCI/DOE: Expose the DOE protocols via sysfs

From: Lukas Wunner
Date: Thu Aug 10 2023 - 03:44:50 EST


On Thu, Aug 10, 2023 at 07:05:12AM +0200, Greg KH wrote:
> On Wed, Aug 09, 2023 at 07:28:51PM -0400, Alistair Francis wrote:
> > v3:
> > - Expose each DOE feature as a separate file
>
> But you don't actually have anything in the sysfs files, why not?

He wants to expose a list of supported protocols.

He first exposed the list in a single attribute, separated by newlines.
Which made sense because it allows users to grep for a specific protocol.

You told him not to expose multiple values in a single attribute.
So he's exposing the available protocols each in an empty file.
The file name contains the protocol.

You got what you asked for. ;)


> > --- a/drivers/pci/doe.c
> > +++ b/drivers/pci/doe.c
> > @@ -56,6 +56,10 @@ struct pci_doe_mb {
> > wait_queue_head_t wq;
> > struct workqueue_struct *work_queue;
> > unsigned long flags;
> > +
> > +#ifdef CONFIG_SYSFS
> > + struct device_attribute *sysfs_attrs;
> > +#endif
>
> Please don't put #ifdefs in .c files if you can prevent it. I think
> this will work just fine if you don't have the #ifdef. And who would be
> using pci without sysfs?

People with space-constrained devices such as routers.

It is perfectly legal to compile a kernel with CONFIG_PCI=y and
CONFIG_SYSFS=n.

And it is reasonable not to include code in the kernel which has
specifically been deselected in the kernel config.

Thanks,

Lukas