[PATCH v5 08/27] PCI: add support for dev_groups to struct pci_device_driver
Bjorn Helgaas
helgaas at kernel.org
Wed Apr 28 16:53:18 UTC 2021
In subject:
s/PCI: add support/PCI: Add support/
to match convention ("git log --oneline drivers/pci/pci-driver.c" to
learn this).
On Wed, Apr 28, 2021 at 11:11:48AM -0400, Andrey Grodzovsky wrote:
> This is exact copy of 'USB: add support for dev_groups to
> struct usb_device_driver' patch by Greg but just for
> the PCI case.
Ideally this would be an imperative sentence telling us what the patch
*does*, not just that it's a copy of something else.
I'd also like a brief comment about why this is useful, i.e., why you
need this and what you're going to use it for.
The usual commit citation format is 7d9c1d2f7aca ("USB: add support
for dev_groups to struct usb_device_driver") so it's easier to locate
the commit.
I see there is also b71b283e3d6d ("USB: add support for dev_groups to
struct usb_driver"). I don't know enough about USB to know whether
7d9c1d2f7aca or b71b283e3d6d is a closer analogue to what you're doing
here, but I do see that struct usb_driver is far more common than
struct usb_device_driver.
PCI has struct pci_driver, but doesn't have the concept of a struct
pci_device_driver.
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
> Suggested-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> ---
> drivers/pci/pci-driver.c | 1 +
> include/linux/pci.h | 3 +++
> 2 files changed, 4 insertions(+)
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index ec44a79e951a..3a72352aa5cf 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -1385,6 +1385,7 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,
> drv->driver.owner = owner;
> drv->driver.mod_name = mod_name;
> drv->driver.groups = drv->groups;
> + drv->driver.dev_groups = drv->dev_groups;
>
> spin_lock_init(&drv->dynids.lock);
> INIT_LIST_HEAD(&drv->dynids.list);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 86c799c97b77..b57755b03009 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -858,6 +858,8 @@ struct module;
> * number of VFs to enable via sysfs "sriov_numvfs" file.
> * @err_handler: See Documentation/PCI/pci-error-recovery.rst
> * @groups: Sysfs attribute groups.
> + * @dev_groups: Attributes attached to the device that will be
> + * created once it is bound to the driver.
> * @driver: Driver model structure.
> * @dynids: List of dynamically added device IDs.
> */
> @@ -873,6 +875,7 @@ struct pci_driver {
> int (*sriov_configure)(struct pci_dev *dev, int num_vfs); /* On PF */
> const struct pci_error_handlers *err_handler;
> const struct attribute_group **groups;
> + const struct attribute_group **dev_groups;
> struct device_driver driver;
> struct pci_dynids dynids;
> };
> --
> 2.25.1
>
More information about the dri-devel
mailing list