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

soundwire: constify the struct device_type usage

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
sdw_master_type and sdw_slave_type variables to be constant structures as
well, placing it into read-only memory which can not be modified at
runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240219-device_cleanup-soundwire-v1-1-9edd51767611@marliere.net
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Ricardo B. Marliere and committed by
Vinod Koul
99fea943 81a7d0c4

+4 -4
+1 -1
drivers/soundwire/master.c
··· 112 112 pm_generic_runtime_resume, NULL) 113 113 }; 114 114 115 - struct device_type sdw_master_type = { 115 + const struct device_type sdw_master_type = { 116 116 .name = "soundwire_master", 117 117 .release = sdw_master_device_release, 118 118 .pm = &master_dev_pm,
+1 -1
drivers/soundwire/slave.c
··· 16 16 kfree(slave); 17 17 } 18 18 19 - struct device_type sdw_slave_type = { 19 + const struct device_type sdw_slave_type = { 20 20 .name = "sdw_slave", 21 21 .release = sdw_slave_release, 22 22 .uevent = sdw_slave_uevent,
+2 -2
include/linux/soundwire/sdw_type.h
··· 5 5 #define __SOUNDWIRE_TYPES_H 6 6 7 7 extern const struct bus_type sdw_bus_type; 8 - extern struct device_type sdw_slave_type; 9 - extern struct device_type sdw_master_type; 8 + extern const struct device_type sdw_slave_type; 9 + extern const struct device_type sdw_master_type; 10 10 11 11 static inline int is_sdw_slave(const struct device *dev) 12 12 {