diff mbox series

[07/20] PCI: Convert PCI sysfs objects to use BIN_ATTR_ADMIN_RW macro

Message ID 20210416205856.3234481-8-kw@linux.com
State New
Headers show
Series PCI: Convert dynamic sysfs objects into static | expand

Commit Message

Krzysztof Wilczyński April 16, 2021, 8:58 p.m. UTC
Move the PCI "config", "rom" and "vpd" sysfs objects that currently use
an open coded BIN_ATTR macro to hide sensitive information that should
only be accessed by the root user to the new BIN_ATTR_ADMIN_RW macro,
and the BIN_ATTR_RW macro where otherwise appropriate.

Rename the "read" and "write" functions so that they are in the format
that is expected when using new macros as these have specific naming
requirements from the accessor functions.

No functional change intended.

Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 drivers/pci/pci-sysfs.c | 32 ++++++++++++++++----------------
 drivers/pci/vpd.c       | 14 +++++++-------
 2 files changed, 23 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6a8a44d44127..07c3ddd7877e 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -666,9 +666,9 @@  static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(boot_vga);
 
-static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
-			       struct bin_attribute *bin_attr, char *buf,
-			       loff_t off, size_t count)
+static ssize_t config_read(struct file *filp, struct kobject *kobj,
+			   struct bin_attribute *bin_attr, char *buf,
+			   loff_t off, size_t count)
 {
 	struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
 	unsigned int size = 64;
@@ -743,9 +743,9 @@  static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
 	return count;
 }
 
-static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
-				struct bin_attribute *bin_attr, char *buf,
-				loff_t off, size_t count)
+static ssize_t config_write(struct file *filp, struct kobject *kobj,
+			    struct bin_attribute *bin_attr, char *buf,
+			    loff_t off, size_t count)
 {
 	struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
 	unsigned int size = count;
@@ -808,7 +808,7 @@  static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
 
 	return count;
 }
-static BIN_ATTR(config, 0644, pci_read_config, pci_write_config, 0);
+static BIN_ATTR_RW(config, 0);
 
 static struct bin_attribute *pci_dev_config_attrs[] = {
 	&bin_attr_config,
@@ -1243,7 +1243,7 @@  void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }
 #endif
 
 /**
- * pci_write_rom - used to enable access to the PCI ROM display
+ * rom_write - used to enable access to the PCI ROM display
  * @filp: sysfs file
  * @kobj: kernel object handle
  * @bin_attr: struct bin_attribute for this file
@@ -1253,9 +1253,9 @@  void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }
  *
  * writing anything except 0 enables it
  */
-static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
-			     struct bin_attribute *bin_attr, char *buf,
-			     loff_t off, size_t count)
+static ssize_t rom_write(struct file *filp, struct kobject *kobj,
+			 struct bin_attribute *bin_attr, char *buf,
+			 loff_t off, size_t count)
 {
 	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
 
@@ -1268,7 +1268,7 @@  static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
 }
 
 /**
- * pci_read_rom - read a PCI ROM
+ * rom_read - read a PCI ROM
  * @filp: sysfs file
  * @kobj: kernel object handle
  * @bin_attr: struct bin_attribute for this file
@@ -1279,9 +1279,9 @@  static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
  * Put @count bytes starting at @off into @buf from the ROM in the PCI
  * device corresponding to @kobj.
  */
-static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,
-			    struct bin_attribute *bin_attr, char *buf,
-			    loff_t off, size_t count)
+static ssize_t rom_read(struct file *filp, struct kobject *kobj,
+			struct bin_attribute *bin_attr, char *buf,
+			loff_t off, size_t count)
 {
 	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
 	void __iomem *rom;
@@ -1306,7 +1306,7 @@  static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,
 
 	return count;
 }
-static BIN_ATTR(rom, 0600, pci_read_rom, pci_write_rom, 0);
+static BIN_ATTR_ADMIN_RW(rom, 0);
 
 static struct bin_attribute *pci_dev_rom_attrs[] = {
 	&bin_attr_rom,
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index 3707671bc2f1..c8efb9ebdfd7 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -396,9 +396,9 @@  void pci_vpd_release(struct pci_dev *dev)
 	kfree(dev->vpd);
 }
 
-static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj,
-			     struct bin_attribute *bin_attr, char *buf,
-			     loff_t off, size_t count)
+static ssize_t vpd_read(struct file *filp, struct kobject *kobj,
+			struct bin_attribute *bin_attr, char *buf,
+			loff_t off, size_t count)
 {
 	struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
 
@@ -412,9 +412,9 @@  static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj,
 	return pci_read_vpd(dev, off, count, buf);
 }
 
-static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj,
-			      struct bin_attribute *bin_attr, char *buf,
-			      loff_t off, size_t count)
+static ssize_t vpd_write(struct file *filp, struct kobject *kobj,
+			 struct bin_attribute *bin_attr, char *buf,
+			 loff_t off, size_t count)
 {
 	struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj));
 
@@ -427,7 +427,7 @@  static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj,
 
 	return pci_write_vpd(dev, off, count, buf);
 }
-static BIN_ATTR(vpd, 0600, read_vpd_attr, write_vpd_attr, 0);
+static BIN_ATTR_ADMIN_RW(vpd, 0);
 
 static struct bin_attribute *vpd_attrs[] = {
 	&bin_attr_vpd,