[PATCH 02/36] ALSA: rawmidi: Add ioctl callback to snd_rawmidi_global_ops

From: Takashi Iwai
Date: Fri May 19 2023 - 05:31:44 EST


A new callback, ioctl, is added to snd_rawmidi_global_ops for allowing
the driver to deal with the own ioctls. This is another preparation
patch for the upcoming UMP support.

Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
---
include/sound/rawmidi.h | 3 +++
sound/core/rawmidi.c | 2 ++
2 files changed, 5 insertions(+)

diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h
index 52b1cbfb2526..a53cd063412c 100644
--- a/include/sound/rawmidi.h
+++ b/include/sound/rawmidi.h
@@ -32,6 +32,7 @@

struct snd_rawmidi;
struct snd_rawmidi_substream;
+struct snd_rawmidi_file;
struct snd_seq_port_info;
struct pid;

@@ -47,6 +48,8 @@ struct snd_rawmidi_global_ops {
int (*dev_unregister) (struct snd_rawmidi * rmidi);
void (*get_port_info)(struct snd_rawmidi *rmidi, int number,
struct snd_seq_port_info *info);
+ long (*ioctl)(struct snd_rawmidi_file *rfile, unsigned int cmd,
+ void __user *argp);
};

struct snd_rawmidi_runtime {
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 589b75087d27..1415f559b5d0 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -984,6 +984,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long
}
}
default:
+ if (rfile->rmidi->ops && rfile->rmidi->ops->ioctl)
+ return rfile->rmidi->ops->ioctl(rfile, cmd, argp);
rmidi_dbg(rfile->rmidi,
"rawmidi: unknown command = 0x%x\n", cmd);
}
--
2.35.3