Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

w1: Constify struct w1_family_ops

The fops field in the w1_family struct is never modified. Make it const
to indicate that. Constifying the pointer makes it possible for drivers
to declare static w1_family_ops structs const, which in turn will allow
the compiler to put it in read-only memory.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20201004193202.4044-2-rikard.falkeborn@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rikard Falkeborn and committed by
Greg Kroah-Hartman
07f8569f 9f126c56

+2 -2
+1 -1
drivers/w1/w1.c
··· 613 613 614 614 static int w1_family_notify(unsigned long action, struct w1_slave *sl) 615 615 { 616 - struct w1_family_ops *fops; 616 + const struct w1_family_ops *fops; 617 617 int err; 618 618 619 619 fops = sl->family->fops;
+1 -1
include/linux/w1.h
··· 269 269 struct list_head family_entry; 270 270 u8 fid; 271 271 272 - struct w1_family_ops *fops; 272 + const struct w1_family_ops *fops; 273 273 274 274 const struct of_device_id *of_match_table; 275 275