Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52cf25d0 authored by Emese Revfy's avatar Emese Revfy Committed by Greg Kroah-Hartman
Browse files

Driver core: Constify struct sysfs_ops in struct kobj_type



Constify struct sysfs_ops.

This is part of the ops structure constification
effort started by Arjan van de Ven et al.

Benefits of this constification:

 * prevents modification of data that is shared
   (referenced) by many other structure instances
   at runtime

 * detects/prevents accidental (but not intentional)
   modification attempts on archs that enforce
   read-only kernel data at runtime

 * potentially better optimized code as the compiler
   can assume that the const data cannot be changed

 * the compiler/linker move const data into .rodata
   and therefore exclude them from false sharing

Signed-off-by: default avatarEmese Revfy <re.emese@gmail.com>
Acked-by: default avatarDavid Teigland <teigland@redhat.com>
Acked-by: default avatarMatt Domsch <Matt_Domsch@dell.com>
Acked-by: default avatarMaciej Sosnowski <maciej.sosnowski@intel.com>
Acked-by: default avatarHans J. Koch <hjk@linutronix.de>
Acked-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Acked-by: default avatarJens Axboe <jens.axboe@oracle.com>
Acked-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 6c1733ac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ kobj_type:

    struct kobj_type {
	    void (*release)(struct kobject *);
	    struct sysfs_ops	*sysfs_ops;
	    const struct sysfs_ops *sysfs_ops;
	    struct attribute	**default_attrs;
    };

+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ static ssize_t cache_show(struct kobject * kobj, struct attribute * attr, char *
	return ret;
}

static struct sysfs_ops cache_sysfs_ops = {
static const struct sysfs_ops cache_sysfs_ops = {
	.show   = cache_show
};

+1 −1
Original line number Diff line number Diff line
@@ -642,7 +642,7 @@ static struct kobj_attribute *cache_index_opt_attrs[] = {
	&cache_assoc_attr,
};

static struct sysfs_ops cache_index_ops = {
static const struct sysfs_ops cache_index_ops = {
	.show = cache_index_show,
};

+1 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ static struct attribute *sq_sysfs_attrs[] = {
	NULL,
};

static struct sysfs_ops sq_sysfs_ops = {
static const struct sysfs_ops sq_sysfs_ops = {
	.show	= sq_sysfs_show,
	.store	= sq_sysfs_store,
};
+1 −1
Original line number Diff line number Diff line
@@ -903,7 +903,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
	return ret;
}

static struct sysfs_ops sysfs_ops = {
static const struct sysfs_ops sysfs_ops = {
	.show   = show,
	.store  = store,
};
Loading