linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Krzysztof Wilczyński" <kw@linux.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: "Pali Rohár" <pali@kernel.org>,
	"Oliver O'Halloran" <oohall@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Joe Perches" <joe@perches.com>,
	"Dan Williams" <dan.j.williams@intel.com>,
	"Mauro Carvalho Chehab" <mchehab+huawei@kernel.org>,
	"David Sterba" <dsterba@suse.com>,
	linux-pci@vger.kernel.org
Subject: [PATCH 15/20] PCI: Rearrange attributes from the pci_dev_attr_group
Date: Fri, 16 Apr 2021 20:58:51 +0000	[thread overview]
Message-ID: <20210416205856.3234481-16-kw@linux.com> (raw)
In-Reply-To: <20210416205856.3234481-1-kw@linux.com>

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_attr_group"
attribute group to the top of the file.

No functional change intended.

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 drivers/pci/pci-sysfs.c | 74 ++++++++++++++++++++---------------------
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index f18b1728aefa..fd89a391b1c7 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -789,6 +789,43 @@ static const struct attribute_group pci_dev_reset_attr_group = {
 	.is_visible = pci_dev_reset_attr_is_visible,
 };
 
+static ssize_t boot_vga_show(struct device *dev,
+			     struct device_attribute *attr, char *buf)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+	struct pci_dev *vga_dev = vga_default_device();
+
+	if (vga_dev)
+		return sysfs_emit(buf, "%u\n", (pdev == vga_dev));
+
+	return sysfs_emit(buf, "%u\n",
+			  !!(pdev->resource[PCI_ROM_RESOURCE].flags &
+			     IORESOURCE_ROM_SHADOW));
+}
+static DEVICE_ATTR_RO(boot_vga);
+
+static struct attribute *pci_dev_dev_attrs[] = {
+	&dev_attr_boot_vga.attr,
+	NULL,
+};
+
+static umode_t pci_dev_attr_is_visible(struct kobject *kobj,
+				       struct attribute *a, int n)
+{
+	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
+
+	if (a == &dev_attr_boot_vga.attr)
+		if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
+			return 0;
+
+	return a->mode;
+}
+
+static const struct attribute_group pci_dev_attr_group = {
+	.attrs = pci_dev_dev_attrs,
+	.is_visible = pci_dev_attr_is_visible,
+};
+
 /*
  * PCI Bus Class Devices
  */
@@ -1012,21 +1049,6 @@ const struct attribute_group *pcibus_groups[] = {
 	NULL,
 };
 
-static ssize_t boot_vga_show(struct device *dev,
-			     struct device_attribute *attr, char *buf)
-{
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct pci_dev *vga_dev = vga_default_device();
-
-	if (vga_dev)
-		return sysfs_emit(buf, "%u\n", (pdev == vga_dev));
-
-	return sysfs_emit(buf, "%u\n",
-			  !!(pdev->resource[PCI_ROM_RESOURCE].flags &
-			     IORESOURCE_ROM_SHADOW));
-}
-static DEVICE_ATTR_RO(boot_vga);
-
 #ifdef HAVE_PCI_LEGACY
 /**
  * pci_read_legacy_io - read byte(s) from legacy I/O port space
@@ -1495,23 +1517,6 @@ static int __init pci_sysfs_init(void)
 }
 late_initcall(pci_sysfs_init);
 
-static struct attribute *pci_dev_dev_attrs[] = {
-	&dev_attr_boot_vga.attr,
-	NULL,
-};
-
-static umode_t pci_dev_attr_is_visible(struct kobject *kobj,
-				       struct attribute *a, int n)
-{
-	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
-
-	if (a == &dev_attr_boot_vga.attr)
-		if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
-			return 0;
-
-	return a->mode;
-}
-
 static struct attribute *pci_dev_hp_attrs[] = {
 	&dev_attr_remove.attr,
 	&dev_attr_dev_rescan.attr,
@@ -1571,11 +1576,6 @@ static const struct attribute_group pci_dev_hp_attr_group = {
 	.is_visible = pci_dev_hp_attr_is_visible,
 };
 
-static const struct attribute_group pci_dev_attr_group = {
-	.attrs = pci_dev_dev_attrs,
-	.is_visible = pci_dev_attr_is_visible,
-};
-
 static const struct attribute_group pci_bridge_attr_group = {
 	.attrs = pci_bridge_attrs,
 	.is_visible = pci_bridge_attr_is_visible,
-- 
2.31.0


  parent reply	other threads:[~2021-04-16 20:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 20:58 [PATCH 00/20] PCI: Convert dynamic sysfs objects into static Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 01/20] PCI: Convert dynamic "config" sysfs object " Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 02/20] PCI: Convert dynamic "rom" " Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 03/20] PCI: Convert dynamic "reset" " Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 04/20] PCI/VPD: Convert dynamic "vpd" " Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 05/20] PCI: Convert dynamic "index" and "label" sysfs objects " Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 06/20] sysfs: Introduce BIN_ATTR_ADMIN_RO and BIN_ATTR_ADMIN_RW Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 07/20] PCI: Convert PCI sysfs objects to use BIN_ATTR_ADMIN_RW macro Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 08/20] PCI: Move to kstrtobool() to handle user input Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 09/20] PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functions Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 10/20] PCI: Update style to be more consistent Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 11/20] PCI: Rearrange attributes from the pci_dev_group Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 12/20] PCI: Rearrange attributes from the pci_dev_config_attr_group Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 13/20] PCI: Rearrange attributes from the pci_dev_rom_attr_group Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 14/20] PCI: Rearrange attributes from the pci_dev_reset_attr_group Krzysztof Wilczyński
2021-04-16 20:58 ` Krzysztof Wilczyński [this message]
2021-04-16 20:58 ` [PATCH 16/20] PCI: Rearrange attributes from the pci_dev_hp_attr_group Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 17/20] PCI: Rearrange attributes from the pci_bridge_attr_group Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 18/20] PCI: Rearrange attributes from the pcie_dev_attr_group Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 19/20] PCI: Rearrange attributes from the pci_bus_group Krzysztof Wilczyński
2021-04-16 20:58 ` [PATCH 20/20] PCI: Rearrange attributes from the pcibus_group Krzysztof Wilczyński

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210416205856.3234481-16-kw@linux.com \
    --to=kw@linux.com \
    --cc=bhelgaas@google.com \
    --cc=dan.j.williams@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dsterba@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=oohall@gmail.com \
    --cc=pali@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).