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

driver core: class: mark the struct class for sysfs callbacks as constant



struct class 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
class to be moved to read-only memory.

While we are touching all class sysfs callbacks also mark the attribute
as constant as it can not be modified.  The bonding code still uses this
structure so it can not be removed from the function callbacks.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Russ Weight <russell.h.weight@intel.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Steve French <sfrench@samba.org>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: linux-cifs@vger.kernel.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-mtd@lists.infradead.org
Cc: linux-rdma@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: netdev@vger.kernel.org
Reviewed-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20230325084537.3622280-1-gregkh@linuxfoundation.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8ad266d1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -512,7 +512,7 @@ static int dlpar_parse_id_type(char **cmd, struct pseries_hp_errorlog *hp_elog)
	return 0;
}

static ssize_t dlpar_store(struct class *class, struct class_attribute *attr,
static ssize_t dlpar_store(const struct class *class, const struct class_attribute *attr,
			   const char *buf, size_t count)
{
	struct pseries_hp_errorlog hp_elog;
@@ -551,7 +551,7 @@ static ssize_t dlpar_store(struct class *class, struct class_attribute *attr,
	return rc ? rc : count;
}

static ssize_t dlpar_show(struct class *class, struct class_attribute *attr,
static ssize_t dlpar_show(const struct class *class, const struct class_attribute *attr,
			  char *buf)
{
	return sprintf(buf, "%s\n", "memory,cpu");
+2 −2
Original line number Diff line number Diff line
@@ -787,8 +787,8 @@ int rtas_syscall_dispatch_ibm_suspend_me(u64 handle)
	return pseries_migrate_partition(handle);
}

static ssize_t migration_store(struct class *class,
			       struct class_attribute *attr, const char *buf,
static ssize_t migration_store(const struct class *class,
			       const struct class_attribute *attr, const char *buf,
			       size_t count)
{
	u64 streamid;
+2 −2
Original line number Diff line number Diff line
@@ -482,8 +482,8 @@ void class_interface_unregister(struct class_interface *class_intf)
}
EXPORT_SYMBOL_GPL(class_interface_unregister);

ssize_t show_class_attr_string(struct class *class,
			       struct class_attribute *attr, char *buf)
ssize_t show_class_attr_string(const struct class *class,
			       const struct class_attribute *attr, char *buf)
{
	struct class_attribute_string *cs;

+2 −2
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ static int devcd_free(struct device *dev, void *data)
	return 0;
}

static ssize_t disabled_show(struct class *class, struct class_attribute *attr,
static ssize_t disabled_show(const struct class *class, const struct class_attribute *attr,
			     char *buf)
{
	return sysfs_emit(buf, "%d\n", devcd_disabled);
@@ -197,7 +197,7 @@ static ssize_t disabled_show(struct class *class, struct class_attribute *attr,
 * so, above situation would not occur.
 */

static ssize_t disabled_store(struct class *class, struct class_attribute *attr,
static ssize_t disabled_store(const struct class *class, const struct class_attribute *attr,
			      const char *buf, size_t count)
{
	long tmp = simple_strtol(buf, NULL, 10);
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ void __fw_load_abort(struct fw_priv *fw_priv)
}

#ifdef CONFIG_FW_LOADER_USER_HELPER
static ssize_t timeout_show(struct class *class, struct class_attribute *attr,
static ssize_t timeout_show(const struct class *class, const struct class_attribute *attr,
			    char *buf)
{
	return sysfs_emit(buf, "%d\n", __firmware_loading_timeout());
@@ -44,7 +44,7 @@ static ssize_t timeout_show(struct class *class, struct class_attribute *attr,
 *
 *	Note: zero means 'wait forever'.
 **/
static ssize_t timeout_store(struct class *class, struct class_attribute *attr,
static ssize_t timeout_store(const struct class *class, const struct class_attribute *attr,
			     const char *buf, size_t count)
{
	int tmp_loading_timeout = simple_strtol(buf, NULL, 10);
Loading