2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-27 06:34:11 +08:00

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: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20201004193202.4044-3-rikard.falkeborn@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Rikard Falkeborn 2020-10-04 21:32:01 +02:00 committed by Greg Kroah-Hartman
parent 07f8569fbe
commit 57de2dfcab
17 changed files with 19 additions and 19 deletions

View File

@ -206,7 +206,7 @@ static struct attribute *w1_ds2405_attrs[] = {
ATTRIBUTE_GROUPS(w1_ds2405); 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 .groups = w1_ds2405_groups
}; };

View File

@ -138,7 +138,7 @@ static void w1_f12_remove_slave(struct w1_slave *sl)
&(w1_f12_sysfs_bin_files[i])); &(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, .add_slave = w1_f12_add_slave,
.remove_slave = w1_f12_remove_slave, .remove_slave = w1_f12_remove_slave,
}; };

View File

@ -336,7 +336,7 @@ static const struct attribute_group *w1_f29_groups[] = {
NULL, 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, .add_slave = w1_f29_disable_test_mode,
.groups = w1_f29_groups, .groups = w1_f29_groups,
}; };

View File

@ -143,7 +143,7 @@ static const struct attribute_group *w1_f3a_groups[] = {
NULL, NULL,
}; };
static struct w1_family_ops w1_f3a_fops = { static const struct w1_family_ops w1_f3a_fops = {
.groups = w1_f3a_groups, .groups = w1_f3a_groups,
}; };

View File

@ -117,7 +117,7 @@ static struct attribute *w1_f1d_attrs[] = {
}; };
ATTRIBUTE_GROUPS(w1_f1d); 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, .groups = w1_f1d_groups,
}; };

View File

@ -279,7 +279,7 @@ static const struct attribute_group *w1_f14_groups[] = {
NULL, NULL,
}; };
static struct w1_family_ops w1_f14_fops = { static const struct w1_family_ops w1_f14_fops = {
.groups = w1_f14_groups, .groups = w1_f14_groups,
}; };

View File

@ -278,7 +278,7 @@ static const struct attribute_group *w1_f2d_groups[] = {
NULL, NULL,
}; };
static struct w1_family_ops w1_f2d_fops = { static const struct w1_family_ops w1_f2d_fops = {
.groups = w1_f2d_groups, .groups = w1_f2d_groups,
}; };

View File

@ -288,7 +288,7 @@ static void w1_f23_remove_slave(struct w1_slave *sl)
#endif /* CONFIG_W1_SLAVE_DS2433_CRC */ #endif /* CONFIG_W1_SLAVE_DS2433_CRC */
} }
static struct w1_family_ops w1_f23_fops = { static const struct w1_family_ops w1_f23_fops = {
.add_slave = w1_f23_add_slave, .add_slave = w1_f23_add_slave,
.remove_slave = w1_f23_remove_slave, .remove_slave = w1_f23_remove_slave,
.groups = w1_f23_groups, .groups = w1_f23_groups,

View File

@ -412,7 +412,7 @@ static const struct attribute_group *w1_ds2438_groups[] = {
NULL, NULL,
}; };
static struct w1_family_ops w1_ds2438_fops = { static const struct w1_family_ops w1_ds2438_fops = {
.groups = w1_ds2438_groups, .groups = w1_ds2438_groups,
}; };

View File

@ -215,7 +215,7 @@ static int w1_eprom_add_slave(struct w1_slave *sl)
return PTR_ERR_OR_ZERO(nvmem); return PTR_ERR_OR_ZERO(nvmem);
} }
static struct w1_family_ops w1_eprom_fops = { static const struct w1_family_ops w1_eprom_fops = {
.add_slave = w1_eprom_add_slave, .add_slave = w1_eprom_add_slave,
}; };

View File

@ -141,7 +141,7 @@ static void w1_ds2780_remove_slave(struct w1_slave *sl)
platform_device_unregister(pdev); platform_device_unregister(pdev);
} }
static struct w1_family_ops w1_ds2780_fops = { static const struct w1_family_ops w1_ds2780_fops = {
.add_slave = w1_ds2780_add_slave, .add_slave = w1_ds2780_add_slave,
.remove_slave = w1_ds2780_remove_slave, .remove_slave = w1_ds2780_remove_slave,
.groups = w1_ds2780_groups, .groups = w1_ds2780_groups,

View File

@ -138,7 +138,7 @@ static void w1_ds2781_remove_slave(struct w1_slave *sl)
platform_device_unregister(pdev); platform_device_unregister(pdev);
} }
static struct w1_family_ops w1_ds2781_fops = { static const struct w1_family_ops w1_ds2781_fops = {
.add_slave = w1_ds2781_add_slave, .add_slave = w1_ds2781_add_slave,
.remove_slave = w1_ds2781_remove_slave, .remove_slave = w1_ds2781_remove_slave,
.groups = w1_ds2781_groups, .groups = w1_ds2781_groups,

View File

@ -281,7 +281,7 @@ static void w1_f0d_remove_slave(struct w1_slave *sl)
sysfs_remove_bin_file(&sl->dev.kobj, &w1_f0d_bin_attr); sysfs_remove_bin_file(&sl->dev.kobj, &w1_f0d_bin_attr);
} }
static struct w1_family_ops w1_f0d_fops = { static const struct w1_family_ops w1_f0d_fops = {
.add_slave = w1_f0d_add_slave, .add_slave = w1_f0d_add_slave,
.remove_slave = w1_f0d_remove_slave, .remove_slave = w1_f0d_remove_slave,
}; };

View File

@ -410,7 +410,7 @@ static void w1_f1C_remove_slave(struct w1_slave *sl)
sl->family_data = NULL; sl->family_data = NULL;
} }
static struct w1_family_ops w1_f1C_fops = { static const struct w1_family_ops w1_f1C_fops = {
.add_slave = w1_f1C_add_slave, .add_slave = w1_f1C_add_slave,
.remove_slave = w1_f1C_remove_slave, .remove_slave = w1_f1C_remove_slave,
.groups = w1_f1C_groups, .groups = w1_f1C_groups,

View File

@ -741,7 +741,7 @@ static void w1_f19_remove_slave(struct w1_slave *sl)
/* Declarations within the w1 subsystem. */ /* Declarations within the w1 subsystem. */
static struct w1_family_ops w1_f19_fops = { static const struct w1_family_ops w1_f19_fops = {
.add_slave = w1_f19_add_slave, .add_slave = w1_f19_add_slave,
.remove_slave = w1_f19_remove_slave, .remove_slave = w1_f19_remove_slave,
.groups = w1_f19_groups, .groups = w1_f19_groups,

View File

@ -475,21 +475,21 @@ static const struct hwmon_chip_info w1_chip_info = {
/* Family operations */ /* Family operations */
static struct w1_family_ops w1_therm_fops = { static const struct w1_family_ops w1_therm_fops = {
.add_slave = w1_therm_add_slave, .add_slave = w1_therm_add_slave,
.remove_slave = w1_therm_remove_slave, .remove_slave = w1_therm_remove_slave,
.groups = w1_therm_groups, .groups = w1_therm_groups,
.chip_info = W1_CHIPINFO, .chip_info = W1_CHIPINFO,
}; };
static struct w1_family_ops w1_ds18s20_fops = { static const struct w1_family_ops w1_ds18s20_fops = {
.add_slave = w1_therm_add_slave, .add_slave = w1_therm_add_slave,
.remove_slave = w1_therm_remove_slave, .remove_slave = w1_therm_remove_slave,
.groups = w1_ds18s20_groups, .groups = w1_ds18s20_groups,
.chip_info = W1_CHIPINFO, .chip_info = W1_CHIPINFO,
}; };
static struct w1_family_ops w1_ds28ea00_fops = { static const struct w1_family_ops w1_ds28ea00_fops = {
.add_slave = w1_therm_add_slave, .add_slave = w1_therm_add_slave,
.remove_slave = w1_therm_remove_slave, .remove_slave = w1_therm_remove_slave,
.groups = w1_ds28ea00_groups, .groups = w1_ds28ea00_groups,

View File

@ -160,7 +160,7 @@ static const struct attribute_group *w1_slave_default_groups[] = {
NULL, NULL,
}; };
static struct w1_family_ops w1_default_fops = { static const struct w1_family_ops w1_default_fops = {
.groups = w1_slave_default_groups, .groups = w1_slave_default_groups,
}; };