[Linux-kernel-mentees] [PATCH v2] PCI: sysfs: Change bus_rescan and dev_rescan to rescan
helgaas at kernel.org
Sat Mar 28 20:06:33 UTC 2020
On Thu, Mar 26, 2020 at 07:35:24AM +0100, Greg KH wrote:
> On Wed, Mar 25, 2020 at 05:10:33PM -0500, Bjorn Helgaas wrote:
> > -static DEVICE_ATTR_WO(dev_rescan);
> > +static struct device_attribute dev_attr_dev_rescan = __ATTR(rescan, 0200, NULL,
> > + dev_rescan_store);
> Oops, this should just be DEVICE_ATTR(), no need for __ATTR() as this
> isn't a kobject-only file.
> So how about:
> static DEVICE_ATTR(rescan, 0200, NULL, dev_rescan_store);
I don' think DEVICE_ATTR() works in this case because it uses the
first argument ("rescan") to build both the C symbol for the
device_attribute struct and the sysfs filename.
There are two instances in this file. The two sysfs "rescan" files
are not a problem, but the two "dev_attr_rescan_name" C symbols *are*.
We could resolve that by putting the bus attributes in a different
source file than the dev attributes, but it doesn't seem worth it now.
I tentatively have the patch below on pci/misc. I dropped the
tested-by and reviewed-by because I didn't want to put words in your
commit bce34ce1806e ("PCI: sysfs: Revert "rescan" file renames")
Author: Kelsey Skunberg <kelsey.skunberg at gmail.com>
Date: Wed Mar 25 09:17:08 2020 -0600
PCI: sysfs: Revert "rescan" file renames
We changed these sysfs filenames:
.../pci_bus/<domain:bus>/rescan -> .../pci_bus/<domain:bus>/bus_rescan
.../<domain:bus:dev.fn>/rescan -> .../<domain:bus:dev.fn>/dev_rescan
and Ruslan reported  that this broke a userspace application.
Revert these name changes so both files are named "rescan" again.
Note that we have to use __ATTR() to assign custom C symbols, i.e.,
"struct device_attribute <symbol>".
[bhelgaas: commit log, use __ATTR() both places so we don't have to rename
Fixes: 8bdfa145f582 ("PCI: sysfs: Define device attributes with DEVICE_ATTR*()")
Fixes: 4e2b79436e4f ("PCI: sysfs: Change DEVICE_ATTR() to DEVICE_ATTR_WO()")
Signed-off-by: Kelsey Skunberg <kelsey.skunberg at gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas at google.com>
Cc: stable at vger.kernel.org # v5.4+
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 13f766db0684..335dd6fbf039 100644
@@ -464,7 +464,8 @@ static ssize_t dev_rescan_store(struct device *dev,
+static struct device_attribute dev_attr_dev_rescan = __ATTR(rescan, 0200, NULL,
static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@@ -501,7 +502,8 @@ static ssize_t bus_rescan_store(struct device *dev,
+static struct device_attribute dev_attr_bus_rescan = __ATTR(rescan, 0200, NULL,
#if defined(CONFIG_PM) && defined(CONFIG_ACPI)
static ssize_t d3cold_allowed_store(struct device *dev,
More information about the Linux-kernel-mentees