Skip to content

Commit 66e82d2

Browse files
gregkhtiwai
authored andcommitted
ALSA: mark all struct bus_type as const
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>
1 parent 64bf8de commit 66e82d2

5 files changed

Lines changed: 4 additions & 6 deletions

File tree

include/sound/ac97_codec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm);
410410
int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
411411

412412
/* ad hoc AC97 device driver access */
413-
extern struct bus_type ac97_bus_type;
413+
extern const struct bus_type ac97_bus_type;
414414

415415
/* AC97 platform_data adding function */
416416
static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)

include/sound/hdaudio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct hda_device_id;
3333
/*
3434
* exported bus type
3535
*/
36-
extern struct bus_type snd_hda_bus_type;
36+
extern const struct bus_type snd_hda_bus_type;
3737

3838
/*
3939
* generic arrays

sound/ac97/bus.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ static DEFINE_MUTEX(ac97_controllers_mutex);
2828
static DEFINE_IDR(ac97_adapter_idr);
2929
static LIST_HEAD(ac97_controllers);
3030

31-
static struct bus_type ac97_bus_type;
32-
3331
static inline struct ac97_controller*
3432
to_ac97_controller(struct device *ac97_adapter)
3533
{

sound/ac97_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id,
7575
}
7676
EXPORT_SYMBOL_GPL(snd_ac97_reset);
7777

78-
struct bus_type ac97_bus_type = {
78+
const struct bus_type ac97_bus_type = {
7979
.name = "ac97",
8080
};
8181

sound/hda/hda_bus_type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static int hda_uevent(const struct device *dev, struct kobj_uevent_env *env)
7676
return 0;
7777
}
7878

79-
struct bus_type snd_hda_bus_type = {
79+
const struct bus_type snd_hda_bus_type = {
8080
.name = "hdaudio",
8181
.match = hda_bus_match,
8282
.uevent = hda_uevent,

0 commit comments

Comments
 (0)