[PATCH 14/20] PCI: Rearrange attributes from the pci_dev_reset_attr_group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When new sysfs objects were added to the PCI device over time, the code
that implemented new attributes has been added in many different places
in the pci-sysfs.c file.  This makes it hard to read and also hard to
find relevant code.

Thus, move attributes that are part of the "pci_dev_reset_attr_group"
attribute group to the top of the file.

No functional change intended.

Suggested-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Signed-off-by: Krzysztof Wilczyński <kw@xxxxxxxxx>
---
 drivers/pci/pci-sysfs.c | 90 ++++++++++++++++++++---------------------
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 794c97424456..f18b1728aefa 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -744,6 +744,51 @@ static const struct attribute_group pci_dev_rom_attr_group = {
 	.is_bin_visible = pci_dev_rom_attr_is_visible,
 };
 
+static ssize_t reset_store(struct device *dev,
+			   struct device_attribute *attr, const char *buf,
+			   size_t count)
+{
+	bool reset;
+	struct pci_dev *pdev = to_pci_dev(dev);
+	ssize_t ret;
+
+	if (kstrtobool(buf, &reset) < 0)
+		return -EINVAL;
+
+	if (!reset)
+		return -EINVAL;
+
+	pm_runtime_get_sync(dev);
+	ret = pci_reset_function(pdev);
+	pm_runtime_put(dev);
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+static DEVICE_ATTR_WO(reset);
+
+static struct attribute *pci_dev_reset_attrs[] = {
+	&dev_attr_reset.attr,
+	NULL,
+};
+
+static umode_t pci_dev_reset_attr_is_visible(struct kobject *kobj,
+					     struct attribute *a, int n)
+{
+	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
+
+	if (!pdev->reset_fn)
+		return 0;
+
+	return a->mode;
+}
+
+static const struct attribute_group pci_dev_reset_attr_group = {
+	.attrs = pci_dev_reset_attrs,
+	.is_visible = pci_dev_reset_attr_is_visible,
+};
+
 /*
  * PCI Bus Class Devices
  */
@@ -1406,51 +1451,6 @@ int __weak pci_create_resource_files(struct pci_dev *pdev) { return 0; }
 void __weak pci_remove_resource_files(struct pci_dev *pdev) { return; }
 #endif
 
-static ssize_t reset_store(struct device *dev,
-			   struct device_attribute *attr, const char *buf,
-			   size_t count)
-{
-	bool reset;
-	struct pci_dev *pdev = to_pci_dev(dev);
-	ssize_t ret;
-
-	if (kstrtobool(buf, &reset) < 0)
-		return -EINVAL;
-
-	if (!reset)
-		return -EINVAL;
-
-	pm_runtime_get_sync(dev);
-	ret = pci_reset_function(pdev);
-	pm_runtime_put(dev);
-	if (ret < 0)
-		return ret;
-
-	return count;
-}
-static DEVICE_ATTR_WO(reset);
-
-static struct attribute *pci_dev_reset_attrs[] = {
-	&dev_attr_reset.attr,
-	NULL,
-};
-
-static umode_t pci_dev_reset_attr_is_visible(struct kobject *kobj,
-					     struct attribute *a, int n)
-{
-	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
-
-	if (!pdev->reset_fn)
-		return 0;
-
-	return a->mode;
-}
-
-static const struct attribute_group pci_dev_reset_attr_group = {
-	.attrs = pci_dev_reset_attrs,
-	.is_visible = pci_dev_reset_attr_is_visible,
-};
-
 int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
 {
 	if (!sysfs_initialized)
-- 
2.31.0




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux