Commit 57de2dfc authored by Rikard Falkeborn's avatar Rikard Falkeborn Committed by Greg Kroah-Hartman
Browse files

w1: Constify static w1_family_ops structs

The only usage of these structs is to assign their address to the fops
field in the w1_family struct, which is a const pointer. Make them const
to allow the compiler to put them in read-only memory.

This was done with the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/

):

// <smpl>
@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct w1_family_ops i@p = {...};

@ok1@
identifier r1.i;
position p;
identifier s;
@@
static struct w1_family s = {
	.fops=&i@p,
};

@bad1@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad1 disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct w1_family_ops i={};
// </smpl>

Signed-off-by: default avatarRikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20201004193202.4044-3-rikard.falkeborn@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 07f8569f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ static struct attribute *w1_ds2405_attrs[] = {

ATTRIBUTE_GROUPS(w1_ds2405);

static struct w1_family_ops w1_ds2405_fops = {
static const struct w1_family_ops w1_ds2405_fops = {
	.groups = w1_ds2405_groups
};

+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ static void w1_f12_remove_slave(struct w1_slave *sl)
			&(w1_f12_sysfs_bin_files[i]));
}

static struct w1_family_ops w1_f12_fops = {
static const struct w1_family_ops w1_f12_fops = {
	.add_slave      = w1_f12_add_slave,
	.remove_slave   = w1_f12_remove_slave,
};
+1 −1
Original line number Diff line number Diff line
@@ -336,7 +336,7 @@ static const struct attribute_group *w1_f29_groups[] = {
	NULL,
};

static struct w1_family_ops w1_f29_fops = {
static const struct w1_family_ops w1_f29_fops = {
	.add_slave      = w1_f29_disable_test_mode,
	.groups		= w1_f29_groups,
};
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ static const struct attribute_group *w1_f3a_groups[] = {
	NULL,
};

static struct w1_family_ops w1_f3a_fops = {
static const struct w1_family_ops w1_f3a_fops = {
	.groups		= w1_f3a_groups,
};

+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ static struct attribute *w1_f1d_attrs[] = {
};
ATTRIBUTE_GROUPS(w1_f1d);

static struct w1_family_ops w1_f1d_fops = {
static const struct w1_family_ops w1_f1d_fops = {
	.groups		= w1_f1d_groups,
};

Loading