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

ALSA: core: Treat snd_device_ops as const

This is a preliminary patch to allow const for snd_device_ops
definitions in each driver's code. The ops reference is read-only,
hence it can be declared as const for further optimization.

There should be no functional changes by this patch.

Link: https://lore.kernel.org/r/20200103081714.9560-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+3 -3
+2 -2
include/sound/core.h
··· 69 69 enum snd_device_state state; /* state of the device */ 70 70 enum snd_device_type type; /* device type */ 71 71 void *device_data; /* device structure */ 72 - struct snd_device_ops *ops; /* operations */ 72 + const struct snd_device_ops *ops; /* operations */ 73 73 }; 74 74 75 75 #define snd_device(n) list_entry(n, struct snd_device, list) ··· 256 256 /* device.c */ 257 257 258 258 int snd_device_new(struct snd_card *card, enum snd_device_type type, 259 - void *device_data, struct snd_device_ops *ops); 259 + void *device_data, const struct snd_device_ops *ops); 260 260 int snd_device_register(struct snd_card *card, void *device_data); 261 261 int snd_device_register_all(struct snd_card *card); 262 262 void snd_device_disconnect(struct snd_card *card, void *device_data);
+1 -1
sound/core/device.c
··· 27 27 * Return: Zero if successful, or a negative error code on failure. 28 28 */ 29 29 int snd_device_new(struct snd_card *card, enum snd_device_type type, 30 - void *device_data, struct snd_device_ops *ops) 30 + void *device_data, const struct snd_device_ops *ops) 31 31 { 32 32 struct snd_device *dev; 33 33 struct list_head *p;