Skip to content

Commit aad7ebb

Browse files
committed
ALSA: seq: Constify struct snd_midi_op
Change the argument of snd_midi_process_event() to receive a const snd_midi_op pointer and its callers respectively. This allows further optimizations. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d25ff26 commit aad7ebb

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

include/sound/seq_midi_emul.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ enum {
174174
};
175175

176176
/* Prototypes for midi_process.c */
177-
void snd_midi_process_event(struct snd_midi_op *ops, struct snd_seq_event *ev,
177+
void snd_midi_process_event(const struct snd_midi_op *ops,
178+
struct snd_seq_event *ev,
178179
struct snd_midi_channel_set *chanset);
179180
void snd_midi_channel_set_clear(struct snd_midi_channel_set *chset);
180181
struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n);

sound/core/seq/seq_midi_emul.c

+22-15
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,25 @@ MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI emulation."
3030
MODULE_LICENSE("GPL");
3131

3232
/* Prototypes for static functions */
33-
static void note_off(struct snd_midi_op *ops, void *drv,
33+
static void note_off(const struct snd_midi_op *ops, void *drv,
3434
struct snd_midi_channel *chan,
3535
int note, int vel);
36-
static void do_control(struct snd_midi_op *ops, void *private,
36+
static void do_control(const struct snd_midi_op *ops, void *private,
3737
struct snd_midi_channel_set *chset,
3838
struct snd_midi_channel *chan,
3939
int control, int value);
40-
static void rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
40+
static void rpn(const struct snd_midi_op *ops, void *drv,
41+
struct snd_midi_channel *chan,
4142
struct snd_midi_channel_set *chset);
42-
static void nrpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
43+
static void nrpn(const struct snd_midi_op *ops, void *drv,
44+
struct snd_midi_channel *chan,
4345
struct snd_midi_channel_set *chset);
44-
static void sysex(struct snd_midi_op *ops, void *private, unsigned char *sysex,
46+
static void sysex(const struct snd_midi_op *ops, void *private,
47+
unsigned char *sysex,
4548
int len, struct snd_midi_channel_set *chset);
46-
static void all_sounds_off(struct snd_midi_op *ops, void *private,
49+
static void all_sounds_off(const struct snd_midi_op *ops, void *private,
4750
struct snd_midi_channel *chan);
48-
static void all_notes_off(struct snd_midi_op *ops, void *private,
51+
static void all_notes_off(const struct snd_midi_op *ops, void *private,
4952
struct snd_midi_channel *chan);
5053
static void snd_midi_reset_controllers(struct snd_midi_channel *chan);
5154
static void reset_all_channels(struct snd_midi_channel_set *chset);
@@ -66,7 +69,7 @@ static void reset_all_channels(struct snd_midi_channel_set *chset);
6669
* be interpreted.
6770
*/
6871
void
69-
snd_midi_process_event(struct snd_midi_op *ops,
72+
snd_midi_process_event(const struct snd_midi_op *ops,
7073
struct snd_seq_event *ev,
7174
struct snd_midi_channel_set *chanset)
7275
{
@@ -229,7 +232,8 @@ EXPORT_SYMBOL(snd_midi_process_event);
229232
* release note
230233
*/
231234
static void
232-
note_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
235+
note_off(const struct snd_midi_op *ops, void *drv,
236+
struct snd_midi_channel *chan,
233237
int note, int vel)
234238
{
235239
if (chan->gm_hold) {
@@ -251,7 +255,8 @@ note_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
251255
* events that need to take place immediately to the driver.
252256
*/
253257
static void
254-
do_control(struct snd_midi_op *ops, void *drv, struct snd_midi_channel_set *chset,
258+
do_control(const struct snd_midi_op *ops, void *drv,
259+
struct snd_midi_channel_set *chset,
255260
struct snd_midi_channel *chan, int control, int value)
256261
{
257262
int i;
@@ -402,7 +407,7 @@ EXPORT_SYMBOL(snd_midi_channel_set_clear);
402407
* Process a rpn message.
403408
*/
404409
static void
405-
rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
410+
rpn(const struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
406411
struct snd_midi_channel_set *chset)
407412
{
408413
int type;
@@ -442,7 +447,7 @@ rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
442447
* Process an nrpn message.
443448
*/
444449
static void
445-
nrpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
450+
nrpn(const struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan,
446451
struct snd_midi_channel_set *chset)
447452
{
448453
/* parse XG NRPNs here if possible */
@@ -470,7 +475,7 @@ get_channel(unsigned char cmd)
470475
* Process a sysex message.
471476
*/
472477
static void
473-
sysex(struct snd_midi_op *ops, void *private, unsigned char *buf, int len,
478+
sysex(const struct snd_midi_op *ops, void *private, unsigned char *buf, int len,
474479
struct snd_midi_channel_set *chset)
475480
{
476481
/* GM on */
@@ -584,7 +589,8 @@ sysex(struct snd_midi_op *ops, void *private, unsigned char *buf, int len,
584589
* all sound off
585590
*/
586591
static void
587-
all_sounds_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan)
592+
all_sounds_off(const struct snd_midi_op *ops, void *drv,
593+
struct snd_midi_channel *chan)
588594
{
589595
int n;
590596

@@ -602,7 +608,8 @@ all_sounds_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan
602608
* all notes off
603609
*/
604610
static void
605-
all_notes_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan)
611+
all_notes_off(const struct snd_midi_op *ops, void *drv,
612+
struct snd_midi_channel *chan)
606613
{
607614
int n;
608615

sound/drivers/opl3/opl3_seq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int snd_opl3_synth_unuse(void *private_data, struct snd_seq_port_subscrib
128128
/*
129129
* MIDI emulation operators
130130
*/
131-
struct snd_midi_op opl3_ops = {
131+
const struct snd_midi_op opl3_ops = {
132132
.note_on = snd_opl3_note_on,
133133
.note_off = snd_opl3_note_off,
134134
.key_press = snd_opl3_key_press,

sound/drivers/opl3/opl3_voice.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ void snd_opl3_free_seq_oss(struct snd_opl3 *opl3);
4141

4242
extern char snd_opl3_regmap[MAX_OPL2_VOICES][4];
4343
extern bool use_internal_drums;
44-
extern struct snd_midi_op opl3_ops;
44+
extern const struct snd_midi_op opl3_ops;
4545

4646
#endif

sound/drivers/opl4/opl4_seq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int snd_opl4_seq_unuse(void *private_data, struct snd_seq_port_subscribe
100100
return 0;
101101
}
102102

103-
static struct snd_midi_op opl4_ops = {
103+
static const struct snd_midi_op opl4_ops = {
104104
.note_on = snd_opl4_note_on,
105105
.note_off = snd_opl4_note_off,
106106
.note_terminate = snd_opl4_terminate_note,

sound/synth/emux/emux_seq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static int snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *inf
1919
/*
2020
* MIDI emulation operators
2121
*/
22-
static struct snd_midi_op emux_ops = {
22+
static const struct snd_midi_op emux_ops = {
2323
.note_on = snd_emux_note_on,
2424
.note_off = snd_emux_note_off,
2525
.key_press = snd_emux_key_press,

0 commit comments

Comments
 (0)