Skip to contentSkip to conversation

fpga: altera-cvp: remove DRIVER_ATTR() usage

PATCH In review Greg Kroah-Hartman 3 participants 7 messages Sep 18, 2017 – Sep 19, 2017

Subsystems (3)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

PATCH 1/2 fpga: altera-cvp: remove DRIVER_ATTR() usage

It's better to be explicit and use the DRIVER_ATTR_RW() macro when defining a driver's sysfs file.

This is part of a series to drop DRIVER_ATTR() from the tree entirely.

---
 drivers/fpga/altera-cvp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/fpga/altera-cvp.c +3 -3
index 08629ee69d11..00e73d28077c 100644
@@ -361,12 +361,12 @@ static const struct fpga_manager_ops altera_cvp_ops = {
 	.write_complete	= altera_cvp_write_complete,
 };
 
-static ssize_t show_chkcfg(struct device_driver *dev, char *buf)
+static ssize_t chkcfg_show(struct device_driver *dev, char *buf)
 {
 	return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg);
 }
 
-static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
+static ssize_t chkcfg_store(struct device_driver *drv, const char *buf,
 			    size_t count)
 {
 	int ret;
@@ -378,7 +378,7 @@ static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
 	return count;
 }
 
-static DRIVER_ATTR(chkcfg, 0600, show_chkcfg, store_chkcfg);
+static DRIVER_ATTR_RW(chkcfg);
 
 static int altera_cvp_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *dev_id);
Signature · 1 line
2.14.1
author maintainer
#1 lore raw

PATCH 2/2 driver core: remove DRIVER_ATTR

DRIVER_ATTR is no longer in use, and driver authors should be using DRIVER_ATTR_RW() or DRIVER_ATTR_RO() or DRIVER_ATTR_WO() instead in order to always get the permissions correct. So remove it so that no one can use it anymore.

---
 Documentation/driver-model/driver.txt | 7 ++++---
 Documentation/filesystems/sysfs.txt   | 3 ++-
 include/linux/device.h                | 2 --
 3 files changed, 6 insertions(+), 6 deletions(-)
Documentation/driver-model/driver.txt +4 -3
index 4421135826a2..d661e6f7e6a0 100644
@@ -196,12 +196,13 @@ struct driver_attribute {
 };
 
 Device drivers can export attributes via their sysfs directories. 
-Drivers can declare attributes using a DRIVER_ATTR macro that works
-identically to the DEVICE_ATTR macro. 
+Drivers can declare attributes using a DRIVER_ATTR_RW and DRIVER_ATTR_RO
+macro that works identically to the DEVICE_ATTR_RW and DEVICE_ATTR_RO
+macros.
 
 Example:
 
-DRIVER_ATTR(debug,0644,show_debug,store_debug);
+DRIVER_ATTR_RW(debug);
 
 This is equivalent to declaring:
 
Documentation/filesystems/sysfs.txt +2 -1
index 24da7b32c489..9a3658cc399e 100644
@@ -366,7 +366,8 @@ struct driver_attribute {
 
 Declaring:
 
-DRIVER_ATTR(_name, _mode, _show, _store)
+DRIVER_ATTR_RO(_name)
+DRIVER_ATTR_RW(_name)
 
 Creation/Removal:
 
include/linux/device.h +0 -2
index c6f27207dbe8..2bc70ddda09b 100644
@@ -307,8 +307,6 @@ struct driver_attribute {
 			 size_t count);
 };
 
-#define DRIVER_ATTR(_name, _mode, _show, _store) \
-	struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
 #define DRIVER_ATTR_RW(_name) \
 	struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
 #define DRIVER_ATTR_RO(_name) \
Signature · 1 line
2.14.1
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] driver core: remove DRIVER_ATTR

Quoted 7 lines · Greg Kroah-Hartman

DRIVER_ATTR is no longer in use, and driver authors should be using DRIVER_ATTR_RW() or DRIVER_ATTR_RO() or DRIVER_ATTR_WO() instead in order to always get the permissions correct. So remove it so that no one can use it anymore.

Quoted 57 lines
---
 Documentation/driver-model/driver.txt | 7 ++++---
 Documentation/filesystems/sysfs.txt   | 3 ++-
 include/linux/device.h                | 2 --
 3 files changed, 6 insertions(+), 6 deletions(-)
Documentation/driver-model/driver.txt +4 -3
index 4421135826a2..d661e6f7e6a0 100644
@@ -196,12 +196,13 @@ struct driver_attribute {
 };
 
 Device drivers can export attributes via their sysfs directories. 
-Drivers can declare attributes using a DRIVER_ATTR macro that works
-identically to the DEVICE_ATTR macro. 
+Drivers can declare attributes using a DRIVER_ATTR_RW and DRIVER_ATTR_RO
+macro that works identically to the DEVICE_ATTR_RW and DEVICE_ATTR_RO
+macros.
 
 Example:
 
-DRIVER_ATTR(debug,0644,show_debug,store_debug);
+DRIVER_ATTR_RW(debug);
 
 This is equivalent to declaring:
 
Documentation/filesystems/sysfs.txt +2 -1
index 24da7b32c489..9a3658cc399e 100644
@@ -366,7 +366,8 @@ struct driver_attribute {
 
 Declaring:
 
-DRIVER_ATTR(_name, _mode, _show, _store)
+DRIVER_ATTR_RO(_name)
+DRIVER_ATTR_RW(_name)
 
 Creation/Removal:
 
include/linux/device.h +0 -2
index c6f27207dbe8..2bc70ddda09b 100644
@@ -307,8 +307,6 @@ struct driver_attribute {
 			 size_t count);
 };
 
-#define DRIVER_ATTR(_name, _mode, _show, _store) \
-	struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
 #define DRIVER_ATTR_RW(_name) \
 	struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
 #define DRIVER_ATTR_RO(_name) \
Signature · 1 line
2.14.1

Thanks,

Moritz

Acked-by
#3 lore raw

Re: [PATCH 2/2] driver core: remove DRIVER_ATTR

Quoted 9 lines · Moritz Fischer
Quoted 7 lines · Greg Kroah-Hartman

DRIVER_ATTR is no longer in use, and driver authors should be using DRIVER_ATTR_RW() or DRIVER_ATTR_RO() or DRIVER_ATTR_WO() instead in order to always get the permissions correct. So remove it so that no one can use it anymore.

Quoted 61 lines
Quoted 55 lines
---
 Documentation/driver-model/driver.txt | 7 ++++---
 Documentation/filesystems/sysfs.txt   | 3 ++-
 include/linux/device.h                | 2 --
 3 files changed, 6 insertions(+), 6 deletions(-)
Documentation/driver-model/driver.txt +4 -3
index 4421135826a2..d661e6f7e6a0 100644
@@ -196,12 +196,13 @@ struct driver_attribute {
 };
 
 Device drivers can export attributes via their sysfs directories.
-Drivers can declare attributes using a DRIVER_ATTR macro that works
-identically to the DEVICE_ATTR macro.
+Drivers can declare attributes using a DRIVER_ATTR_RW and DRIVER_ATTR_RO
+macro that works identically to the DEVICE_ATTR_RW and DEVICE_ATTR_RO
+macros.
 
 Example:
 
-DRIVER_ATTR(debug,0644,show_debug,store_debug);
+DRIVER_ATTR_RW(debug);
 
 This is equivalent to declaring:
 
Documentation/filesystems/sysfs.txt +2 -1
index 24da7b32c489..9a3658cc399e 100644
@@ -366,7 +366,8 @@ struct driver_attribute {
 
 Declaring:
 
-DRIVER_ATTR(_name, _mode, _show, _store)
+DRIVER_ATTR_RO(_name)
+DRIVER_ATTR_RW(_name)
 
 Creation/Removal:
 
include/linux/device.h +0 -3
index c6f27207dbe8..2bc70ddda09b 100644
@@ -307,8 +307,6 @@ struct driver_attribute {
                       size_t count);
 };
 
-#define DRIVER_ATTR(_name, _mode, _show, _store) \
-     struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
 #define DRIVER_ATTR_RW(_name) \
      struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
 #define DRIVER_ATTR_RO(_name) \
--
Quoted 2 lines

2.14.1

Thanks,

Moritz

maintainer Acked-by on v1 1/2
#4 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

It's better to be explicit and use the DRIVER_ATTR_RW() macro when defining a driver's sysfs file.

This is part of a series to drop DRIVER_ATTR() from the tree entirely.

Quoted 35 lines
---
 drivers/fpga/altera-cvp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/fpga/altera-cvp.c +3 -3
index 08629ee69d11..00e73d28077c 100644
@@ -361,12 +361,12 @@ static const struct fpga_manager_ops altera_cvp_ops = {
 	.write_complete	= altera_cvp_write_complete,
 };
 
-static ssize_t show_chkcfg(struct device_driver *dev, char *buf)
+static ssize_t chkcfg_show(struct device_driver *dev, char *buf)
 {
 	return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg);
 }
 
-static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
+static ssize_t chkcfg_store(struct device_driver *drv, const char *buf,
 			    size_t count)
 {
 	int ret;
@@ -378,7 +378,7 @@ static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
 	return count;
 }
 
-static DRIVER_ATTR(chkcfg, 0600, show_chkcfg, store_chkcfg);
+static DRIVER_ATTR_RW(chkcfg);
 
 static int altera_cvp_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *dev_id);
Signature · 1 line
2.14.1
Acked-by
#5 lore raw
Quoted 11 lines · Moritz Fischer
Quoted 9 lines · Greg Kroah-Hartman

It's better to be explicit and use the DRIVER_ATTR_RW() macro when defining a driver's sysfs file.

This is part of a series to drop DRIVER_ATTR() from the tree entirely.

Quoted 35 lines
Quoted 35 lines
---
 drivers/fpga/altera-cvp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/fpga/altera-cvp.c +3 -4
index 08629ee69d11..00e73d28077c 100644
@@ -361,12 +361,12 @@ static const struct fpga_manager_ops altera_cvp_ops = {
      .write_complete = altera_cvp_write_complete,
 };
 
-static ssize_t show_chkcfg(struct device_driver *dev, char *buf)
+static ssize_t chkcfg_show(struct device_driver *dev, char *buf)
 {
      return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg);
 }
 
-static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
+static ssize_t chkcfg_store(struct device_driver *drv, const char *buf,
                          size_t count)
 {
      int ret;
@@ -378,7 +378,7 @@ static ssize_t store_chkcfg(struct device_driver *drv, const char *buf,
      return count;
 }
 
-static DRIVER_ATTR(chkcfg, 0600, show_chkcfg, store_chkcfg);
+static DRIVER_ATTR_RW(chkcfg);
 
 static int altera_cvp_probe(struct pci_dev *pdev,
                          const struct pci_device_id *dev_id);
--

2.14.1

author maintainer
#6 lore raw
Quoted 5 lines · Alan Tull
Quoted 4 lines · Moritz Fischer
Quoted 3 lines · Greg Kroah-Hartman

It's better to be explicit and use the DRIVER_ATTR_RW() macro when defining a driver's sysfs file.

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines

This is part of a series to drop DRIVER_ATTR() from the tree entirely.

Thanks to both of you for the review.

greg k-h