From 48c9d417d7269da2a2da5b602fcb5fdbee36305e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 13:56:51 +0100 Subject: [ALSA] Remove xxx_t typedefs: Raw MIDI Modules: RawMidi Midlevel Remove xxx_t typedefs from the core raw MIDI codes. Signed-off-by: Takashi Iwai --- sound/core/rawmidi.c | 280 +++++++++++++++++++++++++++------------------------ 1 file changed, 146 insertions(+), 134 deletions(-) (limited to 'sound/core/rawmidi.c') diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index d033e61c05c..ede0a6083d2 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -50,13 +50,13 @@ module_param_array(amidi_map, int, NULL, 0444); MODULE_PARM_DESC(amidi_map, "Raw MIDI device number assigned to 2nd OSS device."); #endif /* CONFIG_SND_OSSEMUL */ -static int snd_rawmidi_free(snd_rawmidi_t *rawmidi); -static int snd_rawmidi_dev_free(snd_device_t *device); -static int snd_rawmidi_dev_register(snd_device_t *device); -static int snd_rawmidi_dev_disconnect(snd_device_t *device); -static int snd_rawmidi_dev_unregister(snd_device_t *device); +static int snd_rawmidi_free(struct snd_rawmidi *rawmidi); +static int snd_rawmidi_dev_free(struct snd_device *device); +static int snd_rawmidi_dev_register(struct snd_device *device); +static int snd_rawmidi_dev_disconnect(struct snd_device *device); +static int snd_rawmidi_dev_unregister(struct snd_device *device); -static snd_rawmidi_t *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; +static struct snd_rawmidi *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; static DECLARE_MUTEX(register_mutex); @@ -72,34 +72,35 @@ static inline unsigned short snd_rawmidi_file_flags(struct file *file) } } -static inline int snd_rawmidi_ready(snd_rawmidi_substream_t * substream) +static inline int snd_rawmidi_ready(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; return runtime->avail >= runtime->avail_min; } -static inline int snd_rawmidi_ready_append(snd_rawmidi_substream_t * substream, size_t count) +static inline int snd_rawmidi_ready_append(struct snd_rawmidi_substream *substream, + size_t count) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; return runtime->avail >= runtime->avail_min && (!substream->append || runtime->avail >= count); } static void snd_rawmidi_input_event_tasklet(unsigned long data) { - snd_rawmidi_substream_t *substream = (snd_rawmidi_substream_t *)data; + struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *)data; substream->runtime->event(substream); } static void snd_rawmidi_output_trigger_tasklet(unsigned long data) { - snd_rawmidi_substream_t *substream = (snd_rawmidi_substream_t *)data; + struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *)data; substream->ops->trigger(substream, 1); } -static int snd_rawmidi_runtime_create(snd_rawmidi_substream_t * substream) +static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_runtime *runtime; if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL) return -ENOMEM; @@ -129,9 +130,9 @@ static int snd_rawmidi_runtime_create(snd_rawmidi_substream_t * substream) return 0; } -static int snd_rawmidi_runtime_free(snd_rawmidi_substream_t * substream) +static int snd_rawmidi_runtime_free(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; kfree(runtime->buffer); kfree(runtime); @@ -139,7 +140,7 @@ static int snd_rawmidi_runtime_free(snd_rawmidi_substream_t * substream) return 0; } -static inline void snd_rawmidi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *substream,int up) { if (up) { tasklet_hi_schedule(&substream->runtime->tasklet); @@ -149,17 +150,17 @@ static inline void snd_rawmidi_output_trigger(snd_rawmidi_substream_t * substrea } } -static void snd_rawmidi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_rawmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) { substream->ops->trigger(substream, up); if (!up && substream->runtime->event) tasklet_kill(&substream->runtime->tasklet); } -int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream) +int snd_rawmidi_drop_output(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_rawmidi_output_trigger(substream, 0); runtime->drain = 0; @@ -170,11 +171,11 @@ int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream) return 0; } -int snd_rawmidi_drain_output(snd_rawmidi_substream_t * substream) +int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream) { int err; long timeout; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; err = 0; runtime->drain = 1; @@ -199,10 +200,10 @@ int snd_rawmidi_drain_output(snd_rawmidi_substream_t * substream) return err; } -int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream) +int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_rawmidi_input_trigger(substream, 0); runtime->drain = 0; @@ -214,12 +215,12 @@ int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream) } int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, - int mode, snd_rawmidi_file_t * rfile) + int mode, struct snd_rawmidi_file * rfile) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; struct list_head *list1, *list2; - snd_rawmidi_substream_t *sinput = NULL, *soutput = NULL; - snd_rawmidi_runtime_t *input = NULL, *output = NULL; + struct snd_rawmidi_substream *sinput = NULL, *soutput = NULL; + struct snd_rawmidi_runtime *input = NULL, *output = NULL; int err; if (rfile) @@ -275,7 +276,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, } break; } - sinput = list_entry(list1, snd_rawmidi_substream_t, list); + sinput = list_entry(list1, struct snd_rawmidi_substream, list); if ((mode & SNDRV_RAWMIDI_LFLG_INPUT) && sinput->opened) goto __nexti; if (subdevice < 0 || (subdevice >= 0 && subdevice == sinput->number)) @@ -293,7 +294,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, } break; } - soutput = list_entry(list2, snd_rawmidi_substream_t, list); + soutput = list_entry(list2, struct snd_rawmidi_substream, list); if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { if (mode & SNDRV_RAWMIDI_LFLG_APPEND) { if (soutput->opened && !soutput->append) @@ -368,15 +369,15 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) { int maj = imajor(inode); int cardnum; - snd_card_t *card; + struct snd_card *card; int device, subdevice; unsigned short fflags; int err; - snd_rawmidi_t *rmidi; - snd_rawmidi_file_t *rawmidi_file; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_file *rawmidi_file; wait_queue_t wait; struct list_head *list; - snd_ctl_file_t *kctl; + struct snd_ctl_file *kctl; if (maj == snd_major) { cardnum = SNDRV_MINOR_CARD(iminor(inode)); @@ -465,11 +466,11 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) return err; } -int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile) +int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) { - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream; + struct snd_rawmidi_runtime *runtime; snd_assert(rfile != NULL, return -ENXIO); snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); @@ -515,8 +516,8 @@ int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile) static int snd_rawmidi_release(struct inode *inode, struct file *file) { - snd_rawmidi_file_t *rfile; - snd_rawmidi_t *rmidi; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi *rmidi; int err; rfile = file->private_data; @@ -528,9 +529,10 @@ static int snd_rawmidi_release(struct inode *inode, struct file *file) return err; } -int snd_rawmidi_info(snd_rawmidi_substream_t *substream, snd_rawmidi_info_t *info) +int snd_rawmidi_info(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_info *info) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; if (substream == NULL) return -ENODEV; @@ -550,22 +552,23 @@ int snd_rawmidi_info(snd_rawmidi_substream_t *substream, snd_rawmidi_info_t *inf return 0; } -static int snd_rawmidi_info_user(snd_rawmidi_substream_t *substream, snd_rawmidi_info_t __user * _info) +static int snd_rawmidi_info_user(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_info __user * _info) { - snd_rawmidi_info_t info; + struct snd_rawmidi_info info; int err; if ((err = snd_rawmidi_info(substream, &info)) < 0) return err; - if (copy_to_user(_info, &info, sizeof(snd_rawmidi_info_t))) + if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info))) return -EFAULT; return 0; } -int snd_rawmidi_info_select(snd_card_t *card, snd_rawmidi_info_t *info) +int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info) { - snd_rawmidi_t *rmidi; - snd_rawmidi_str_t *pstr; - snd_rawmidi_substream_t *substream; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_str *pstr; + struct snd_rawmidi_substream *substream; struct list_head *list; if (info->device >= SNDRV_RAWMIDI_DEVICES) return -ENXIO; @@ -578,18 +581,18 @@ int snd_rawmidi_info_select(snd_card_t *card, snd_rawmidi_info_t *info) if (info->subdevice >= pstr->substream_count) return -ENXIO; list_for_each(list, &pstr->substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); if ((unsigned int)substream->number == info->subdevice) return snd_rawmidi_info(substream, info); } return -ENXIO; } -static int snd_rawmidi_info_select_user(snd_card_t *card, - snd_rawmidi_info_t __user *_info) +static int snd_rawmidi_info_select_user(struct snd_card *card, + struct snd_rawmidi_info __user *_info) { int err; - snd_rawmidi_info_t info; + struct snd_rawmidi_info info; if (get_user(info.device, &_info->device)) return -EFAULT; if (get_user(info.stream, &_info->stream)) @@ -598,16 +601,16 @@ static int snd_rawmidi_info_select_user(snd_card_t *card, return -EFAULT; if ((err = snd_rawmidi_info_select(card, &info)) < 0) return err; - if (copy_to_user(_info, &info, sizeof(snd_rawmidi_info_t))) + if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info))) return -EFAULT; return 0; } -int snd_rawmidi_output_params(snd_rawmidi_substream_t * substream, - snd_rawmidi_params_t * params) +int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_params * params) { char *newbuf; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (substream->append && substream->use_count > 1) return -EBUSY; @@ -630,11 +633,11 @@ int snd_rawmidi_output_params(snd_rawmidi_substream_t * substream, return 0; } -int snd_rawmidi_input_params(snd_rawmidi_substream_t * substream, - snd_rawmidi_params_t * params) +int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_params * params) { char *newbuf; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_rawmidi_drain_input(substream); if (params->buffer_size < 32 || params->buffer_size > 1024L * 1024L) { @@ -654,10 +657,10 @@ int snd_rawmidi_input_params(snd_rawmidi_substream_t * substream, return 0; } -static int snd_rawmidi_output_status(snd_rawmidi_substream_t * substream, - snd_rawmidi_status_t * status) +static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_status * status) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; memset(status, 0, sizeof(*status)); status->stream = SNDRV_RAWMIDI_STREAM_OUTPUT; @@ -667,10 +670,10 @@ static int snd_rawmidi_output_status(snd_rawmidi_substream_t * substream, return 0; } -static int snd_rawmidi_input_status(snd_rawmidi_substream_t * substream, - snd_rawmidi_status_t * status) +static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_status * status) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; memset(status, 0, sizeof(*status)); status->stream = SNDRV_RAWMIDI_STREAM_INPUT; @@ -684,7 +687,7 @@ static int snd_rawmidi_input_status(snd_rawmidi_substream_t * substream, static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - snd_rawmidi_file_t *rfile; + struct snd_rawmidi_file *rfile; void __user *argp = (void __user *)arg; rfile = file->private_data; @@ -695,8 +698,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long return put_user(SNDRV_RAWMIDI_VERSION, (int __user *)argp) ? -EFAULT : 0; case SNDRV_RAWMIDI_IOCTL_INFO: { - snd_rawmidi_stream_t stream; - snd_rawmidi_info_t __user *info = argp; + int stream; + struct snd_rawmidi_info __user *info = argp; if (get_user(stream, &info->stream)) return -EFAULT; switch (stream) { @@ -710,8 +713,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long } case SNDRV_RAWMIDI_IOCTL_PARAMS: { - snd_rawmidi_params_t params; - if (copy_from_user(¶ms, argp, sizeof(snd_rawmidi_params_t))) + struct snd_rawmidi_params params; + if (copy_from_user(¶ms, argp, sizeof(struct snd_rawmidi_params))) return -EFAULT; switch (params.stream) { case SNDRV_RAWMIDI_STREAM_OUTPUT: @@ -729,8 +732,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long case SNDRV_RAWMIDI_IOCTL_STATUS: { int err = 0; - snd_rawmidi_status_t status; - if (copy_from_user(&status, argp, sizeof(snd_rawmidi_status_t))) + struct snd_rawmidi_status status; + if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status))) return -EFAULT; switch (status.stream) { case SNDRV_RAWMIDI_STREAM_OUTPUT: @@ -748,7 +751,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long } if (err < 0) return err; - if (copy_to_user(argp, &status, sizeof(snd_rawmidi_status_t))) + if (copy_to_user(argp, &status, sizeof(struct snd_rawmidi_status))) return -EFAULT; return 0; } @@ -792,8 +795,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long return -ENOTTY; } -static int snd_rawmidi_control_ioctl(snd_card_t * card, - snd_ctl_file_t * control, +static int snd_rawmidi_control_ioctl(struct snd_card *card, + struct snd_ctl_file *control, unsigned int cmd, unsigned long arg) { @@ -845,11 +848,12 @@ static int snd_rawmidi_control_ioctl(snd_card_t * card, * * Returns the size of read data, or a negative error code on failure. */ -int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const unsigned char *buffer, int count) +int snd_rawmidi_receive(struct snd_rawmidi_substream *substream, + const unsigned char *buffer, int count) { unsigned long flags; int result = 0, count1; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (runtime->buffer == NULL) { snd_printd("snd_rawmidi_receive: input is not active!!!\n"); @@ -904,12 +908,12 @@ int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const unsigned char return result; } -static long snd_rawmidi_kernel_read1(snd_rawmidi_substream_t *substream, +static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream, unsigned char *buf, long count, int kernel) { unsigned long flags; long result = 0, count1; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; while (count > 0 && runtime->avail) { count1 = runtime->buffer_size - runtime->appl_ptr; @@ -938,19 +942,21 @@ static long snd_rawmidi_kernel_read1(snd_rawmidi_substream_t *substream, return result; } -long snd_rawmidi_kernel_read(snd_rawmidi_substream_t *substream, unsigned char *buf, long count) +long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream, + unsigned char *buf, long count) { snd_rawmidi_input_trigger(substream, 1); return snd_rawmidi_kernel_read1(substream, buf, count, 1); } -static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t count, + loff_t *offset) { long result; int count1; - snd_rawmidi_file_t *rfile; - snd_rawmidi_substream_t *substream; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi_substream *substream; + struct snd_rawmidi_runtime *runtime; rfile = file->private_data; substream = rfile->input; @@ -998,9 +1004,9 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun * * Returns 1 if the internal output buffer is empty, 0 if not. */ -int snd_rawmidi_transmit_empty(snd_rawmidi_substream_t * substream) +int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; int result; unsigned long flags; @@ -1028,11 +1034,12 @@ int snd_rawmidi_transmit_empty(snd_rawmidi_substream_t * substream) * * Returns the size of copied data, or a negative error code on failure. */ -int snd_rawmidi_transmit_peek(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count) +int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, + unsigned char *buffer, int count) { unsigned long flags; int result, count1; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (runtime->buffer == NULL) { snd_printd("snd_rawmidi_transmit_peek: output is not active!!!\n"); @@ -1079,10 +1086,10 @@ int snd_rawmidi_transmit_peek(snd_rawmidi_substream_t * substream, unsigned char * * Returns the advanced size if successful, or a negative error code on failure. */ -int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count) +int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) { unsigned long flags; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (runtime->buffer == NULL) { snd_printd("snd_rawmidi_transmit_ack: output is not active!!!\n"); @@ -1112,7 +1119,8 @@ int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count) * * Returns the copied size if successful, or a negative error code on failure. */ -int snd_rawmidi_transmit(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count) +int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, + unsigned char *buffer, int count) { count = snd_rawmidi_transmit_peek(substream, buffer, count); if (count < 0) @@ -1120,11 +1128,12 @@ int snd_rawmidi_transmit(snd_rawmidi_substream_t * substream, unsigned char *buf return snd_rawmidi_transmit_ack(substream, count); } -static long snd_rawmidi_kernel_write1(snd_rawmidi_substream_t * substream, const unsigned char *buf, long count, int kernel) +static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream, + const unsigned char *buf, long count, int kernel) { unsigned long flags; long count1, result; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_assert(buf != NULL, return -EINVAL); snd_assert(runtime->buffer != NULL, return -EINVAL); @@ -1170,18 +1179,20 @@ static long snd_rawmidi_kernel_write1(snd_rawmidi_substream_t * substream, const return result; } -long snd_rawmidi_kernel_write(snd_rawmidi_substream_t * substream, const unsigned char *buf, long count) +long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream, + const unsigned char *buf, long count) { return snd_rawmidi_kernel_write1(substream, buf, count, 1); } -static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, + size_t count, loff_t *offset) { long result, timeout; int count1; - snd_rawmidi_file_t *rfile; - snd_rawmidi_runtime_t *runtime; - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi_runtime *runtime; + struct snd_rawmidi_substream *substream; rfile = file->private_data; substream = rfile->output; @@ -1246,8 +1257,8 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size static unsigned int snd_rawmidi_poll(struct file *file, poll_table * wait) { - snd_rawmidi_file_t *rfile; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi_runtime *runtime; unsigned int mask; rfile = file->private_data; @@ -1284,12 +1295,12 @@ static unsigned int snd_rawmidi_poll(struct file *file, poll_table * wait) */ -static void snd_rawmidi_proc_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream; + struct snd_rawmidi_runtime *runtime; struct list_head *list; rmidi = entry->private_data; @@ -1297,7 +1308,7 @@ static void snd_rawmidi_proc_info_read(snd_info_entry_t *entry, down(&rmidi->open_mutex); if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_iprintf(buffer, "Output %d\n" " Tx bytes : %lu\n", @@ -1317,7 +1328,7 @@ static void snd_rawmidi_proc_info_read(snd_info_entry_t *entry, } if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) { list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_iprintf(buffer, "Input %d\n" " Rx bytes : %lu\n", @@ -1354,18 +1365,18 @@ static struct file_operations snd_rawmidi_f_ops = .compat_ioctl = snd_rawmidi_ioctl_compat, }; -static snd_minor_t snd_rawmidi_reg = +static struct snd_minor snd_rawmidi_reg = { .comment = "raw midi", .f_ops = &snd_rawmidi_f_ops, }; -static int snd_rawmidi_alloc_substreams(snd_rawmidi_t *rmidi, - snd_rawmidi_str_t *stream, +static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, + struct snd_rawmidi_str *stream, int direction, int count) { - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_substream *substream; int idx; INIT_LIST_HEAD(&stream->substreams); @@ -1397,13 +1408,13 @@ static int snd_rawmidi_alloc_substreams(snd_rawmidi_t *rmidi, * * Returns zero if successful, or a negative error code on failure. */ -int snd_rawmidi_new(snd_card_t * card, char *id, int device, +int snd_rawmidi_new(struct snd_card *card, char *id, int device, int output_count, int input_count, - snd_rawmidi_t ** rrawmidi) + struct snd_rawmidi ** rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_rawmidi_dev_free, .dev_register = snd_rawmidi_dev_register, .dev_disconnect = snd_rawmidi_dev_disconnect, @@ -1438,18 +1449,18 @@ int snd_rawmidi_new(snd_card_t * card, char *id, int device, return 0; } -static void snd_rawmidi_free_substreams(snd_rawmidi_str_t *stream) +static void snd_rawmidi_free_substreams(struct snd_rawmidi_str *stream) { - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_substream *substream; while (!list_empty(&stream->substreams)) { - substream = list_entry(stream->substreams.next, snd_rawmidi_substream_t, list); + substream = list_entry(stream->substreams.next, struct snd_rawmidi_substream, list); list_del(&substream->list); kfree(substream); } } -static int snd_rawmidi_free(snd_rawmidi_t *rmidi) +static int snd_rawmidi_free(struct snd_rawmidi *rmidi) { snd_assert(rmidi != NULL, return -ENXIO); snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]); @@ -1460,26 +1471,26 @@ static int snd_rawmidi_free(snd_rawmidi_t *rmidi) return 0; } -static int snd_rawmidi_dev_free(snd_device_t *device) +static int snd_rawmidi_dev_free(struct snd_device *device) { - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; return snd_rawmidi_free(rmidi); } #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) -static void snd_rawmidi_dev_seq_free(snd_seq_device_t *device) +static void snd_rawmidi_dev_seq_free(struct snd_seq_device *device) { - snd_rawmidi_t *rmidi = device->private_data; + struct snd_rawmidi *rmidi = device->private_data; rmidi->seq_dev = NULL; } #endif -static int snd_rawmidi_dev_register(snd_device_t *device) +static int snd_rawmidi_dev_register(struct snd_device *device) { int idx, err; - snd_info_entry_t *entry; + struct snd_info_entry *entry; char name[16]; - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) return -ENOMEM; @@ -1554,9 +1565,9 @@ static int snd_rawmidi_dev_register(snd_device_t *device) return 0; } -static int snd_rawmidi_dev_disconnect(snd_device_t *device) +static int snd_rawmidi_dev_disconnect(struct snd_device *device) { - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; int idx; down(®ister_mutex); @@ -1566,10 +1577,10 @@ static int snd_rawmidi_dev_disconnect(snd_device_t *device) return 0; } -static int snd_rawmidi_dev_unregister(snd_device_t *device) +static int snd_rawmidi_dev_unregister(struct snd_device *device) { int idx; - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; snd_assert(rmidi != NULL, return -ENXIO); down(®ister_mutex); @@ -1613,13 +1624,14 @@ static int snd_rawmidi_dev_unregister(snd_device_t *device) * * Sets the rawmidi operators for the given stream direction. */ -void snd_rawmidi_set_ops(snd_rawmidi_t *rmidi, int stream, snd_rawmidi_ops_t *ops) +void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, + struct snd_rawmidi_ops *ops) { struct list_head *list; - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_substream *substream; list_for_each(list, &rmidi->streams[stream].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); substream->ops = ops; } } -- cgit v1.2.3-70-g09d2 From 73e77ba0235532bd7523ba90883d325f6e095acf Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:44:01 +0100 Subject: [ALSA] Add error messages Add error messages in the critial error path to be more verbose. Signed-off-by: Takashi Iwai --- sound/core/control.c | 8 ++++++-- sound/core/device.c | 5 ++++- sound/core/hwdep.c | 7 ++++--- sound/core/pcm.c | 16 +++++++++++----- sound/core/rawmidi.c | 18 ++++++++++++++---- sound/core/timer.c | 4 +++- sound/drivers/mpu401/mpu401_uart.c | 1 + sound/drivers/opl3/opl3_lib.c | 4 +++- sound/isa/opl3sa2.c | 27 ++++++++++++++++++++------- 9 files changed, 66 insertions(+), 24 deletions(-) (limited to 'sound/core/rawmidi.c') diff --git a/sound/core/control.c b/sound/core/control.c index 03ae9bb7d38..f8f98cc5241 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -195,8 +195,10 @@ struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, unsigned int acce snd_assert(control != NULL, return NULL); snd_assert(control->count > 0, return NULL); kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL); - if (kctl == NULL) + if (kctl == NULL) { + snd_printk(KERN_ERR "Cannot allocate control instance\n"); return NULL; + } *kctl = *control; for (idx = 0; idx < kctl->count; idx++) kctl->vd[idx].access = access; @@ -309,7 +311,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) struct snd_ctl_elem_id id; unsigned int idx; - snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); + snd_assert(card != NULL, return -EINVAL); + if (! kcontrol) + return -EINVAL; snd_assert(kcontrol->info != NULL, return -EINVAL); id = kcontrol->id; down_write(&card->controls_rwsem); diff --git a/sound/core/device.c b/sound/core/device.c index afa8cc7fb05..b1cf6ec5678 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -50,8 +50,10 @@ int snd_device_new(struct snd_card *card, snd_device_type_t type, snd_assert(device_data != NULL, return -ENXIO); snd_assert(ops != NULL, return -ENXIO); dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) + if (dev == NULL) { + snd_printk(KERN_ERR "Cannot allocate device\n"); return -ENOMEM; + } dev->card = card; dev->type = type; dev->state = SNDRV_DEV_BUILD; @@ -173,6 +175,7 @@ int snd_device_register(struct snd_card *card, void *device_data) dev->state = SNDRV_DEV_REGISTERED; return 0; } + snd_printd("snd_device_register busy\n"); return -EBUSY; } snd_BUG(); diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index da0fb9f0841..444e266e7c4 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -364,13 +364,14 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, *rhwdep = NULL; snd_assert(card != NULL, return -ENXIO); hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL); - if (hwdep == NULL) + if (hwdep == NULL) { + snd_printk(KERN_ERR "hwdep: cannot allocate\n"); return -ENOMEM; + } hwdep->card = card; hwdep->device = device; - if (id) { + if (id) strlcpy(hwdep->id, id, sizeof(hwdep->id)); - } #ifdef CONFIG_SND_OSSEMUL hwdep->oss_type = -1; #endif diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 59c995bbf15..9305ac357a3 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -600,14 +600,18 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) pstr->reg = &snd_pcm_reg[stream]; if (substream_count > 0) { err = snd_pcm_stream_proc_init(pstr); - if (err < 0) + if (err < 0) { + snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); return err; + } } prev = NULL; for (idx = 0, prev = NULL; idx < substream_count; idx++) { substream = kzalloc(sizeof(*substream), GFP_KERNEL); - if (substream == NULL) + if (substream == NULL) { + snd_printk(KERN_ERR "Cannot allocate PCM substream\n"); return -ENOMEM; + } substream->pcm = pcm; substream->pstr = pstr; substream->number = idx; @@ -620,6 +624,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) prev->next = substream; err = snd_pcm_substream_proc_init(substream); if (err < 0) { + snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); kfree(substream); return err; } @@ -666,13 +671,14 @@ int snd_pcm_new(struct snd_card *card, char *id, int device, *rpcm = NULL; snd_assert(card != NULL, return -ENXIO); pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); - if (pcm == NULL) + if (pcm == NULL) { + snd_printk(KERN_ERR "Cannot allocate PCM\n"); return -ENOMEM; + } pcm->card = card; pcm->device = device; - if (id) { + if (id) strlcpy(pcm->id, id, sizeof(pcm->id)); - } if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) { snd_pcm_free(pcm); return err; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index ede0a6083d2..7a86a9a08a1 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1382,8 +1382,10 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, INIT_LIST_HEAD(&stream->substreams); for (idx = 0; idx < count; idx++) { substream = kzalloc(sizeof(*substream), GFP_KERNEL); - if (substream == NULL) + if (substream == NULL) { + snd_printk(KERN_ERR "rawmidi: cannot allocate substream\n"); return -ENOMEM; + } substream->stream = direction; substream->number = idx; substream->rmidi = rmidi; @@ -1425,19 +1427,27 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, *rrawmidi = NULL; snd_assert(card != NULL, return -ENXIO); rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); - if (rmidi == NULL) + if (rmidi == NULL) { + snd_printk(KERN_ERR "rawmidi: cannot allocate\n"); return -ENOMEM; + } rmidi->card = card; rmidi->device = device; init_MUTEX(&rmidi->open_mutex); init_waitqueue_head(&rmidi->open_wait); if (id != NULL) strlcpy(rmidi->id, id, sizeof(rmidi->id)); - if ((err = snd_rawmidi_alloc_substreams(rmidi, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], SNDRV_RAWMIDI_STREAM_INPUT, input_count)) < 0) { + if ((err = snd_rawmidi_alloc_substreams(rmidi, + &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], + SNDRV_RAWMIDI_STREAM_INPUT, + input_count)) < 0) { snd_rawmidi_free(rmidi); return err; } - if ((err = snd_rawmidi_alloc_substreams(rmidi, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT], SNDRV_RAWMIDI_STREAM_OUTPUT, output_count)) < 0) { + if ((err = snd_rawmidi_alloc_substreams(rmidi, + &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT], + SNDRV_RAWMIDI_STREAM_OUTPUT, + output_count)) < 0) { snd_rawmidi_free(rmidi); return err; } diff --git a/sound/core/timer.c b/sound/core/timer.c index 18d43a03785..74637cef6d2 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -777,8 +777,10 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, snd_assert(rtimer != NULL, return -EINVAL); *rtimer = NULL; timer = kzalloc(sizeof(*timer), GFP_KERNEL); - if (timer == NULL) + if (timer == NULL) { + snd_printk(KERN_ERR "timer: cannot allocate\n"); return -ENOMEM; + } timer->tmr_class = tid->dev_class; timer->card = card; timer->tmr_device = tid->device; diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 16e87f31788..ee67b522d25 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -462,6 +462,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, return err; mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); if (mpu == NULL) { + snd_printk(KERN_ERR "mpu401_uart: cannot allocate\n"); snd_device_free(card, rmidi); return -ENOMEM; } diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index cbd37e91960..650f3b8e60e 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -349,8 +349,10 @@ int snd_opl3_new(struct snd_card *card, *ropl3 = NULL; opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL); - if (opl3 == NULL) + if (opl3 == NULL) { + snd_printk(KERN_ERR "opl3: cannot allocate\n"); return -ENOMEM; + } opl3->card = card; opl3->hardware = hardware; diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index b923de9b321..aafe5565b6e 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -496,21 +496,29 @@ static int __init snd_opl3sa2_mixer(struct snd_opl3sa2 *chip) /* reassign AUX0 to CD */ strcpy(id1.name, "Aux Playback Switch"); strcpy(id2.name, "CD Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } strcpy(id1.name, "Aux Playback Volume"); strcpy(id2.name, "CD Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } /* reassign AUX1 to FM */ strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; strcpy(id2.name, "FM Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } strcpy(id1.name, "Aux Playback Volume"); strcpy(id2.name, "FM Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } /* add OPL3SA2 controls */ for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) { if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0) @@ -575,8 +583,10 @@ static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, int err; cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); - if (!cfg) + if (!cfg) { + snd_printk(KERN_ERR PFX "cannot allocate pnp cfg\n"); return -ENOMEM; + } /* PnP initialization */ pnp_init_resource_table(cfg); if (sb_port[dev] != SNDRV_AUTO_PORT) @@ -597,7 +607,7 @@ static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); err = pnp_manual_config_dev(pdev, cfg, 0); if (err < 0) - snd_printk(KERN_ERR "PnP manual resources are invalid, using auto config\n"); + snd_printk(KERN_WARNING "PnP manual resources are invalid, using auto config\n"); err = pnp_activate_dev(pdev); if (err < 0) { kfree(cfg); @@ -784,8 +794,11 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, struct snd_card *card; pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL); - if (pdev == NULL) + if (pdev == NULL) { + snd_printk(KERN_ERR PFX "can't get pnp device from id '%s'\n", + id->devs[0].id); return -EBUSY; + } for (; dev < SNDRV_CARDS; dev++) { if (enable[dev] && isapnp[dev]) break; -- cgit v1.2.3-70-g09d2 From a106cd3d9e88c8761bd0eac2ce402cc82bd11fea Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 13:59:56 +0100 Subject: [ALSA] rawmidi: protect against invalid device number in snd_rawmidi_info_select() Modules: RawMidi Midlevel In snd_rawmidi_info_select(), check that the device identified by the passed device number actually exists. Signed-off-by: Clemens Ladisch --- sound/core/rawmidi.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound/core/rawmidi.c') diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 7a86a9a08a1..d703545cae8 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -573,6 +573,8 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info if (info->device >= SNDRV_RAWMIDI_DEVICES) return -ENXIO; rmidi = snd_rawmidi_devices[card->number * SNDRV_RAWMIDI_DEVICES + info->device]; + if (!rmidi) + return -ENXIO; if (info->stream < 0 || info->stream > 1) return -EINVAL; pstr = &rmidi->streams[info->stream]; -- cgit v1.2.3-70-g09d2 From 2af677fc884fc6dc79e65c99050ea607ac8bab9b Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:03:48 +0100 Subject: [ALSA] dynamic minors (1/6): store device type in struct snd_minor Instead of a comment string, store the device type in the snd_minor structure. This makes snd_minor more flexible, and has the nice side effect that we don't need anymore to create a separate snd_minor template for registering a device but can pass the file_operations directly to snd_register_device(). Signed-off-by: Clemens Ladisch --- include/sound/core.h | 8 ++++--- include/sound/pcm.h | 3 +-- sound/core/control.c | 11 +++------ sound/core/hwdep.c | 11 +++------ sound/core/oss/mixer_oss.c | 8 +------ sound/core/oss/pcm_oss.c | 8 +------ sound/core/pcm.c | 6 +++-- sound/core/pcm_native.c | 53 +++++++++++++++++------------------------- sound/core/rawmidi.c | 14 ++++------- sound/core/seq/oss/seq_oss.c | 9 ++----- sound/core/seq/seq_clientmgr.c | 10 ++------ sound/core/sound.c | 38 ++++++++++++++++++++++++------ sound/core/sound_oss.c | 35 ++++++++++++++++++++++------ sound/core/timer.c | 8 +------ 14 files changed, 108 insertions(+), 114 deletions(-) (limited to 'sound/core/rawmidi.c') diff --git a/include/sound/core.h b/include/sound/core.h index f00b9c9b567..f557c8ac450 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -185,8 +185,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru struct snd_minor { struct list_head list; /* list of all minors per card */ int number; /* minor number */ + int type; /* SNDRV_DEVICE_TYPE_XXX */ int device; /* device number */ - const char *comment; /* for /proc/asound/devices */ struct file_operations *f_ops; /* file operations */ char name[0]; /* device name (keep at the end of structure) */ @@ -199,11 +199,13 @@ extern int snd_ecards_limit; void snd_request_card(int card); -int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); +int snd_register_device(int type, struct snd_card *card, int dev, + struct file_operations *f_ops, const char *name); int snd_unregister_device(int type, struct snd_card *card, int dev); #ifdef CONFIG_SND_OSSEMUL -int snd_register_oss_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); +int snd_register_oss_device(int type, struct snd_card *card, int dev, + struct file_operations *f_ops, const char *name); int snd_unregister_oss_device(int type, struct snd_card *card, int dev); #endif diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 7e77c0add80..5e29b0e0f21 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -402,7 +402,6 @@ struct snd_pcm_str { struct snd_pcm_oss_stream oss; #endif struct snd_pcm_file *files; - struct snd_minor *reg; struct snd_info_entry *proc_root; struct snd_info_entry *proc_info_entry; #ifdef CONFIG_SND_DEBUG @@ -441,7 +440,7 @@ struct snd_pcm_notify { */ extern struct snd_pcm *snd_pcm_devices[]; -extern struct snd_minor snd_pcm_reg[2]; +extern struct file_operations snd_pcm_f_ops[2]; int snd_pcm_new(struct snd_card *card, char *id, int device, int playback_count, int capture_count, diff --git a/sound/core/control.c b/sound/core/control.c index f8f98cc5241..23561e74712 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1264,12 +1264,6 @@ static struct file_operations snd_ctl_f_ops = .fasync = snd_ctl_fasync, }; -static struct snd_minor snd_ctl_reg = -{ - .comment = "ctl", - .f_ops = &snd_ctl_f_ops, -}; - /* * registration of the control device */ @@ -1284,7 +1278,7 @@ static int snd_ctl_dev_register(struct snd_device *device) snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); sprintf(name, "controlC%i", cardnum); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, - card, 0, &snd_ctl_reg, name)) < 0) + card, -1, &snd_ctl_f_ops, name)) < 0) return err; return 0; } @@ -1336,7 +1330,8 @@ static int snd_ctl_dev_unregister(struct snd_device *device) snd_assert(card != NULL, return -ENXIO); cardnum = card->number; snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); - if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, 0)) < 0) + if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, + card, -1)) < 0) return err; return snd_ctl_dev_free(device); } diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 444e266e7c4..27d5bf7266f 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -330,12 +330,6 @@ static struct file_operations snd_hwdep_f_ops = .mmap = snd_hwdep_mmap, }; -static struct snd_minor snd_hwdep_reg = -{ - .comment = "hardware dependent", - .f_ops = &snd_hwdep_f_ops, -}; - /** * snd_hwdep_new - create a new hwdep instance * @card: the card instance @@ -416,7 +410,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device, - &snd_hwdep_reg, name)) < 0) { + &snd_hwdep_f_ops, name)) < 0) { snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", hwdep->card->number, hwdep->device); snd_hwdep_devices[idx] = NULL; @@ -431,7 +425,8 @@ static int snd_hwdep_dev_register(struct snd_device *device) } else { if (snd_register_oss_device(hwdep->oss_type, hwdep->card, hwdep->device, - &snd_hwdep_reg, hwdep->oss_dev) < 0) { + &snd_hwdep_f_ops, + hwdep->oss_dev) < 0) { snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n", hwdep->card->number, hwdep->device); } else diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index e448002ca7b..2dd6bf9b49e 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -398,12 +398,6 @@ static struct file_operations snd_mixer_oss_f_ops = .compat_ioctl = snd_mixer_oss_ioctl_compat, }; -static struct snd_minor snd_mixer_oss_reg = -{ - .comment = "mixer", - .f_ops = &snd_mixer_oss_f_ops, -}; - /* * utilities */ @@ -1292,7 +1286,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) sprintf(name, "mixer%i%i", card->number, 0); if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, card, 0, - &snd_mixer_oss_reg, + &snd_mixer_oss_f_ops, name)) < 0) { snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", card->number, 0); diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index ffc13b9194b..947bf08df42 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -2444,18 +2444,12 @@ static struct file_operations snd_pcm_oss_f_reg = .mmap = snd_pcm_oss_mmap, }; -static struct snd_minor snd_pcm_oss_reg = -{ - .comment = "digital audio", - .f_ops = &snd_pcm_oss_f_reg, -}; - static void register_oss_dsp(struct snd_pcm *pcm, int index) { char name[128]; sprintf(name, "dsp%i%i", pcm->card->number, pcm->device); if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, - pcm->card, index, &snd_pcm_oss_reg, + pcm->card, index, &snd_pcm_oss_f_reg, name) < 0) { snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n", pcm->card->number, pcm->device); diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 9305ac357a3..2bc5f69ec2a 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -597,7 +597,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) pstr->stream = stream; pstr->pcm = pcm; pstr->substream_count = substream_count; - pstr->reg = &snd_pcm_reg[stream]; if (substream_count > 0) { err = snd_pcm_stream_proc_init(pstr); if (err < 0) { @@ -897,7 +896,10 @@ static int snd_pcm_dev_register(struct snd_device *device) devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; break; } - if ((err = snd_register_device(devtype, pcm->card, pcm->device, pcm->streams[cidx].reg, str)) < 0) { + if ((err = snd_register_device(devtype, pcm->card, + pcm->device, + &snd_pcm_f_ops[cidx], str)) < 0) + { snd_pcm_devices[idx] = NULL; up(®ister_mutex); return err; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 7bac1cbe38d..bb40c016135 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3370,40 +3370,29 @@ out: * Register section */ -static struct file_operations snd_pcm_f_ops_playback = { - .owner = THIS_MODULE, - .write = snd_pcm_write, - .writev = snd_pcm_writev, - .open = snd_pcm_open, - .release = snd_pcm_release, - .poll = snd_pcm_playback_poll, - .unlocked_ioctl = snd_pcm_playback_ioctl, - .compat_ioctl = snd_pcm_ioctl_compat, - .mmap = snd_pcm_mmap, - .fasync = snd_pcm_fasync, -}; - -static struct file_operations snd_pcm_f_ops_capture = { - .owner = THIS_MODULE, - .read = snd_pcm_read, - .readv = snd_pcm_readv, - .open = snd_pcm_open, - .release = snd_pcm_release, - .poll = snd_pcm_capture_poll, - .unlocked_ioctl = snd_pcm_capture_ioctl, - .compat_ioctl = snd_pcm_ioctl_compat, - .mmap = snd_pcm_mmap, - .fasync = snd_pcm_fasync, -}; - -struct snd_minor snd_pcm_reg[2] = -{ +struct file_operations snd_pcm_f_ops[2] = { { - .comment = "digital audio playback", - .f_ops = &snd_pcm_f_ops_playback, + .owner = THIS_MODULE, + .write = snd_pcm_write, + .writev = snd_pcm_writev, + .open = snd_pcm_open, + .release = snd_pcm_release, + .poll = snd_pcm_playback_poll, + .unlocked_ioctl = snd_pcm_playback_ioctl, + .compat_ioctl = snd_pcm_ioctl_compat, + .mmap = snd_pcm_mmap, + .fasync = snd_pcm_fasync, }, { - .comment = "digital audio capture", - .f_ops = &snd_pcm_f_ops_capture, + .owner = THIS_MODULE, + .read = snd_pcm_read, + .readv = snd_pcm_readv, + .open = snd_pcm_open, + .release = snd_pcm_release, + .poll = snd_pcm_capture_poll, + .unlocked_ioctl = snd_pcm_capture_ioctl, + .compat_ioctl = snd_pcm_ioctl_compat, + .mmap = snd_pcm_mmap, + .fasync = snd_pcm_fasync, } }; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index d703545cae8..7ac77e5ddcb 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1367,12 +1367,6 @@ static struct file_operations snd_rawmidi_f_ops = .compat_ioctl = snd_rawmidi_ioctl_compat, }; -static struct snd_minor snd_rawmidi_reg = -{ - .comment = "raw midi", - .f_ops = &snd_rawmidi_f_ops, -}; - static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, struct snd_rawmidi_str *stream, int direction, @@ -1516,7 +1510,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device, - &snd_rawmidi_reg, name)) < 0) { + &snd_rawmidi_f_ops, name)) < 0) { snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); snd_rawmidi_devices[idx] = NULL; up(®ister_mutex); @@ -1533,7 +1527,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) rmidi->ossreg = 0; if ((int)rmidi->device == midi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 0, &snd_rawmidi_reg, name) < 0) { + rmidi->card, 0, + &snd_rawmidi_f_ops, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0); } else { rmidi->ossreg++; @@ -1544,7 +1539,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) } if ((int)rmidi->device == amidi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 1, &snd_rawmidi_reg, name) < 0) { + rmidi->card, 1, + &snd_rawmidi_f_ops, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1); } else { rmidi->ossreg++; diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 2371e41b13e..61c0a41376f 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -217,11 +217,6 @@ static struct file_operations seq_oss_f_ops = .compat_ioctl = odev_ioctl_compat, }; -static struct snd_minor seq_oss_reg = { - .comment = "sequencer", - .f_ops = &seq_oss_f_ops, -}; - static int __init register_device(void) { @@ -230,7 +225,7 @@ register_device(void) down(®ister_mutex); if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0, - &seq_oss_reg, + &seq_oss_f_ops, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device seq\n"); up(®ister_mutex); @@ -238,7 +233,7 @@ register_device(void) } if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0, - &seq_oss_reg, + &seq_oss_f_ops, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device music\n"); snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 5eab4201c64..087fdf32732 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2520,13 +2520,6 @@ static struct file_operations snd_seq_f_ops = .compat_ioctl = snd_seq_ioctl_compat, }; -static struct snd_minor snd_seq_reg = -{ - .comment = "sequencer", - .f_ops = &snd_seq_f_ops, -}; - - /* * register sequencer device */ @@ -2537,7 +2530,8 @@ int __init snd_sequencer_device_init(void) if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, &snd_seq_reg, "seq")) < 0) { + if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, + &snd_seq_f_ops, "seq")) < 0) { up(®ister_mutex); return err; } diff --git a/sound/core/sound.c b/sound/core/sound.c index fb236a6b9c3..798c24c2de2 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -195,7 +195,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * @type: the device type, SNDRV_DEVICE_TYPE_XXX * @card: the card instance * @dev: the device index - * @reg: the struct snd_minor record + * @f_ops: the file operations * @name: the device file name * * Registers an ALSA device file for the given card. @@ -203,7 +203,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * * Retrurns zero if successful, or a negative error code on failure. */ -int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor * reg, const char *name) +int snd_register_device(int type, struct snd_card *card, int dev, + struct file_operations *f_ops, const char *name) { int minor = snd_kernel_minor(type, card, dev); struct snd_minor *preg; @@ -212,12 +213,13 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct snd_min if (minor < 0) return minor; snd_assert(name, return -EINVAL); - preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); + preg = kzalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); if (preg == NULL) return -ENOMEM; - *preg = *reg; preg->number = minor; + preg->type = type; preg->device = dev; + preg->f_ops = f_ops; strcpy(preg->name, name); down(&sound_mutex); if (snd_minor_search(minor)) { @@ -276,6 +278,28 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) static struct snd_info_entry *snd_minor_info_entry = NULL; +static const char *snd_device_type_name(int type) +{ + switch (type) { + case SNDRV_DEVICE_TYPE_CONTROL: + return "control"; + case SNDRV_DEVICE_TYPE_HWDEP: + return "hardware dependent"; + case SNDRV_DEVICE_TYPE_RAWMIDI: + return "raw midi"; + case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: + return "digital audio playback"; + case SNDRV_DEVICE_TYPE_PCM_CAPTURE: + return "digital audio capture"; + case SNDRV_DEVICE_TYPE_SEQUENCER: + return "sequencer"; + case SNDRV_DEVICE_TYPE_TIMER: + return "timer"; + default: + return "?"; + } +} + static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { int card, device; @@ -288,11 +312,11 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu mptr = list_entry(list, struct snd_minor, list); if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) { if ((device = mptr->device) >= 0) - snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, mptr->comment); + snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, snd_device_type_name(mptr->type)); else - snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, mptr->comment); + snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, snd_device_type_name(mptr->type)); } else { - snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment); + snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_device_type_name(mptr->type)); } } } diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index ec37604ffb6..4d189ffaa76 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -91,7 +91,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) } int snd_register_oss_device(int type, struct snd_card *card, int dev, - struct snd_minor * reg, const char *name) + struct file_operations *f_ops, const char *name) { int minor = snd_oss_kernel_minor(type, card, dev); int minor_unit; @@ -103,12 +103,13 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, if (minor < 0) return minor; - preg = (struct snd_minor *)kmalloc(sizeof(struct snd_minor), GFP_KERNEL); + preg = kzalloc(sizeof(struct snd_minor), GFP_KERNEL); if (preg == NULL) return -ENOMEM; - *preg = *reg; preg->number = minor; + preg->type = type; preg->device = dev; + preg->f_ops = f_ops; down(&sound_oss_mutex); list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]); minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); @@ -125,11 +126,12 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, } if (card) carddev = card->dev; - register1 = register_sound_special_device(reg->f_ops, minor, carddev); + register1 = register_sound_special_device(f_ops, minor, carddev); if (register1 != minor) goto __end; if (track2 >= 0) { - register2 = register_sound_special_device(reg->f_ops, track2, carddev); + register2 = register_sound_special_device(f_ops, track2, + carddev); if (register2 != track2) goto __end; } @@ -190,6 +192,25 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) static struct snd_info_entry *snd_minor_info_oss_entry = NULL; +static const char *snd_oss_device_type_name(int type) +{ + switch (type) { + case SNDRV_OSS_DEVICE_TYPE_MIXER: + return "mixer"; + case SNDRV_OSS_DEVICE_TYPE_SEQUENCER: + case SNDRV_OSS_DEVICE_TYPE_MUSIC: + return "sequencer"; + case SNDRV_OSS_DEVICE_TYPE_PCM: + return "digital audio"; + case SNDRV_OSS_DEVICE_TYPE_MIDI: + return "raw midi"; + case SNDRV_OSS_DEVICE_TYPE_DMFM: + return "hardware dependent"; + default: + return "?"; + } +} + static void snd_minor_info_oss_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { @@ -205,9 +226,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry, if (dev != SNDRV_MINOR_OSS_SNDSTAT && dev != SNDRV_MINOR_OSS_SEQUENCER && dev != SNDRV_MINOR_OSS_MUSIC) - snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, mptr->comment); + snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, snd_oss_device_type_name(mptr->type)); else - snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment); + snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_oss_device_type_name(mptr->type)); } } up(&sound_oss_mutex); diff --git a/sound/core/timer.c b/sound/core/timer.c index 6aad411dd7b..a7bcb04263c 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1924,12 +1924,6 @@ static struct file_operations snd_timer_f_ops = .fasync = snd_timer_user_fasync, }; -static struct snd_minor snd_timer_reg = -{ - .comment = "timer", - .f_ops = &snd_timer_f_ops, -}; - /* * ENTRY functions */ @@ -1959,7 +1953,7 @@ static int __init alsa_timer_init(void) snd_printk(KERN_ERR "unable to register system timer (%i)\n", err); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, - NULL, 0, &snd_timer_reg, "timer"))<0) + NULL, 0, &snd_timer_f_ops, "timer")) < 0) snd_printk(KERN_ERR "unable to register timer device (%i)\n", err); return 0; -- cgit v1.2.3-70-g09d2 From f87135f56cb266e031f5ec081dfbde7e43f55e80 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:06:59 +0100 Subject: [ALSA] dynamic minors (3/6): store device-specific object pointers dynamically Instead of storing the pointers to the device-specific structures in an array, put them into the struct snd_minor, and look them up dynamically. This makes the device type modules independent of the minor number encoding. Signed-off-by: Clemens Ladisch --- include/sound/core.h | 9 +++- include/sound/hwdep.h | 1 + include/sound/pcm.h | 2 +- include/sound/rawmidi.h | 6 +-- sound/core/control.c | 7 ++- sound/core/hwdep.c | 91 +++++++++++++++---------------- sound/core/oss/mixer_oss.c | 7 +-- sound/core/oss/pcm_oss.c | 14 ++--- sound/core/pcm.c | 118 +++++++++++++++++++++++------------------ sound/core/pcm_native.c | 40 +++++++++----- sound/core/rawmidi.c | 87 +++++++++++++++--------------- sound/core/seq/oss/seq_oss.c | 4 +- sound/core/seq/seq_clientmgr.c | 2 +- sound/core/seq/seq_midi.c | 10 +++- sound/core/sound.c | 46 +++++++++++++--- sound/core/sound_oss.c | 27 ++++++++-- sound/core/timer.c | 4 +- 17 files changed, 278 insertions(+), 197 deletions(-) (limited to 'sound/core/rawmidi.c') diff --git a/include/sound/core.h b/include/sound/core.h index 67b0a7e764e..90ac6132ea3 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -187,6 +187,7 @@ struct snd_minor { int card; /* card number */ int device; /* device number */ struct file_operations *f_ops; /* file operations */ + void *private_data; /* private data for f_ops->open */ char name[0]; /* device name (keep at the end of structure) */ }; @@ -199,13 +200,17 @@ extern int snd_ecards_limit; void snd_request_card(int card); int snd_register_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name); + struct file_operations *f_ops, void *private_data, + const char *name); int snd_unregister_device(int type, struct snd_card *card, int dev); +void *snd_lookup_minor_data(unsigned int minor, int type); #ifdef CONFIG_SND_OSSEMUL int snd_register_oss_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name); + struct file_operations *f_ops, void *private_data, + const char *name); int snd_unregister_oss_device(int type, struct snd_card *card, int dev); +void *snd_lookup_oss_minor_data(unsigned int minor, int type); #endif int snd_minor_info_init(void); diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h index 04b20bc4f14..c679e5b3111 100644 --- a/include/sound/hwdep.h +++ b/include/sound/hwdep.h @@ -43,6 +43,7 @@ struct snd_hwdep_ops { struct snd_hwdep { struct snd_card *card; + struct list_head list; int device; char id[32]; char name[80]; diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 5e29b0e0f21..314268a1104 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -412,6 +412,7 @@ struct snd_pcm_str { struct snd_pcm { struct snd_card *card; + struct list_head list; unsigned int device; /* device number */ unsigned int info_flags; unsigned short dev_class; @@ -439,7 +440,6 @@ struct snd_pcm_notify { * Registering */ -extern struct snd_pcm *snd_pcm_devices[]; extern struct file_operations snd_pcm_f_ops[2]; int snd_pcm_new(struct snd_card *card, char *id, int device, diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h index 9492a32c102..d19bddfbf99 100644 --- a/include/sound/rawmidi.h +++ b/include/sound/rawmidi.h @@ -113,7 +113,7 @@ struct snd_rawmidi_str { struct snd_rawmidi { struct snd_card *card; - + struct list_head list; unsigned int device; /* device number */ unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */ char id[64]; @@ -165,8 +165,8 @@ int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, /* main midi functions */ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info); -int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, int mode, - struct snd_rawmidi_file *rfile); +int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, + int mode, struct snd_rawmidi_file *rfile); int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile); int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, struct snd_rawmidi_params *params); diff --git a/sound/core/control.c b/sound/core/control.c index 23561e74712..abd62f94372 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -47,13 +47,12 @@ static LIST_HEAD(snd_control_compat_ioctls); static int snd_ctl_open(struct inode *inode, struct file *file) { - int cardnum = SNDRV_MINOR_CARD(iminor(inode)); unsigned long flags; struct snd_card *card; struct snd_ctl_file *ctl; int err; - card = snd_cards[cardnum]; + card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL); if (!card) { err = -ENODEV; goto __error1; @@ -1277,8 +1276,8 @@ static int snd_ctl_dev_register(struct snd_device *device) cardnum = card->number; snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); sprintf(name, "controlC%i", cardnum); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, - card, -1, &snd_ctl_f_ops, name)) < 0) + if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, + &snd_ctl_f_ops, card, name)) < 0) return err; return 0; } diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 27d5bf7266f..b8c0c8c4d12 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -35,8 +35,7 @@ MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Hardware dependent layer"); MODULE_LICENSE("GPL"); -static struct snd_hwdep *snd_hwdep_devices[SNDRV_CARDS * SNDRV_MINOR_HWDEPS]; - +static LIST_HEAD(snd_hwdep_devices); static DECLARE_MUTEX(register_mutex); static int snd_hwdep_free(struct snd_hwdep *hwdep); @@ -44,9 +43,19 @@ static int snd_hwdep_dev_free(struct snd_device *device); static int snd_hwdep_dev_register(struct snd_device *device); static int snd_hwdep_dev_unregister(struct snd_device *device); -/* - */ +static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device) +{ + struct list_head *p; + struct snd_hwdep *hwdep; + + list_for_each(p, &snd_hwdep_devices) { + hwdep = list_entry(p, struct snd_hwdep, list); + if (hwdep->card == card && hwdep->device == device) + return hwdep; + } + return NULL; +} static loff_t snd_hwdep_llseek(struct file * file, loff_t offset, int orig) { @@ -77,34 +86,25 @@ static ssize_t snd_hwdep_write(struct file * file, const char __user *buf, static int snd_hwdep_open(struct inode *inode, struct file * file) { int major = imajor(inode); - int cardnum; - int device; struct snd_hwdep *hw; int err; wait_queue_t wait; if (major == snd_major) { - cardnum = SNDRV_MINOR_CARD(iminor(inode)); - device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_HWDEP; + hw = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_HWDEP); #ifdef CONFIG_SND_OSSEMUL } else if (major == SOUND_MAJOR) { - cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode)); - device = 0; + hw = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_DMFM); #endif } else return -ENXIO; - cardnum %= SNDRV_CARDS; - device %= SNDRV_MINOR_HWDEPS; - hw = snd_hwdep_devices[(cardnum * SNDRV_MINOR_HWDEPS) + device]; if (hw == NULL) return -ENODEV; if (!hw->ops.open) return -ENXIO; -#ifdef CONFIG_SND_OSSEMUL - if (major == SOUND_MAJOR && hw->oss_type < 0) - return -ENXIO; -#endif if (!try_module_get(hw->card->module)) return -EFAULT; @@ -265,9 +265,6 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, struct snd_ctl_file * control, unsigned int cmd, unsigned long arg) { - unsigned int tmp; - - tmp = card->number * SNDRV_MINOR_HWDEPS; switch (cmd) { case SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE: { @@ -275,14 +272,16 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)arg)) return -EFAULT; + down(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_MINOR_HWDEPS) { - if (snd_hwdep_devices[tmp + device]) + if (snd_hwdep_search(card, device)) break; device++; } if (device >= SNDRV_MINOR_HWDEPS) device = -1; + up(®ister_mutex); if (put_user(device, (int __user *)arg)) return -EFAULT; return 0; @@ -290,17 +289,19 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, case SNDRV_CTL_IOCTL_HWDEP_INFO: { struct snd_hwdep_info __user *info = (struct snd_hwdep_info __user *)arg; - int device; + int device, err; struct snd_hwdep *hwdep; if (get_user(device, &info->device)) return -EFAULT; - if (device < 0 || device >= SNDRV_MINOR_HWDEPS) - return -ENXIO; - hwdep = snd_hwdep_devices[tmp + device]; - if (hwdep == NULL) - return -ENXIO; - return snd_hwdep_info(hwdep, info); + down(®ister_mutex); + hwdep = snd_hwdep_search(card, device); + if (hwdep) + err = snd_hwdep_info(hwdep, info); + else + err = -ENXIO; + up(®ister_mutex); + return err; } } return -ENOIOCTLCMD; @@ -397,23 +398,22 @@ static int snd_hwdep_dev_free(struct snd_device *device) static int snd_hwdep_dev_register(struct snd_device *device) { struct snd_hwdep *hwdep = device->device_data; - int idx, err; + int err; char name[32]; down(®ister_mutex); - idx = (hwdep->card->number * SNDRV_MINOR_HWDEPS) + hwdep->device; - if (snd_hwdep_devices[idx]) { + if (snd_hwdep_search(hwdep->card, hwdep->device)) { up(®ister_mutex); return -EBUSY; } - snd_hwdep_devices[idx] = hwdep; + list_add_tail(&hwdep->list, &snd_hwdep_devices); sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device, - &snd_hwdep_f_ops, name)) < 0) { + &snd_hwdep_f_ops, hwdep, name)) < 0) { snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", hwdep->card->number, hwdep->device); - snd_hwdep_devices[idx] = NULL; + list_del(&hwdep->list); up(®ister_mutex); return err; } @@ -425,7 +425,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) } else { if (snd_register_oss_device(hwdep->oss_type, hwdep->card, hwdep->device, - &snd_hwdep_f_ops, + &snd_hwdep_f_ops, hwdep, hwdep->oss_dev) < 0) { snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n", hwdep->card->number, hwdep->device); @@ -441,12 +441,10 @@ static int snd_hwdep_dev_register(struct snd_device *device) static int snd_hwdep_dev_unregister(struct snd_device *device) { struct snd_hwdep *hwdep = device->device_data; - int idx; snd_assert(hwdep != NULL, return -ENXIO); down(®ister_mutex); - idx = (hwdep->card->number * SNDRV_MINOR_HWDEPS) + hwdep->device; - if (snd_hwdep_devices[idx] != hwdep) { + if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { up(®ister_mutex); return -EINVAL; } @@ -455,7 +453,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device); #endif snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); - snd_hwdep_devices[idx] = NULL; + list_del(&hwdep->list); up(®ister_mutex); return snd_hwdep_free(hwdep); } @@ -467,18 +465,14 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) static void snd_hwdep_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - int idx; + struct list_head *p; struct snd_hwdep *hwdep; down(®ister_mutex); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_MINOR_HWDEPS; idx++) { - hwdep = snd_hwdep_devices[idx]; - if (hwdep == NULL) - continue; + list_for_each(p, &snd_hwdep_devices) { + hwdep = list_entry(p, struct snd_hwdep, list); snd_iprintf(buffer, "%02i-%02i: %s\n", - idx / SNDRV_MINOR_HWDEPS, - idx % SNDRV_MINOR_HWDEPS, - hwdep->name); + hwdep->card->number, hwdep->device, hwdep->name); } up(®ister_mutex); } @@ -493,9 +487,8 @@ static int __init alsa_hwdep_init(void) { struct snd_info_entry *entry; - memset(snd_hwdep_devices, 0, sizeof(snd_hwdep_devices)); if ((entry = snd_info_create_module_entry(THIS_MODULE, "hwdep", NULL)) != NULL) { - entry->c.text.read_size = 512; + entry->c.text.read_size = PAGE_SIZE; entry->c.text.read = snd_hwdep_proc_read; if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 2dd6bf9b49e..2d7a42014f5 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -41,12 +41,13 @@ MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_MIXER); static int snd_mixer_oss_open(struct inode *inode, struct file *file) { - int cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode)); struct snd_card *card; struct snd_mixer_oss_file *fmixer; int err; - if ((card = snd_cards[cardnum]) == NULL) + card = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_MIXER); + if (card == NULL) return -ENODEV; if (card->mixer_oss == NULL) return -ENODEV; @@ -1286,7 +1287,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) sprintf(name, "mixer%i%i", card->number, 0); if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, card, 0, - &snd_mixer_oss_f_ops, + &snd_mixer_oss_f_ops, card, name)) < 0) { snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", card->number, 0); diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 947bf08df42..2ae283c7b28 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1834,9 +1834,6 @@ static int snd_task_name(struct task_struct *task, char *name, size_t size) static int snd_pcm_oss_open(struct inode *inode, struct file *file) { - int minor = iminor(inode); - int cardnum = SNDRV_MINOR_OSS_CARD(minor); - int device; int err; char task_name[32]; struct snd_pcm *pcm; @@ -1845,11 +1842,8 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) int nonblock; wait_queue_t wait; - snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); - device = SNDRV_MINOR_OSS_DEVICE(minor) == SNDRV_MINOR_OSS_PCM1 ? - adsp_map[cardnum] : dsp_map[cardnum]; - - pcm = snd_pcm_devices[(cardnum * SNDRV_PCM_DEVICES) + device]; + pcm = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_PCM); if (pcm == NULL) { err = -ENODEV; goto __error1; @@ -1890,7 +1884,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) down(&pcm->open_mutex); while (1) { err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file, - minor, psetup, csetup); + iminor(inode), psetup, csetup); if (err >= 0) break; if (err == -EAGAIN) { @@ -2450,7 +2444,7 @@ static void register_oss_dsp(struct snd_pcm *pcm, int index) sprintf(name, "dsp%i%i", pcm->card->number, pcm->device); if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, pcm->card, index, &snd_pcm_oss_f_reg, - name) < 0) { + pcm, name) < 0) { snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n", pcm->card->number, pcm->device); } diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 2bc5f69ec2a..95036c83de4 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -33,7 +33,7 @@ MODULE_AUTHOR("Jaroslav Kysela , Abramo Bagnara card == card && pcm->device == device) + return pcm; + } + return NULL; +} + static int snd_pcm_control_ioctl(struct snd_card *card, struct snd_ctl_file *control, unsigned int cmd, unsigned long arg) { - unsigned int tmp; - - tmp = card->number * SNDRV_PCM_DEVICES; switch (cmd) { case SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE: { @@ -57,14 +67,16 @@ static int snd_pcm_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)arg)) return -EFAULT; + down(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_PCM_DEVICES) { - if (snd_pcm_devices[tmp + device]) + if (snd_pcm_search(card, device)) break; device++; } if (device == SNDRV_PCM_DEVICES) device = -1; + up(®ister_mutex); if (put_user(device, (int __user *)arg)) return -EFAULT; return 0; @@ -77,31 +89,44 @@ static int snd_pcm_control_ioctl(struct snd_card *card, struct snd_pcm *pcm; struct snd_pcm_str *pstr; struct snd_pcm_substream *substream; + int err; + info = (struct snd_pcm_info __user *)arg; if (get_user(device, &info->device)) return -EFAULT; - if (device >= SNDRV_PCM_DEVICES) - return -ENXIO; - pcm = snd_pcm_devices[tmp + device]; - if (pcm == NULL) - return -ENXIO; if (get_user(stream, &info->stream)) return -EFAULT; if (stream < 0 || stream > 1) return -EINVAL; - pstr = &pcm->streams[stream]; - if (pstr->substream_count == 0) - return -ENOENT; if (get_user(subdevice, &info->subdevice)) return -EFAULT; - if (subdevice >= pstr->substream_count) - return -ENXIO; - for (substream = pstr->substream; substream; substream = substream->next) + down(®ister_mutex); + pcm = snd_pcm_search(card, device); + if (pcm == NULL) { + err = -ENXIO; + goto _error; + } + pstr = &pcm->streams[stream]; + if (pstr->substream_count == 0) { + err = -ENOENT; + goto _error; + } + if (subdevice >= pstr->substream_count) { + err = -ENXIO; + goto _error; + } + for (substream = pstr->substream; substream; + substream = substream->next) if (substream->number == (int)subdevice) break; - if (substream == NULL) - return -ENXIO; - return snd_pcm_info_user(substream, info); + if (substream == NULL) { + err = -ENXIO; + goto _error; + } + err = snd_pcm_info_user(substream, info); + _error: + up(®ister_mutex); + return err; } case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE: { @@ -865,8 +890,7 @@ void snd_pcm_release_substream(struct snd_pcm_substream *substream) static int snd_pcm_dev_register(struct snd_device *device) { - int idx, cidx, err; - unsigned short minor; + int cidx, err; struct snd_pcm_substream *substream; struct list_head *list; char str[16]; @@ -874,12 +898,11 @@ static int snd_pcm_dev_register(struct snd_device *device) snd_assert(pcm != NULL && device != NULL, return -ENXIO); down(®ister_mutex); - idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device; - if (snd_pcm_devices[idx]) { + if (snd_pcm_search(pcm->card, pcm->device)) { up(®ister_mutex); return -EBUSY; } - snd_pcm_devices[idx] = pcm; + list_add_tail(&pcm->list, &snd_pcm_devices); for (cidx = 0; cidx < 2; cidx++) { int devtype = -1; if (pcm->streams[cidx].substream == NULL) @@ -887,20 +910,19 @@ static int snd_pcm_dev_register(struct snd_device *device) switch (cidx) { case SNDRV_PCM_STREAM_PLAYBACK: sprintf(str, "pcmC%iD%ip", pcm->card->number, pcm->device); - minor = SNDRV_MINOR_PCM_PLAYBACK + idx; devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK; break; case SNDRV_PCM_STREAM_CAPTURE: sprintf(str, "pcmC%iD%ic", pcm->card->number, pcm->device); - minor = SNDRV_MINOR_PCM_CAPTURE + idx; devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; break; } if ((err = snd_register_device(devtype, pcm->card, pcm->device, - &snd_pcm_f_ops[cidx], str)) < 0) + &snd_pcm_f_ops[cidx], + pcm, str)) < 0) { - snd_pcm_devices[idx] = NULL; + list_del(&pcm->list); up(®ister_mutex); return err; } @@ -921,11 +943,10 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) struct snd_pcm *pcm = device->device_data; struct list_head *list; struct snd_pcm_substream *substream; - int idx, cidx; + int cidx; down(®ister_mutex); - idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device; - snd_pcm_devices[idx] = NULL; + list_del_init(&pcm->list); for (cidx = 0; cidx < 2; cidx++) for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) if (substream->runtime) @@ -941,15 +962,14 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) static int snd_pcm_dev_unregister(struct snd_device *device) { - int idx, cidx, devtype; + int cidx, devtype; struct snd_pcm_substream *substream; struct list_head *list; struct snd_pcm *pcm = device->device_data; snd_assert(pcm != NULL, return -ENXIO); down(®ister_mutex); - idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device; - snd_pcm_devices[idx] = NULL; + list_del(&pcm->list); for (cidx = 0; cidx < 2; cidx++) { devtype = -1; switch (cidx) { @@ -975,24 +995,19 @@ static int snd_pcm_dev_unregister(struct snd_device *device) int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) { - int idx; + struct list_head *p; snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL); down(®ister_mutex); if (nfree) { list_del(¬ify->list); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) { - if (snd_pcm_devices[idx] == NULL) - continue; - notify->n_unregister(snd_pcm_devices[idx]); - } + list_for_each(p, &snd_pcm_devices) + notify->n_unregister(list_entry(p, + struct snd_pcm, list)); } else { list_add_tail(¬ify->list, &snd_pcm_notify_list); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) { - if (snd_pcm_devices[idx] == NULL) - continue; - notify->n_register(snd_pcm_devices[idx]); - } + list_for_each(p, &snd_pcm_devices) + notify->n_register(list_entry(p, struct snd_pcm, list)); } up(®ister_mutex); return 0; @@ -1005,16 +1020,14 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) static void snd_pcm_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - int idx; + struct list_head *p; struct snd_pcm *pcm; down(®ister_mutex); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) { - pcm = snd_pcm_devices[idx]; - if (pcm == NULL) - continue; - snd_iprintf(buffer, "%02i-%02i: %s : %s", idx / SNDRV_PCM_DEVICES, - idx % SNDRV_PCM_DEVICES, pcm->id, pcm->name); + list_for_each(p, &snd_pcm_devices) { + pcm = list_entry(p, struct snd_pcm, list); + snd_iprintf(buffer, "%02i-%02i: %s : %s", + pcm->card->number, pcm->device, pcm->id, pcm->name); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) snd_iprintf(buffer, " : playback %i", pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count); @@ -1063,7 +1076,6 @@ static void __exit alsa_pcm_exit(void) module_init(alsa_pcm_init) module_exit(alsa_pcm_exit) -EXPORT_SYMBOL(snd_pcm_devices); EXPORT_SYMBOL(snd_pcm_new); EXPORT_SYMBOL(snd_pcm_new_stream); EXPORT_SYMBOL(snd_pcm_notify); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index bb40c016135..9010306bcea 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -62,6 +62,7 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params_old __user * _oparams); static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params_old __user * _oparams); +static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream); /* * @@ -1554,7 +1555,8 @@ static struct file *snd_pcm_file_fd(int fd) { struct file *file; struct inode *inode; - unsigned short minor; + unsigned int minor; + file = fget(fd); if (!file) return NULL; @@ -1565,8 +1567,8 @@ static struct file *snd_pcm_file_fd(int fd) return NULL; } minor = iminor(inode); - if (minor >= 256 || - minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) { + if (!snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_PLAYBACK) && + !snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_CAPTURE)) { fput(file); return NULL; } @@ -2071,18 +2073,30 @@ static int snd_pcm_open_file(struct file *file, return 0; } -static int snd_pcm_open(struct inode *inode, struct file *file) +static int snd_pcm_playback_open(struct inode *inode, struct file *file) +{ + struct snd_pcm *pcm; + + pcm = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_PCM_PLAYBACK); + return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); +} + +static int snd_pcm_capture_open(struct inode *inode, struct file *file) { - int cardnum = SNDRV_MINOR_CARD(iminor(inode)); - int device = SNDRV_MINOR_DEVICE(iminor(inode)); - int err; struct snd_pcm *pcm; + + pcm = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_PCM_CAPTURE); + return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); +} + +static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) +{ + int err; struct snd_pcm_file *pcm_file; wait_queue_t wait; - if (device < SNDRV_MINOR_PCM_PLAYBACK || device >= SNDRV_MINOR_DEVICES) - return -ENXIO; - pcm = snd_pcm_devices[(cardnum * SNDRV_PCM_DEVICES) + (device % SNDRV_MINOR_PCMS)]; if (pcm == NULL) { err = -ENODEV; goto __error1; @@ -2098,7 +2112,7 @@ static int snd_pcm_open(struct inode *inode, struct file *file) add_wait_queue(&pcm->open_wait, &wait); down(&pcm->open_mutex); while (1) { - err = snd_pcm_open_file(file, pcm, device >= SNDRV_MINOR_PCM_CAPTURE ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK, &pcm_file); + err = snd_pcm_open_file(file, pcm, stream, &pcm_file); if (err >= 0) break; if (err == -EAGAIN) { @@ -3375,7 +3389,7 @@ struct file_operations snd_pcm_f_ops[2] = { .owner = THIS_MODULE, .write = snd_pcm_write, .writev = snd_pcm_writev, - .open = snd_pcm_open, + .open = snd_pcm_playback_open, .release = snd_pcm_release, .poll = snd_pcm_playback_poll, .unlocked_ioctl = snd_pcm_playback_ioctl, @@ -3387,7 +3401,7 @@ struct file_operations snd_pcm_f_ops[2] = { .owner = THIS_MODULE, .read = snd_pcm_read, .readv = snd_pcm_readv, - .open = snd_pcm_open, + .open = snd_pcm_capture_open, .release = snd_pcm_release, .poll = snd_pcm_capture_poll, .unlocked_ioctl = snd_pcm_capture_ioctl, diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 7ac77e5ddcb..e6ee0d81378 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -56,10 +56,22 @@ static int snd_rawmidi_dev_register(struct snd_device *device); static int snd_rawmidi_dev_disconnect(struct snd_device *device); static int snd_rawmidi_dev_unregister(struct snd_device *device); -static struct snd_rawmidi *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; - +static LIST_HEAD(snd_rawmidi_devices); static DECLARE_MUTEX(register_mutex); +static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) +{ + struct list_head *p; + struct snd_rawmidi *rawmidi; + + list_for_each(p, &snd_rawmidi_devices) { + rawmidi = list_entry(p, struct snd_rawmidi, list); + if (rawmidi->card == card && rawmidi->device == device) + return rawmidi; + } + return NULL; +} + static inline unsigned short snd_rawmidi_file_flags(struct file *file) { switch (file->f_mode & (FMODE_READ | FMODE_WRITE)) { @@ -214,7 +226,7 @@ int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream) return 0; } -int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, +int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, int mode, struct snd_rawmidi_file * rfile) { struct snd_rawmidi *rmidi; @@ -225,7 +237,9 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, if (rfile) rfile->input = rfile->output = NULL; - rmidi = snd_rawmidi_devices[(cardnum * SNDRV_RAWMIDI_DEVICES) + device]; + down(®ister_mutex); + rmidi = snd_rawmidi_search(card, device); + up(®ister_mutex); if (rmidi == NULL) { err = -ENODEV; goto __error1; @@ -368,9 +382,8 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, static int snd_rawmidi_open(struct inode *inode, struct file *file) { int maj = imajor(inode); - int cardnum; struct snd_card *card; - int device, subdevice; + int subdevice; unsigned short fflags; int err; struct snd_rawmidi *rmidi; @@ -380,27 +393,18 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) struct snd_ctl_file *kctl; if (maj == snd_major) { - cardnum = SNDRV_MINOR_CARD(iminor(inode)); - cardnum %= SNDRV_CARDS; - device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_RAWMIDI; - device %= SNDRV_MINOR_RAWMIDIS; + rmidi = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_RAWMIDI); #ifdef CONFIG_SND_OSSEMUL } else if (maj == SOUND_MAJOR) { - cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode)); - cardnum %= SNDRV_CARDS; - device = SNDRV_MINOR_OSS_DEVICE(iminor(inode)) == SNDRV_MINOR_OSS_MIDI ? - midi_map[cardnum] : amidi_map[cardnum]; + rmidi = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_MIDI); #endif } else return -ENXIO; - rmidi = snd_rawmidi_devices[(cardnum * SNDRV_RAWMIDI_DEVICES) + device]; if (rmidi == NULL) return -ENODEV; -#ifdef CONFIG_SND_OSSEMUL - if (maj == SOUND_MAJOR && !rmidi->ossreg) - return -ENXIO; -#endif if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) return -EINVAL; /* invalid combination */ card = rmidi->card; @@ -430,7 +434,8 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) } } up_read(&card->controls_rwsem); - err = snd_rawmidi_kernel_open(cardnum, device, subdevice, fflags, rawmidi_file); + err = snd_rawmidi_kernel_open(rmidi->card, rmidi->device, + subdevice, fflags, rawmidi_file); if (err >= 0) break; if (err == -EAGAIN) { @@ -570,9 +575,10 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info struct snd_rawmidi_str *pstr; struct snd_rawmidi_substream *substream; struct list_head *list; - if (info->device >= SNDRV_RAWMIDI_DEVICES) - return -ENXIO; - rmidi = snd_rawmidi_devices[card->number * SNDRV_RAWMIDI_DEVICES + info->device]; + + down(®ister_mutex); + rmidi = snd_rawmidi_search(card, info->device); + up(®ister_mutex); if (!rmidi) return -ENXIO; if (info->stream < 0 || info->stream > 1) @@ -803,9 +809,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, unsigned long arg) { void __user *argp = (void __user *)arg; - unsigned int tmp; - tmp = card->number * SNDRV_RAWMIDI_DEVICES; switch (cmd) { case SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE: { @@ -813,14 +817,16 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)argp)) return -EFAULT; + down(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_RAWMIDI_DEVICES) { - if (snd_rawmidi_devices[tmp + device]) + if (snd_rawmidi_search(card, device)) break; device++; } if (device == SNDRV_RAWMIDI_DEVICES) device = -1; + up(®ister_mutex); if (put_user(device, (int __user *)argp)) return -EFAULT; return 0; @@ -1493,7 +1499,7 @@ static void snd_rawmidi_dev_seq_free(struct snd_seq_device *device) static int snd_rawmidi_dev_register(struct snd_device *device) { - int idx, err; + int err; struct snd_info_entry *entry; char name[16]; struct snd_rawmidi *rmidi = device->device_data; @@ -1501,25 +1507,24 @@ static int snd_rawmidi_dev_register(struct snd_device *device) if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) return -ENOMEM; down(®ister_mutex); - idx = (rmidi->card->number * SNDRV_RAWMIDI_DEVICES) + rmidi->device; - if (snd_rawmidi_devices[idx] != NULL) { + if (snd_rawmidi_search(rmidi->card, rmidi->device)) { up(®ister_mutex); return -EBUSY; } - snd_rawmidi_devices[idx] = rmidi; + list_add_tail(&rmidi->list, &snd_rawmidi_devices); sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device, - &snd_rawmidi_f_ops, name)) < 0) { + &snd_rawmidi_f_ops, rmidi, name)) < 0) { snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); - snd_rawmidi_devices[idx] = NULL; + list_del(&rmidi->list); up(®ister_mutex); return err; } if (rmidi->ops && rmidi->ops->dev_register && (err = rmidi->ops->dev_register(rmidi)) < 0) { snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); - snd_rawmidi_devices[idx] = NULL; + list_del(&rmidi->list); up(®ister_mutex); return err; } @@ -1527,8 +1532,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) rmidi->ossreg = 0; if ((int)rmidi->device == midi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 0, - &snd_rawmidi_f_ops, name) < 0) { + rmidi->card, 0, &snd_rawmidi_f_ops, + rmidi, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0); } else { rmidi->ossreg++; @@ -1539,8 +1544,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) } if ((int)rmidi->device == amidi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 1, - &snd_rawmidi_f_ops, name) < 0) { + rmidi->card, 1, &snd_rawmidi_f_ops, + rmidi, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1); } else { rmidi->ossreg++; @@ -1576,24 +1581,20 @@ static int snd_rawmidi_dev_register(struct snd_device *device) static int snd_rawmidi_dev_disconnect(struct snd_device *device) { struct snd_rawmidi *rmidi = device->device_data; - int idx; down(®ister_mutex); - idx = (rmidi->card->number * SNDRV_RAWMIDI_DEVICES) + rmidi->device; - snd_rawmidi_devices[idx] = NULL; + list_del_init(&rmidi->list); up(®ister_mutex); return 0; } static int snd_rawmidi_dev_unregister(struct snd_device *device) { - int idx; struct snd_rawmidi *rmidi = device->device_data; snd_assert(rmidi != NULL, return -ENXIO); down(®ister_mutex); - idx = (rmidi->card->number * SNDRV_RAWMIDI_DEVICES) + rmidi->device; - snd_rawmidi_devices[idx] = NULL; + list_del(&rmidi->list); if (rmidi->proc_entry) { snd_info_unregister(rmidi->proc_entry); rmidi->proc_entry = NULL; diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 61c0a41376f..4b51ab56507 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -225,7 +225,7 @@ register_device(void) down(®ister_mutex); if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0, - &seq_oss_f_ops, + &seq_oss_f_ops, NULL, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device seq\n"); up(®ister_mutex); @@ -233,7 +233,7 @@ register_device(void) } if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0, - &seq_oss_f_ops, + &seq_oss_f_ops, NULL, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device music\n"); snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 087fdf32732..c8bd37ee837 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2531,7 +2531,7 @@ int __init snd_sequencer_device_init(void) return -ERESTARTSYS; if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, - &snd_seq_f_ops, "seq")) < 0) { + &snd_seq_f_ops, NULL, "seq")) < 0) { up(®ister_mutex); return err; } diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index f88d2e3ee66..0a65eb2f976 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -183,7 +183,10 @@ static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribe struct snd_rawmidi_params params; /* open midi port */ - if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_INPUT, &msynth->input_rfile)) < 0) { + if ((err = snd_rawmidi_kernel_open(msynth->card, msynth->device, + msynth->subdevice, + SNDRV_RAWMIDI_LFLG_INPUT, + &msynth->input_rfile)) < 0) { snd_printd("midi input open failed!!!\n"); return err; } @@ -221,7 +224,10 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info struct snd_rawmidi_params params; /* open midi port */ - if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_OUTPUT, &msynth->output_rfile)) < 0) { + if ((err = snd_rawmidi_kernel_open(msynth->card, msynth->device, + msynth->subdevice, + SNDRV_RAWMIDI_LFLG_OUTPUT, + &msynth->output_rfile)) < 0) { snd_printd("midi output open failed!!!\n"); return err; } diff --git a/sound/core/sound.c b/sound/core/sound.c index a509f49fa0b..1e5eca54692 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -60,7 +60,6 @@ MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR); int snd_ecards_limit; static struct snd_minor *snd_minors[SNDRV_OS_MINORS]; - static DECLARE_MUTEX(sound_mutex); extern struct class *sound_class; @@ -107,6 +106,31 @@ static void snd_request_other(int minor) #endif /* request_module support */ +/** + * snd_lookup_minor_data - get user data of a registered device + * @minor: the minor number + * @type: device type (SNDRV_DEVICE_TYPE_XXX) + * + * Checks that a minor device with the specified type is registered, and returns + * its user data pointer. + */ +void *snd_lookup_minor_data(unsigned int minor, int type) +{ + struct snd_minor *mreg; + void *private_data; + + if (minor > ARRAY_SIZE(snd_minors)) + return NULL; + down(&sound_mutex); + mreg = snd_minors[minor]; + if (mreg && mreg->type == type) + private_data = mreg->private_data; + else + private_data = NULL; + up(&sound_mutex); + return private_data; +} + static int snd_open(struct inode *inode, struct file *file) { int minor = iminor(inode); @@ -183,6 +207,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * @card: the card instance * @dev: the device index * @f_ops: the file operations + * @private_data: user pointer for f_ops->open() * @name: the device file name * * Registers an ALSA device file for the given card. @@ -191,7 +216,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * Retrurns zero if successful, or a negative error code on failure. */ int snd_register_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name) + struct file_operations *f_ops, void *private_data, + const char *name) { int minor = snd_kernel_minor(type, card, dev); struct snd_minor *preg; @@ -207,6 +233,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, preg->card = card ? card->number : -1; preg->device = dev; preg->f_ops = f_ops; + preg->private_data = private_data; strcpy(preg->name, name); down(&sound_mutex); if (snd_minors[minor]) { @@ -238,13 +265,18 @@ int snd_register_device(int type, struct snd_card *card, int dev, */ int snd_unregister_device(int type, struct snd_card *card, int dev) { - int minor = snd_kernel_minor(type, card, dev); + int cardnum, minor; struct snd_minor *mptr; - if (minor < 0) - return minor; + cardnum = card ? card->number : -1; down(&sound_mutex); - if ((mptr = snd_minors[minor]) == NULL) { + for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) + if ((mptr = snd_minors[minor]) != NULL && + mptr->type == type && + mptr->card == cardnum && + mptr->device == dev) + break; + if (minor == ARRAY_SIZE(snd_minors)) { up(&sound_mutex); return -EINVAL; } @@ -392,9 +424,11 @@ EXPORT_SYMBOL(snd_request_card); #endif EXPORT_SYMBOL(snd_register_device); EXPORT_SYMBOL(snd_unregister_device); +EXPORT_SYMBOL(snd_lookup_minor_data); #if defined(CONFIG_SND_OSSEMUL) EXPORT_SYMBOL(snd_register_oss_device); EXPORT_SYMBOL(snd_unregister_oss_device); +EXPORT_SYMBOL(snd_lookup_oss_minor_data); #endif /* memory.c */ EXPORT_SYMBOL(copy_to_user_fromio); diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index afbfd8df129..b9e89cac4c5 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -38,9 +38,25 @@ #define SNDRV_OSS_MINORS 128 static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; - static DECLARE_MUTEX(sound_oss_mutex); +void *snd_lookup_oss_minor_data(unsigned int minor, int type) +{ + struct snd_minor *mreg; + void *private_data; + + if (minor > ARRAY_SIZE(snd_oss_minors)) + return NULL; + down(&sound_oss_mutex); + mreg = snd_oss_minors[minor]; + if (mreg && mreg->type == type) + private_data = mreg->private_data; + else + private_data = NULL; + up(&sound_oss_mutex); + return private_data; +} + static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) { int minor; @@ -78,7 +94,8 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) } int snd_register_oss_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name) + struct file_operations *f_ops, void *private_data, + const char *name) { int minor = snd_oss_kernel_minor(type, card, dev); int minor_unit; @@ -97,6 +114,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, preg->card = card ? card->number : -1; preg->device = dev; preg->f_ops = f_ops; + preg->private_data = private_data; down(&sound_oss_mutex); snd_oss_minors[minor] = preg; minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); @@ -121,6 +139,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, carddev); if (register2 != track2) goto __end; + snd_oss_minors[track2] = preg; } up(&sound_oss_mutex); return 0; @@ -163,8 +182,10 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); break; } - if (track2 >= 0) + if (track2 >= 0) { unregister_sound_special(track2); + snd_oss_minors[track2] = NULL; + } snd_oss_minors[minor] = NULL; up(&sound_oss_mutex); kfree(mptr); diff --git a/sound/core/timer.c b/sound/core/timer.c index a7bcb04263c..c62dbacdca1 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1952,8 +1952,8 @@ static int __init alsa_timer_init(void) if ((err = snd_timer_register_system()) < 0) snd_printk(KERN_ERR "unable to register system timer (%i)\n", err); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, - NULL, 0, &snd_timer_f_ops, "timer")) < 0) + if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, + &snd_timer_f_ops, NULL, "timer")) < 0) snd_printk(KERN_ERR "unable to register timer device (%i)\n", err); return 0; -- cgit v1.2.3-70-g09d2 From 1b98ea4791892399d8c23c93e117567eeff38887 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 21 Nov 2005 07:31:31 +0100 Subject: [ALSA] rawmidi: adjust runtime->avail when changing output buffer size Modules: RawMidi Midlevel When the output buffer size is changed, runtime->avail must be adjusted to the new size; otherwise, draining of a bigger buffer would appear to fail because avail does not reach buffer_size. Signed-off-by: Clemens Ladisch --- sound/core/rawmidi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/core/rawmidi.c') diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index e6ee0d81378..587ea1eb319 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -635,6 +635,7 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, kfree(runtime->buffer); runtime->buffer = newbuf; runtime->buffer_size = params->buffer_size; + runtime->avail = runtime->buffer_size; } runtime->avail_min = params->avail_min; substream->active_sensing = !params->no_active_sensing; -- cgit v1.2.3-70-g09d2 From 18612048b3e951f7e0ae9be65efe9e8cfde868a6 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 23 Nov 2005 13:14:50 +0100 Subject: [ALSA] sound/: possible cleanups Modules: RawMidi Midlevel,HDA generic driver This patch contains the following possible cleanups: - pci/hda/hda_proc.c should #include 'hda_local.h' for including the prototype of it's global function snd_hda_codec_proc_new() - core/rawmidi.c: make the needlessly global and EXPORT_SYMBOL'ed function snd_rawmidi_info() static Signed-off-by: Adrian Bunk Signed-off-by: Takashi Iwai --- sound/core/rawmidi.c | 5 ++--- sound/pci/hda/hda_proc.c | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound/core/rawmidi.c') diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 587ea1eb319..d4d124e2192 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -534,8 +534,8 @@ static int snd_rawmidi_release(struct inode *inode, struct file *file) return err; } -int snd_rawmidi_info(struct snd_rawmidi_substream *substream, - struct snd_rawmidi_info *info) +static int snd_rawmidi_info(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_info *info) { struct snd_rawmidi *rmidi; @@ -1694,7 +1694,6 @@ EXPORT_SYMBOL(snd_rawmidi_transmit_ack); EXPORT_SYMBOL(snd_rawmidi_transmit); EXPORT_SYMBOL(snd_rawmidi_new); EXPORT_SYMBOL(snd_rawmidi_set_ops); -EXPORT_SYMBOL(snd_rawmidi_info); EXPORT_SYMBOL(snd_rawmidi_info_select); EXPORT_SYMBOL(snd_rawmidi_kernel_open); EXPORT_SYMBOL(snd_rawmidi_kernel_release); diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 8cc5773958f..ca514a6a587 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -26,6 +26,7 @@ #include #include #include "hda_codec.h" +#include "hda_local.h" static const char *get_wid_type_name(unsigned int wid_value) { -- cgit v1.2.3-70-g09d2