Commit 75cff725 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

driver core: bus: mark the struct bus_type for sysfs callbacks as constant



struct bus_type should never be modified in a sysfs callback as there is
nothing in the structure to modify, and frankly, the structure is almost
never used in a sysfs callback, so mark it as constant to allow struct
bus_type to be moved to read-only memory.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Bounine <alex.bou9@gmail.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: Ben Widawsky <bwidawsk@kernel.org>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Hu Haowen <src.res@email.cn>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Stuart Yoder <stuyoder@gmail.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Acked-by: Ilya Dryomov <idryomov@gmail.com> # rbd
Acked-by: Ira Weiny <ira.weiny@intel.com> # cxl
Reviewed-by: default avatarAlex Shi <alexs@kernel.org>
Acked-by: default avatarIwona Winiarska <iwona.winiarska@intel.com>
Acked-by: default avatarDan Williams <dan.j.williams@intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>	# pci
Acked-by: default avatarWei Liu <wei.liu@kernel.org>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com> # scsi
Link: https://lore.kernel.org/r/20230313182918.1312597-23-gregkh@linuxfoundation.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9cc61e5f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -125,8 +125,8 @@ Exporting Attributes

  struct bus_attribute {
	struct attribute	attr;
	ssize_t (*show)(struct bus_type *, char * buf);
	ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
	ssize_t (*show)(const struct bus_type *, char * buf);
	ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
  };

Bus drivers can export attributes using the BUS_ATTR_RW macro that works
+2 −2
Original line number Diff line number Diff line
@@ -373,8 +373,8 @@ Structure::

    struct bus_attribute {
	    struct attribute        attr;
	    ssize_t (*show)(struct bus_type *, char * buf);
	    ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
	    ssize_t (*show)(const struct bus_type *, char * buf);
	    ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
    };

Declaring::
+2 −2
Original line number Diff line number Diff line
@@ -329,8 +329,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr

struct bus_attribute {
        struct attribute        attr;
        ssize_t (*show)(struct bus_type *, char * buf);
        ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
        ssize_t (*show)(const struct bus_type *, char * buf);
        ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
};

声明:
+2 −2
Original line number Diff line number Diff line
@@ -332,8 +332,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr

struct bus_attribute {
        struct attribute        attr;
        ssize_t (*show)(struct bus_type *, char * buf);
        ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
        ssize_t (*show)(const struct bus_type *, char * buf);
        ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
};

聲明:
+2 −2
Original line number Diff line number Diff line
@@ -267,7 +267,7 @@ static char *ibmebus_chomp(const char *in, size_t count)
	return out;
}

static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
static ssize_t probe_store(const struct bus_type *bus, const char *buf, size_t count)
{
	struct device_node *dn = NULL;
	struct device *dev;
@@ -305,7 +305,7 @@ static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
}
static BUS_ATTR_WO(probe);

static ssize_t remove_store(struct bus_type *bus, const char *buf, size_t count)
static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_t count)
{
	struct device *dev;
	char *path;
Loading