[1/1] PCI/sysfs: get rid of pci_sysfs_init late_initcall
Commit Message
All this initcall does is creating sysfs file for devices already
added to the bus. But this is racing with pci_host_probe which will
add sysfs files on it's own merit.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=215515
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
This is a different approach to fix the race condition mentioned in the
link. From what I can see is that the functions for creating sysfs are
called during pci bus registration anyway, so there is no need to
iterate once again.
drivers/pci/pci-sysfs.c | 33 ---------------------------------
1 file changed, 33 deletions(-)
@@ -31,8 +31,6 @@
#include <linux/aperture.h>
#include "pci.h"
-static int sysfs_initialized; /* = 0 */
-
/* show configuration fields */
#define pci_config_attr(field, format_string) \
static ssize_t \
@@ -953,9 +951,6 @@ 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)
@@ -1494,9 +1489,6 @@ static const struct attribute_group pci_dev_resource_resize_group = {
int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
{
- if (!sysfs_initialized)
- return -EACCES;
-
return pci_create_resource_files(pdev);
}
@@ -1508,34 +1500,9 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
*/
void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
{
- if (!sysfs_initialized)
- return;
-
pci_remove_resource_files(pdev);
}
-static int __init pci_sysfs_init(void)
-{
- struct pci_dev *pdev = NULL;
- struct pci_bus *pbus = NULL;
- int retval;
-
- sysfs_initialized = 1;
- for_each_pci_dev(pdev) {
- retval = pci_create_sysfs_dev_files(pdev);
- if (retval) {
- pci_dev_put(pdev);
- return retval;
- }
- }
-
- while ((pbus = pci_find_next_bus(pbus)))
- pci_create_legacy_files(pbus);
-
- return 0;
-}
-late_initcall(pci_sysfs_init);
-
static struct attribute *pci_dev_dev_attrs[] = {
&dev_attr_boot_vga.attr,
NULL,