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(-)
--
2.20.1
We 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.
Cc: Bjorn Helgaas <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/pci/pci-sysfs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 9ecfe13157c0..25794c27c7a4 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -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,
--
2.20.1
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.
Cc: Bjorn Helgaas <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/pci/pci.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c9d8e3c837de..fda84538de79 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -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)
{
--
2.20.1
We 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 :(
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/base/bus.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index f10d56c61a46..575bd6d752bd 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -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
--
2.20.1
We are getting rid of the "raw" BUS_ATTR() macro, so fix up the
documentation to not refer to it anymore.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Documentation/driver-model/bus.txt | 8 ++++----
Documentation/filesystems/sysfs.txt | 4 +++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/Documentation/driver-model/bus.txt b/Documentation/driver-model/bus.txt
index b577a45b93ea..c247b488a567 100644
--- a/Documentation/driver-model/bus.txt
+++ b/Documentation/driver-model/bus.txt
@@ -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:
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt
index a1426cabcef1..41411b0c60a3 100644
--- a/Documentation/filesystems/sysfs.txt
+++ b/Documentation/filesystems/sysfs.txt
@@ -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:
--
2.20.1
There 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.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
include/linux/device.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index 1b25c7a43f4c..1e8ae731fb97 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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) \
--
2.20.1
We 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...
Cc: Johannes Thumshirn <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
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(-)
diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index 5c8310bade61..3c23b2624bd4 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -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,
diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index f4909cd206d3..9edf82efda15 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -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
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index cb8a273732cf..44536f095681 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -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 */
--
2.20.1
We 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.
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(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 8e5140bbf241..d871d364fdcf 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -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);
}
--
2.20.1
On Fri, Dec 21, 2018 at 8:55 AM Greg Kroah-Hartman
<[email protected]> wrote:
>
> We 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.
>
> 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(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 8e5140bbf241..d871d364fdcf 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -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);
> }
Acked-by: Ilya Dryomov <[email protected]>
Thanks,
Ilya
We 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.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/base/bus.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 8bfd27ec73d6..f10d56c61a46 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -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)
{
--
2.20.1
We 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.
Cc: Matt Porter <[email protected]>
Cc: Alexandre Bounine <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/rapidio/rio-sysfs.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index 73e4b407f162..ad5e303dda05 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -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,
--
2.20.1
We 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.
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(-)
diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
index 5b4a56131904..84e8ec4011ba 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -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,
--
2.20.1
Looks good,
Acked-by: Johannes Thumshirn <[email protected]>
[scsi list cc added]
On Fri, 2018-12-21 at 08:54 +0100, Greg Kroah-Hartman wrote:
> We 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...
The EXPORT_SYMBOL removal is fine, but
[...]
> --- a/include/scsi/libfcoe.h
> +++ b/include/scsi/libfcoe.h
> @@ -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);
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
---
diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index 5c8310bade61..88e5c26ce381 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -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,
Greg Kroah-Hartman <[email protected]> writes:
> We 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.
>
> 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.
Acked-by: Michael Ellerman <[email protected]> (powerpc)
cheers
> diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
> index 5b4a56131904..84e8ec4011ba 100644
> --- a/arch/powerpc/platforms/pseries/ibmebus.c
> +++ b/arch/powerpc/platforms/pseries/ibmebus.c
> @@ -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,
> --
> 2.20.1
On 12/21/18 4:29 PM, James Bottomley wrote:
> [scsi list cc added]
> On Fri, 2018-12-21 at 08:54 +0100, Greg Kroah-Hartman wrote:
>> We 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...
>
> The EXPORT_SYMBOL removal is fine, but
>
> [...]
>> --- a/include/scsi/libfcoe.h
>> +++ b/include/scsi/libfcoe.h
>> @@ -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);
>
> 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
On Fri, Dec 28, 2018 at 01:50:53PM +0100, Hannes Reinecke wrote:
> On 12/21/18 4:29 PM, James Bottomley wrote:
> > [scsi list cc added]
> > On Fri, 2018-12-21 at 08:54 +0100, Greg Kroah-Hartman wrote:
> > > We 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...
> >
> > The EXPORT_SYMBOL removal is fine, but
> >
> > [...]
> > > --- a/include/scsi/libfcoe.h
> > > +++ b/include/scsi/libfcoe.h
> > > @@ -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);
> >
> > 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.
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