]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: mark all struct bus_type as const
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Dec 2023 13:34:46 +0000 (14:34 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sat, 30 Dec 2023 09:10:41 +0000 (10:10 +0100)
Now that the driver core can properly handle constant struct bus_type,
move all of the sound subsystem struct bus_type structures as const,
placing them into read-only memory which can not be modified at runtime.

Note, this fixes a duplicate definition of ac97_bus_type, which somehow
was declared extern in a .h file, and then static as a prototype in a .c
file, and then properly later on in the same .c file.  Amazing that no
compiler warning ever showed up for this.

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Dawei Li <set_pte_at@outlook.com>
Cc: Yu Liao <liaoyu15@huawei.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: linux-sound@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/2023121945-immersion-budget-d0aa@gregkh
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/ac97_codec.h
include/sound/hdaudio.h
sound/ac97/bus.c
sound/ac97_bus.c
sound/hda/hda_bus_type.c

index c495c6d5fbe008c7d1ae3e7fc2d98f0e79cbf6e5..4bd3be3a3192af27afcab6d1885e981507eee039 100644 (file)
@@ -410,7 +410,7 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm);
 int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 
 /* ad hoc AC97 device driver access */
-extern struct bus_type ac97_bus_type;
+extern const struct bus_type ac97_bus_type;
 
 /* AC97 platform_data adding function */
 static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
index 62a3cd154ff2b4ed91abbac3658085726dbebf2b..a73d7f34f4e545c99adf081fa6ffd6db0f584d02 100644 (file)
@@ -33,7 +33,7 @@ struct hda_device_id;
 /*
  * exported bus type
  */
-extern struct bus_type snd_hda_bus_type;
+extern const struct bus_type snd_hda_bus_type;
 
 /*
  * generic arrays
index 3173e9d98927ee99e0d1770dab24ad6f5645458c..1dc7965eb14b0e052ddef4d6376c173ae3e13869 100644 (file)
@@ -28,8 +28,6 @@ static DEFINE_MUTEX(ac97_controllers_mutex);
 static DEFINE_IDR(ac97_adapter_idr);
 static LIST_HEAD(ac97_controllers);
 
-static struct bus_type ac97_bus_type;
-
 static inline struct ac97_controller*
 to_ac97_controller(struct device *ac97_adapter)
 {
index c7aee8c42c554a326f0d1736511b4fb271e22eab..7ea274c559005ce49139e323e662938ec3da8831 100644 (file)
@@ -75,7 +75,7 @@ int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
 }
 EXPORT_SYMBOL_GPL(snd_ac97_reset);
 
-struct bus_type ac97_bus_type = {
+const struct bus_type ac97_bus_type = {
        .name           = "ac97",
 };
 
index 4cd94178df9fa9f33b2c1bfdea3052d11bd5e4a8..cce2c30511a290c023aaba005e5afe81cda3f099 100644 (file)
@@ -76,7 +76,7 @@ static int hda_uevent(const struct device *dev, struct kobj_uevent_env *env)
        return 0;
 }
 
-struct bus_type snd_hda_bus_type = {
+const struct bus_type snd_hda_bus_type = {
        .name = "hdaudio",
        .match = hda_bus_match,
        .uevent = hda_uevent,