Driver core: remove BUS_ATTR()
Subsystems (9)
Greg Kroah-Hartman
maintainercover Driver core: remove BUS_ATTR()
In the quest to get rid of the need to specify any sysfs mode attributes, let's get rid of BUS_ATTR() and move the few remaining users of it over to use the "read write" and "write only" versions of the macro.
Greg Kroah-Hartman (10):
PCI: pci.c: convert to use BUS_ATTR_RW
PCI: pci-sysfs.c: convert to use BUS_ATTR_WO
SCSI: fcoe: convert to use BUS_ATTR_WO
pseries: ibmebus.c: convert to use BUS_ATTR_WO
rapidio: rio-sysfs.c: convert to use BUS_ATTR_WO
block: rbd: convert to use BUS_ATTR_WO and RO driver core: bus: convert to use BUS_ATTR_WO and RW
Documentation: driver core: remove use of BUS_ATTR driver core: drop use of BUS_ATTR()
driver core: remove BUS_ATTR()
Documentation/driver-model/bus.txt | 8 ++--- Documentation/filesystems/sysfs.txt | 4 ++- arch/powerpc/platforms/pseries/ibmebus.c | 10 +++--- drivers/base/bus.c | 20 +++++++---- drivers/block/rbd.c | 45 ++++++++++-------------- drivers/pci/pci-sysfs.c | 5 ++- drivers/pci/pci.c | 7 ++-- drivers/rapidio/rio-sysfs.c | 5 ++- drivers/scsi/fcoe/fcoe_sysfs.c | 4 +-- drivers/scsi/fcoe/fcoe_transport.c | 7 ++-- include/linux/device.h | 2 -- include/scsi/libfcoe.h | 6 ++-- 12 files changed, 56 insertions(+), 67 deletions(-)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 1/10 PCI: pci.c: convert to use BUS_ATTR_RW
We are trying to get rid of BUS_ATTR() and the usage of that in pci.c can be trivially converted to use BUS_ATTR_RW(), so use that instead.
--- drivers/pci/pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/pci.c +3 -4
@@ -6034,19 +6034,18 @@ static ssize_t pci_get_resource_alignment_param(char *buf, size_t size)return count; } -static ssize_t pci_resource_alignment_show (struct bus_type *bus,char *buf) +static ssize_t resource_alignment_show (struct bus_type *bus,char *buf) {return pci_get_resource_alignment_param (buf,PAGE_SIZE ); } -static ssize_t pci_resource_alignment_store (struct bus_type *bus, +static ssize_t resource_alignment_store (struct bus_type *bus,const char *buf,size_t count) {return pci_set_resource_alignment_param (buf, count); } -static BUS_ATTR(resource_alignment, 0644, pci_resource_alignment_show, - pci_resource_alignment_store); +static BUS_ATTR_RW (resource_alignment);static int __init pci_resource_alignment_sysfs_init (void ) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 2/10 PCI: pci-sysfs.c: convert to use BUS_ATTR_WO
In reply to Greg Kroah-HartmanWe are trying to get rid of BUS_ATTR() and the usage of that in pci-sysfs.c can be trivially converted to use BUS_ATTR_WO(), so use that instead.
--- drivers/pci/pci-sysfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pci/pci-sysfs.c +2 -3
@@ -412,8 +412,7 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RW (msi_bus); -static ssize_t bus_rescan_store (struct bus_type *bus,const char *buf, -size_t count) +static ssize_t rescan_store (struct bus_type *bus,const char *buf,size_t count) {unsigned long val;struct pci_bus *b =NULL ;
@@ -429,7 +428,7 @@ static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf, }return count; } -static BUS_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, bus_rescan_store); +static BUS_ATTR_WO (rescan);static struct attribute *pci_bus_attrs[] = { &bus_attr_rescan.attr,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 3/10 SCSI: fcoe: convert to use BUS_ATTR_WO
In reply to Greg Kroah-HartmanWe are trying to get rid of BUS_ATTR() and the usage of that in the fcoe driver can be trivially converted to use BUS_ATTR_WO(), so use that instead.
At the same time remove a unneeded EXPORT_SYMBOL() marking for the sysfs callback function we are renaming, no idea of how that got into the tree...
--- drivers/scsi/fcoe/fcoe_sysfs.c | 4 ++-- drivers/scsi/fcoe/fcoe_transport.c | 7 ++----- include/scsi/libfcoe.h | 6 ++---- 3 files changed, 6 insertions(+), 11 deletions(-)
drivers/scsi/fcoe/fcoe_sysfs.c +2 -2
@@ -671,8 +671,8 @@ static const struct device_type fcoe_fcf_device_type = { .release = fcoe_fcf_device_release, }; -static BUS_ATTR(ctlr_create, S_IWUSR, NULL, fcoe_ctlr_create_store); -static BUS_ATTR(ctlr_destroy, S_IWUSR, NULL, fcoe_ctlr_destroy_store); +static BUS_ATTR_WO (ctlr_create); +static BUS_ATTR_WO (ctlr_destroy);static struct attribute *fcoe_bus_attrs[] = { &bus_attr_ctlr_create.attr,
drivers/scsi/fcoe/fcoe_transport.c +2 -5
@@ -754,8 +754,7 @@ static int libfcoe_device_notification(struct notifier_block *notifier,return NOTIFY_OK ; } -ssize_t fcoe_ctlr_create_store (struct bus_type *bus, -const char *buf,size_t count) +ssize_t ctlr_create_store (struct bus_type *bus,const char *buf,size_t count) {struct net_device *netdev =NULL ;struct fcoe_transport *ft =NULL ;
@@ -817,8 +816,7 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus,return count; } -ssize_t fcoe_ctlr_destroy_store (struct bus_type *bus, -const char *buf,size_t count) +ssize_t ctlr_destroy_store (struct bus_type *bus,const char *buf,size_t count) {int rc = -ENODEV ;struct net_device *netdev =NULL ;
@@ -855,7 +853,6 @@ ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,mutex_unlock (&ft_mutex);return rc; } -EXPORT_SYMBOL (fcoe_ctlr_destroy_store);/** * fcoe_transport_create() - Create a fcoe interface
include/scsi/libfcoe.h +2 -4
@@ -405,10 +405,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);int fcoe_transport_detach (struct fcoe_transport *ft);/* sysfs store handler for ctrl_control interface */ -ssize_t fcoe_ctlr_create_store (struct bus_type *bus, -const char *buf,size_t count); -ssize_t fcoe_ctlr_destroy_store (struct bus_type *bus, -const char *buf,size_t count); +ssize_t ctlr_create_store (struct bus_type *bus,const char *buf,size_t count); +ssize_t ctlr_destroy_store (struct bus_type *bus,const char *buf,size_t count);#endif /* _LIBFCOE_H */
Signature · 1 line
2.20.1
Re: [PATCH 03/10] SCSI: fcoe: convert to use BUS_ATTR_WO
Looks good,
Re: [PATCH 03/10] SCSI: fcoe: convert to use BUS_ATTR_WO
In reply to Greg Kroah-Hartman[scsi list cc added]
Quoted 7 lines · Greg Kroah-Hartman
We are trying to get rid of
BUS_ATTR()and the usage of that in the fcoe driver can be trivially converted to useBUS_ATTR_WO(), so use that instead.At the same time remove a unneeded
EXPORT_SYMBOL()marking for the sysfs callback function we are renaming, no idea of how that got into the tree...
The EXPORT_SYMBOL removal is fine, but
[...]
Quoted 5 lines
include/scsi/libfcoe.h +0
-0@@ -405,10 +405,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);int fcoe_transport_detach (struct fcoe_transport *ft);
include/scsi/libfcoe.h int fcoe_transport_attach(struct fcoe_transport · line 412
Quoted 10 lines
include/scsi/libfcoe.h +2
-4/* sysfs store handler for ctrl_control interface */ -ssize_t fcoe_ctlr_create_store (struct bus_type *bus, -const char *buf,size_t count); -ssize_t fcoe_ctlr_destroy_store (struct bus_type *bus, -const char *buf,size_t count); +ssize_t ctlr_create_store (struct bus_type *bus,const char *buf,size_t count); +ssize_t ctlr_destroy_store (struct bus_type *bus,const char *buf,size_t count);
You're really damaging our prefix namespace here. It looks like the ctlr_ name is a farly recent addition for sysfs (only myra/b) use it in SCSI but it's inviting symbol clashes.
Since the XXX_ATTR_RO seem to be defined with only local file usage in mind, I think we need static functions to shim the problem, like below (provided this is the only instance, because if it isn't, you probably need a XXX_ATTR_WO_prefix() macro)
James
---
drivers/scsi/fcoe/fcoe_sysfs.c +14 -2
@@ -671,8 +671,20 @@ static const struct device_type fcoe_fcf_device_type = { .release = fcoe_fcf_device_release, }; -static BUS_ATTR(ctlr_create, S_IWUSR, NULL, fcoe_ctlr_create_store); -static BUS_ATTR(ctlr_destroy, S_IWUSR, NULL, fcoe_ctlr_destroy_store); +static ssize_t ctlr_create_store (struct bus_type *bus,const char *buf, +size_t count) +{ +return fcoe_ctlr_create_store (bus, buf, count); +} + +static ssize_t ctlr_destroy_store (struct bus_type *bus,const char *buf, +size_t count) +{ +return fcoe_ctlr_destroy_store (bus, buf, count); +} + +static BUS_ATTR_WO (ctlr_create); +static BUS_ATTR_WO (ctlr_destroy);static struct attribute *fcoe_bus_attrs[] = { &bus_attr_ctlr_create.attr,
Hannes Reinecke
maintainerRe: [PATCH 03/10] SCSI: fcoe: convert to use BUS_ATTR_WO
Quoted 19 lines · James Bottomley
[scsi list cc added]
Quoted 7 lines · Greg Kroah-Hartman
We are trying to get rid of
BUS_ATTR()and the usage of that in the fcoe driver can be trivially converted to useBUS_ATTR_WO(), so use that instead.At the same time remove a unneeded
EXPORT_SYMBOL()marking for the sysfs callback function we are renaming, no idea of how that got into the tree...The
EXPORT_SYMBOLremoval is fine, but[...]
Quoted 6 lines
include/scsi/libfcoe.h +0
-0@@ -405,10 +405,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);int fcoe_transport_detach (struct fcoe_transport *ft);
Quoted 14 lines
include/scsi/libfcoe.h int fcoe_transport_attach(struct fcoe_transport · line 412
Quoted 9 lines
include/scsi/libfcoe.h +2
-4/* sysfs store handler for ctrl_control interface */ -ssize_t fcoe_ctlr_create_store (struct bus_type *bus, -const char *buf,size_t count); -ssize_t fcoe_ctlr_destroy_store (struct bus_type *bus, -const char *buf,size_t count); +ssize_t ctlr_create_store (struct bus_type *bus,const char *buf,size_t count); +ssize_t ctlr_destroy_store (struct bus_type *bus,const char *buf,size_t count);You're really damaging our prefix namespace here. It looks like the
ctlr_name is a farly recent addition for sysfs (only myra/b) use it in SCSI but it's inviting symbol clashes.
Hmm. I was under the impression that all sysfs functions from myrb/myrs are local, hence I would not need to prefix them. If this isn't the case I definitely will be fixing them.
But in any case, if possible any sysfs function should be local to the driver; no-one else should ever attempt to use them. And we should be making it so if that's not the case.
Cheers,
Hannes
Greg Kroah-Hartman
maintainerRe: [PATCH 03/10] SCSI: fcoe: convert to use BUS_ATTR_WO
Quoted 34 lines · Hannes Reinecke
Quoted 19 lines · James Bottomley
[scsi list cc added]
Quoted 7 lines · Greg Kroah-Hartman
We are trying to get rid of
BUS_ATTR()and the usage of that in the fcoe driver can be trivially converted to useBUS_ATTR_WO(), so use that instead.At the same time remove a unneeded
EXPORT_SYMBOL()marking for the sysfs callback function we are renaming, no idea of how that got into the tree...The
EXPORT_SYMBOLremoval is fine, but[...]
Quoted 6 lines
include/scsi/libfcoe.h +0
-0@@ -405,10 +405,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);int fcoe_transport_detach (struct fcoe_transport *ft);Quoted 14 lines
include/scsi/libfcoe.h int fcoe_transport_attach(struct fcoe_transport · line 412
Quoted 9 lines
include/scsi/libfcoe.h +2
-4/* sysfs store handler for ctrl_control interface */ -ssize_t fcoe_ctlr_create_store (struct bus_type *bus, -const char *buf,size_t count); -ssize_t fcoe_ctlr_destroy_store (struct bus_type *bus, -const char *buf,size_t count); +ssize_t ctlr_create_store (struct bus_type *bus,const char *buf,size_t count); +ssize_t ctlr_destroy_store (struct bus_type *bus,const char *buf,size_t count);You're really damaging our prefix namespace here. It looks like the
ctlr_name is a farly recent addition for sysfs (only myra/b) use it in SCSI but it's inviting symbol clashes.
Quoted 7 lines
Hmm. I was under the impression that all sysfs functions from myrb/myrs are local, hence I would not need to prefix them.
If this isn't the case I definitely will be fixing them.But in any case, if possible any sysfs function should be local to the driver; no-one else should ever attempt to use them.
And we should be making it so if that's not the case.
This is all in the same "driver", just that the driver is spread out over multiple files.
James, thanks for the fixup, I'll go respin this and break this up into two patches and resend in a bit.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 4/10 pseries: ibmebus.c: convert to use BUS_ATTR_WO
In reply to Greg Kroah-HartmanWe are trying to get rid of BUS_ATTR() and the usage of that in ibmebus.c can be trivially converted to use BUS_ATTR_WO(), so use that instead.
--- arch/powerpc/platforms/pseries/ibmebus.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/powerpc/platforms/pseries/ibmebus.c +4 -6
@@ -261,8 +261,7 @@ static char *ibmebus_chomp(const char *in, size_t count)return out; } -static ssize_t ibmebus_store_probe (struct bus_type *bus, -const char *buf,size_t count) +static ssize_t probe_store (struct bus_type *bus,const char *buf,size_t count) {struct device_node *dn =NULL ;struct device *dev;
@@ -298,10 +297,9 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,return rc;return count; } -static BUS_ATTR(probe, 0200, NULL, ibmebus_store_probe); +static BUS_ATTR_WO (probe); -static ssize_t ibmebus_store_remove (struct bus_type *bus, -const char *buf,size_t count) +static ssize_t remove_store (struct bus_type *bus,const char *buf,size_t count) {struct device *dev;char *path;
@@ -325,7 +323,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,return -ENODEV ; } } -static BUS_ATTR(remove, 0200, NULL, ibmebus_store_remove); +static BUS_ATTR_WO (remove);static struct attribute *ibmbus_bus_attrs[] = { &bus_attr_probe.attr,
Signature · 1 line
2.20.1
Re: [PATCH 04/10] pseries: ibmebus.c: convert to use BUS_ATTR_WO
Quoted 4 lines · Greg Kroah-Hartman
We are trying to get rid of
BUS_ATTR()and the usage of that inibmebus.ccan be trivially converted to useBUS_ATTR_WO(), so use that instead.
Quoted 8 lines
Cc Benjamin Herrenschmidt <[email protected]>Cc Paul Mackerras <[email protected]>Cc Michael Ellerman <[email protected]>Cc Tyrel Datwyler <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/powerpc/platforms/pseries/ibmebus.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
LGTM.
cheers
Quoted 38 lines
arch/powerpc/platforms/pseries/ibmebus.c +4
-6@@ -261,8 +261,7 @@ static char *ibmebus_chomp(const char *in, size_t count)return out; } -static ssize_t ibmebus_store_probe (struct bus_type *bus, -const char *buf,size_t count) +static ssize_t probe_store (struct bus_type *bus,const char *buf,size_t count) {struct device_node *dn =NULL ;struct device *dev;@@ -298,10 +297,9 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,return rc;return count; } -static BUS_ATTR(probe, 0200, NULL, ibmebus_store_probe); +static BUS_ATTR_WO (probe); -static ssize_t ibmebus_store_remove (struct bus_type *bus, -const char *buf,size_t count) +static ssize_t remove_store (struct bus_type *bus,const char *buf,size_t count) {struct device *dev;char *path;@@ -325,7 +323,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,return -ENODEV ; } } -static BUS_ATTR(remove, 0200, NULL, ibmebus_store_remove); +static BUS_ATTR_WO (remove);static struct attribute *ibmbus_bus_attrs[] = { &bus_attr_probe.attr,Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 5/10 rapidio: rio-sysfs.c: convert to use BUS_ATTR_WO
In reply to Greg Kroah-HartmanWe are trying to get rid of BUS_ATTR() and the usage of that in rio-sysfs.c can be trivially converted to use BUS_ATTR_WO(), so use that instead.
--- drivers/rapidio/rio-sysfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/rapidio/rio-sysfs.c +2 -3
@@ -290,8 +290,7 @@ const struct attribute_group *rio_dev_groups[] = { NULL, }; -static ssize_t bus_scan_store (struct bus_type *bus,const char *buf, -size_t count) +static ssize_t scan_store (struct bus_type *bus,const char *buf,size_t count) {long val;int rc;
@@ -314,7 +313,7 @@ static ssize_t bus_scan_store(struct bus_type *bus, const char *buf,return rc; } -static BUS_ATTR(scan, (S_IWUSR|S_IWGRP), NULL, bus_scan_store); +static BUS_ATTR_WO (scan);static struct attribute *rio_bus_attrs[] = { &bus_attr_scan.attr,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 6/10 block: rbd: convert to use BUS_ATTR_WO and RO
In reply to Greg Kroah-HartmanWe are trying to get rid of BUS_ATTR() and the usage of that in rbd.c can be trivially converted to use BUS_ATTR_WO and RO, so use those macros instead.
--- drivers/block/rbd.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-)
drivers/block/rbd.c +19 -26
@@ -428,14 +428,13 @@ static bool single_major = true;module_param (single_major, bool,0444 );MODULE_PARM_DESC (single_major,"Use a single major number for all rbd devices (default: true)" ); -static ssize_t rbd_add (struct bus_type *bus,const char *buf, -size_t count); -static ssize_t rbd_remove (struct bus_type *bus,const char *buf, -size_t count); -static ssize_t rbd_add_single_major (struct bus_type *bus,const char *buf, -size_t count); -static ssize_t rbd_remove_single_major (struct bus_type *bus,const char *buf, -size_t count); +static ssize_t add_store (struct bus_type *bus,const char *buf,size_t count); +static ssize_t remove_store (struct bus_type *bus,const char *buf, +size_t count); +static ssize_t add_single_major_store (struct bus_type *bus,const char *buf, +size_t count); +static ssize_t remove_single_major_store (struct bus_type *bus,const char *buf, +size_t count);static int rbd_dev_image_probe (struct rbd_device *rbd_dev,int depth);static int rbd_dev_id_to_minor (int dev_id)
@@ -464,16 +463,16 @@ static bool rbd_is_lock_owner(struct rbd_device *rbd_dev)return is_lock_owner; } -static ssize_t rbd_supported_features_show (struct bus_type *bus,char *buf) +static ssize_t supported_features_show (struct bus_type *bus,char *buf) {return sprintf (buf,"0x%llx\n" ,RBD_FEATURES_SUPPORTED ); } -static BUS_ATTR(add, 0200, NULL, rbd_add); -static BUS_ATTR(remove, 0200, NULL, rbd_remove); -static BUS_ATTR(add_single_major, 0200, NULL, rbd_add_single_major); -static BUS_ATTR(remove_single_major, 0200, NULL, rbd_remove_single_major); -static BUS_ATTR(supported_features, 0444, rbd_supported_features_show, NULL); +static BUS_ATTR_WO (add); +static BUS_ATTR_WO (remove); +static BUS_ATTR_WO (add_single_major); +static BUS_ATTR_WO (remove_single_major); +static BUS_ATTR_RO (supported_features);static struct attribute *rbd_bus_attrs[] = { &bus_attr_add.attr,
@@ -5934,9 +5933,7 @@ static ssize_t do_rbd_add(struct bus_type *bus, goto out; } -static ssize_t rbd_add (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t add_store (struct bus_type *bus,const char *buf,size_t count) {if (single_major)return -EINVAL ;
@@ -5944,9 +5941,8 @@ static ssize_t rbd_add(struct bus_type *bus,return do_rbd_add (bus, buf, count); } -static ssize_t rbd_add_single_major (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t add_single_major_store (struct bus_type *bus,const char *buf, +size_t count) {return do_rbd_add (bus, buf, count); }
@@ -6050,9 +6046,7 @@ static ssize_t do_rbd_remove(struct bus_type *bus,return count; } -static ssize_t rbd_remove (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t remove_store (struct bus_type *bus,const char *buf,size_t count) {if (single_major)return -EINVAL ;
@@ -6060,9 +6054,8 @@ static ssize_t rbd_remove(struct bus_type *bus,return do_rbd_remove (bus, buf, count); } -static ssize_t rbd_remove_single_major (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t remove_single_major_store (struct bus_type *bus,const char *buf, +size_t count) {return do_rbd_remove (bus, buf, count); }
Signature · 1 line
2.20.1
Re: [PATCH 06/10] block: rbd: convert to use BUS_ATTR_WO and RO
Quoted 99 lines · Greg Kroah-Hartman
We are trying to get rid of
BUS_ATTR()and the usage of that inrbd.ccan be trivially converted to useBUS_ATTR_WOand RO, so use those macros instead.Cc Ilya Dryomov <[email protected]>Cc Sage Weil <[email protected]>Cc Alex Elder <[email protected]>Cc Jens Axboe <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/block/rbd.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-)drivers/block/rbd.c +17
-23@@ -428,14 +428,13 @@ static bool single_major = true;module_param (single_major, bool,0444 );MODULE_PARM_DESC (single_major,"Use a single major number for all rbd devices (default: true)" ); -static ssize_t rbd_add (struct bus_type *bus,const char *buf, -size_t count); -static ssize_t rbd_remove (struct bus_type *bus,const char *buf, -size_t count); -static ssize_t rbd_add_single_major (struct bus_type *bus,const char *buf, -size_t count); -static ssize_t rbd_remove_single_major (struct bus_type *bus,const char *buf, -size_t count); +static ssize_t add_store (struct bus_type *bus,const char *buf,size_t count); +static ssize_t remove_store (struct bus_type *bus,const char *buf, +size_t count); +static ssize_t add_single_major_store (struct bus_type *bus,const char *buf, +size_t count); +static ssize_t remove_single_major_store (struct bus_type *bus,const char *buf, +size_t count);static int rbd_dev_image_probe (struct rbd_device *rbd_dev,int depth);static int rbd_dev_id_to_minor (int dev_id)@@ -464,16 +463,16 @@ static bool rbd_is_lock_owner(struct rbd_device *rbd_dev)return is_lock_owner; } -static ssize_t rbd_supported_features_show (struct bus_type *bus,char *buf) +static ssize_t supported_features_show (struct bus_type *bus,char *buf) {return sprintf (buf,"0x%llx\n" ,RBD_FEATURES_SUPPORTED ); } -static BUS_ATTR(add, 0200, NULL, rbd_add); -static BUS_ATTR(remove, 0200, NULL, rbd_remove); -static BUS_ATTR(add_single_major, 0200, NULL, rbd_add_single_major); -static BUS_ATTR(remove_single_major, 0200, NULL, rbd_remove_single_major); -static BUS_ATTR(supported_features, 0444, rbd_supported_features_show, NULL); +static BUS_ATTR_WO (add); +static BUS_ATTR_WO (remove); +static BUS_ATTR_WO (add_single_major); +static BUS_ATTR_WO (remove_single_major); +static BUS_ATTR_RO (supported_features);static struct attribute *rbd_bus_attrs[] = { &bus_attr_add.attr,@@ -5934,9 +5933,7 @@ static ssize_t do_rbd_add(struct bus_type *bus, goto out; } -static ssize_t rbd_add (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t add_store (struct bus_type *bus,const char *buf,size_t count) {if (single_major)return -EINVAL ;@@ -5944,9 +5941,8 @@ static ssize_t rbd_add(struct bus_type *bus,return do_rbd_add (bus, buf, count); } -static ssize_t rbd_add_single_major (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t add_single_major_store (struct bus_type *bus,const char *buf, +size_t count) {return do_rbd_add (bus, buf, count); }@@ -6050,9 +6046,7 @@ static ssize_t do_rbd_remove(struct bus_type *bus,return count; } -static ssize_t rbd_remove (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t remove_store (struct bus_type *bus,const char *buf,size_t count) {if (single_major)return -EINVAL ;@@ -6060,9 +6054,8 @@ static ssize_t rbd_remove(struct bus_type *bus,return do_rbd_remove (bus, buf, count);
drivers/block/rbd.c static ssize_t rbd_remove(struct bus_type *bus, · line 6061
Quoted 10 lines
drivers/block/rbd.c +2
-3} -static ssize_t rbd_remove_single_major (struct bus_type *bus, -const char *buf, -size_t count) +static ssize_t remove_single_major_store (struct bus_type *bus,const char *buf, +size_t count) {return do_rbd_remove (bus, buf, count); }
Thanks,
Ilya
Greg Kroah-Hartman
maintainerPATCH 7/10 driver core: bus: convert to use BUS_ATTR_WO and RW
In reply to Greg Kroah-HartmanWe are trying to get rid of BUS_ATTR() and the usage of that in bus.c can be trivially converted to use BUS_ATTR_WO and RW, so use those macros instead.
--- drivers/base/bus.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/base/bus.c +5 -6
@@ -233,12 +233,12 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, }static DRIVER_ATTR_WO (bind); -static ssize_t show_drivers_autoprobe (struct bus_type *bus,char *buf) +static ssize_t drivers_autoprobe_show (struct bus_type *bus,char *buf) {return sprintf (buf,"%d\n" , bus->p->drivers_autoprobe); } -static ssize_t store_drivers_autoprobe (struct bus_type *bus, +static ssize_t drivers_autoprobe_store (struct bus_type *bus,const char *buf,size_t count) {if (buf[0 ] =='0' )
@@ -248,7 +248,7 @@ static ssize_t store_drivers_autoprobe(struct bus_type *bus,return count; } -static ssize_t store_drivers_probe (struct bus_type *bus, +static ssize_t drivers_probe_store (struct bus_type *bus,const char *buf,size_t count) {struct device *dev;
@@ -583,9 +583,8 @@ static void remove_bind_files(struct device_driver *drv)driver_remove_file (drv, &driver_attr_unbind); } -static BUS_ATTR(drivers_probe, S_IWUSR, NULL, store_drivers_probe); -static BUS_ATTR(drivers_autoprobe, S_IWUSR | S_IRUGO, - show_drivers_autoprobe, store_drivers_autoprobe); +static BUS_ATTR_WO (drivers_probe); +static BUS_ATTR_RW (drivers_autoprobe);static int add_probe_files (struct bus_type *bus) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 8/10 Documentation: driver core: remove use of BUS_ATTR
In reply to Greg Kroah-HartmanWe are getting rid of the "raw" BUS_ATTR() macro, so fix up the documentation to not refer to it anymore.
--- Documentation/driver-model/bus.txt | 8 ++++---- Documentation/filesystems/sysfs.txt | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-)
Documentation/driver-model/bus.txt +4 -4
@@ -124,11 +124,11 @@ struct bus_attribute { ssize_t (*store)(struct bus_type *, const char * buf, size_t count); }; -Bus drivers can export attributes using the BUS_ATTR macro that works -similarly to the DEVICE_ATTR macro for devices. For example, a definition -like this: +Bus drivers can export attributes using the BUS_ATTR_RW macro that works +similarly to the DEVICE_ATTR_RW macro for devices. For example, a +definition like this: -static BUS_ATTR(debug,0644,show_debug,store_debug); +static BUS_ATTR_RW(debug); is equivalent to declaring:
Documentation/filesystems/sysfs.txt +3 -1
@@ -344,7 +344,9 @@ struct bus_attribute { Declaring: -BUS_ATTR(_name, _mode, _show, _store) +static BUS_ATTR_RW(name); +static BUS_ATTR_RO(name); +static BUS_ATTR_WO(name); Creation/Removal:
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 9/10 driver core: drop use of BUS_ATTR()
In reply to Greg Kroah-HartmanWe are trying to get rid of BUS_ATTR() so drop the last user of it from the tree. We had to "open code" it in order to prevent a function name conflict due to the use of DEVICE_ATTR_WO() earlier in the file :(
--- drivers/base/bus.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/base/bus.c +8 -1
@@ -830,7 +830,14 @@ static ssize_t bus_uevent_store(struct bus_type *bus,kobject_synth_uevent (&bus->p->subsys.kobj, buf, count);return count; } -static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); +/* +* "open code" the old BUS_ATTR() macro here. We want to use BUS_ATTR_WO() +* here, but can not use it as earlier in the file we have +* DEVICE_ATTR_WO(uevent), which would cause a clash with the with the store +* function name. +*/ +static struct bus_attribute bus_attr_uevent =__ATTR (uevent,S_IWUSR ,NULL , + bus_uevent_store);/** * bus_register - register a driver-core subsystem
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 10/10 driver core: remove BUS_ATTR()
In reply to Greg Kroah-HartmanThere are now no in-kernel users of BUS_ATTR() so drop it from device.h
Everyone should use BUS_ATTR_RO/RW/WO() from now on.
--- include/linux/device.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/device.h +0 -2
@@ -49,8 +49,6 @@ struct bus_attribute {ssize_t (*store)(struct bus_type *bus,const char *buf,size_t count); }; -#define BUS_ATTR (_name, _mode, _show, _store) \ - struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)#define BUS_ATTR_RW (_name) \ struct bus_attribute bus_attr_##_name = __ATTR_RW(_name)#define BUS_ATTR_RO (_name) \
Signature · 1 line
2.20.1