lkml.org 
[lkml]   [2023]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/3] PCI/sysfs: create private functions for pci_create_legacy_files/pci_create_sysfs_dev_files
    Date
    The only difference is they don't have the check against sysfs_initialized.
    This is a preparation for the sysfs init race condition fix.
    No functional change intended.

    Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
    ---
    drivers/pci/pci-sysfs.c | 44 ++++++++++++++++++++++++++---------------
    1 file changed, 28 insertions(+), 16 deletions(-)

    diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
    index 289c1c17b41f..7d4733773633 100644
    --- a/drivers/pci/pci-sysfs.c
    +++ b/drivers/pci/pci-sysfs.c
    @@ -938,24 +938,10 @@ void __weak pci_adjust_legacy_attr(struct pci_bus *b,
    {
    }

    -/**
    - * pci_create_legacy_files - create legacy I/O port and memory files
    - * @b: bus to create files under
    - *
    - * Some platforms allow access to legacy I/O port and ISA memory space on
    - * a per-bus basis. This routine creates the files and ties them into
    - * their associated read, write and mmap files from pci-sysfs.c
    - *
    - * On error unwind, but don't propagate the error to the caller
    - * as it is ok to set up the PCI bus without these files.
    - */
    -void pci_create_legacy_files(struct pci_bus *b)
    +static void __pci_create_legacy_files(struct pci_bus *b)
    {
    int error;

    - if (!sysfs_initialized)
    - return;
    -
    b->legacy_io = kcalloc(2, sizeof(struct bin_attribute),
    GFP_ATOMIC);
    if (!b->legacy_io)
    @@ -998,6 +984,25 @@ void pci_create_legacy_files(struct pci_bus *b)
    dev_warn(&b->dev, "could not create legacy I/O port and ISA memory resources in sysfs\n");
    }

    +/**
    + * pci_create_legacy_files - create legacy I/O port and memory files
    + * @b: bus to create files under
    + *
    + * Some platforms allow access to legacy I/O port and ISA memory space on
    + * a per-bus basis. This routine creates the files and ties them into
    + * their associated read, write and mmap files from pci-sysfs.c
    + *
    + * On error unwind, but don't propagate the error to the caller
    + * as it is ok to set up the PCI bus without these files.
    + */
    +void pci_create_legacy_files(struct pci_bus *b)
    +{
    + if (!sysfs_initialized)
    + return;
    +
    + __pci_create_legacy_files(b);
    +}
    +
    void pci_remove_legacy_files(struct pci_bus *b)
    {
    if (b->legacy_io) {
    @@ -1006,6 +1011,8 @@ void pci_remove_legacy_files(struct pci_bus *b)
    kfree(b->legacy_io); /* both are allocated here */
    }
    }
    +#else
    +static void __pci_create_legacy_files(struct pci_bus *b) {}
    #endif /* HAVE_PCI_LEGACY */

    #if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE)
    @@ -1492,12 +1499,17 @@ static const struct attribute_group pci_dev_resource_resize_group = {
    .is_visible = resource_resize_is_visible,
    };

    +int __must_check __pci_create_sysfs_dev_files(struct pci_dev *pdev)
    +{
    + return pci_create_resource_files(pdev);
    +}
    +
    int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
    {
    if (!sysfs_initialized)
    return -EACCES;

    - return pci_create_resource_files(pdev);
    + return __pci_create_sysfs_dev_files(pdev);
    }

    /**
    --
    2.34.1
    \
     
     \ /
      Last update: 2023-04-27 16:29    [W:3.996 / U:0.052 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site