From 55c63bd256d41d79adbe1c3fc2325fb328419a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= Date: Tue, 9 Mar 2010 12:57:52 -0500 Subject: ALSA: provide a more useful get_unmapped_area handler for pcm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shared memory mappings on nommu machines require a get_unmapped_area file operation that suggests an address for the mapping. The current implementation returns 0 and thus forces the driver to implement an mmap handler that fixes up the start and end address of the vma. This patch returns the address of the dma buffer, so it should work out of the box for all drivers that use the snd_pcm_runtime->dma_area pointer. Addresses for mapping the status and control pages are returned as well, but to make those work the conditional compilation of snd_pcm_mmap_{status,control} would need to be revised. URL: http://thread.gmane.org/gmane.linux.alsa.devel/61230 Signed-off-by: Daniel Glöckner Signed-off-by: Cliff Cai Signed-off-by: Mike Frysinger Signed-off-by: Takashi Iwai --- sound/core/pcm_native.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'sound/core') diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 872887624030..9681518aa392 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3434,14 +3434,28 @@ out: #endif /* CONFIG_SND_SUPPORT_OLD_API */ #ifndef CONFIG_MMU -unsigned long dummy_get_unmapped_area(struct file *file, unsigned long addr, - unsigned long len, unsigned long pgoff, - unsigned long flags) -{ - return 0; +static unsigned long snd_pcm_get_unmapped_area(struct file *file, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags) +{ + struct snd_pcm_file *pcm_file = file->private_data; + struct snd_pcm_substream *substream = pcm_file->substream; + struct snd_pcm_runtime *runtime = substream->runtime; + unsigned long offset = pgoff << PAGE_SHIFT; + + switch (offset) { + case SNDRV_PCM_MMAP_OFFSET_STATUS: + return (unsigned long)runtime->status; + case SNDRV_PCM_MMAP_OFFSET_CONTROL: + return (unsigned long)runtime->control; + default: + return (unsigned long)runtime->dma_area + offset; + } } #else -# define dummy_get_unmapped_area NULL +# define snd_pcm_get_unmapped_area NULL #endif /* @@ -3460,7 +3474,7 @@ const struct file_operations snd_pcm_f_ops[2] = { .compat_ioctl = snd_pcm_ioctl_compat, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, - .get_unmapped_area = dummy_get_unmapped_area, + .get_unmapped_area = snd_pcm_get_unmapped_area, }, { .owner = THIS_MODULE, @@ -3473,6 +3487,6 @@ const struct file_operations snd_pcm_f_ops[2] = { .compat_ioctl = snd_pcm_ioctl_compat, .mmap = snd_pcm_mmap, .fasync = snd_pcm_fasync, - .get_unmapped_area = dummy_get_unmapped_area, + .get_unmapped_area = snd_pcm_get_unmapped_area, } }; -- cgit v1.2.3 From 1c6e555c3a66af29a51690748ca54314e62c16d5 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 17 Mar 2010 15:36:38 +0000 Subject: ALSA: Rename jack switch table in preparation for button support Avoids confusion when we have button support. Signed-off-by: Mark Brown --- sound/core/jack.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sound/core') diff --git a/sound/core/jack.c b/sound/core/jack.c index f705eec7372a..f6f091f2b382 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -23,7 +23,7 @@ #include #include -static int jack_types[] = { +static int jack_switch_types[] = { SW_HEADPHONE_INSERT, SW_MICROPHONE_INSERT, SW_LINEOUT_INSERT, @@ -112,10 +112,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, jack->type = type; - for (i = 0; i < ARRAY_SIZE(jack_types); i++) + for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) if (type & (1 << i)) input_set_capability(jack->input_dev, EV_SW, - jack_types[i]); + jack_switch_types[i]); err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); if (err < 0) @@ -163,10 +163,11 @@ void snd_jack_report(struct snd_jack *jack, int status) if (!jack) return; - for (i = 0; i < ARRAY_SIZE(jack_types); i++) { + for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) { int testbit = 1 << i; if (jack->type & testbit) - input_report_switch(jack->input_dev, jack_types[i], + input_report_switch(jack->input_dev, + jack_switch_types[i], status & testbit); } -- cgit v1.2.3 From ebb812cb8df48e299b3d4ab75cbb0042384ef70d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 17 Mar 2010 18:07:12 +0000 Subject: ALSA: Add support for key reporting via the jack interface Some devices provide support for detection of a small number of buttons on their jacks. One common implementation provides a single button, implemented by shorting the microphone to ground and detected along with microphone presence detection by detecting varying current draws on the microphone bias signal. Provide support for up to three buttons via the jack interface. These default to reporting BTN_n but an API is provided to allow these to be remapped to other keys by the machine driver where it knows what the keys are. More keys can be added with ease if required. This is only intended to support simple accessory button designs. If the interface is limiting then either creating a child device for the accessory or accessing the input device in the jack directly is recommended. Signed-off-by: Mark Brown --- sound/core/jack.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'sound/core') diff --git a/sound/core/jack.c b/sound/core/jack.c index f6f091f2b382..3813e7b04d05 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -55,7 +55,7 @@ static int snd_jack_dev_register(struct snd_device *device) { struct snd_jack *jack = device->device_data; struct snd_card *card = device->card; - int err; + int err, i; snprintf(jack->name, sizeof(jack->name), "%s %s", card->shortname, jack->id); @@ -65,6 +65,19 @@ static int snd_jack_dev_register(struct snd_device *device) if (!jack->input_dev->dev.parent) jack->input_dev->dev.parent = snd_card_get_device_link(card); + /* Add capabilities for any keys that are enabled */ + for (i = 0; i < ARRAY_SIZE(jack->key); i++) { + int testbit = SND_JACK_BTN_0 >> i; + + if (!(jack->type & testbit)) + continue; + + if (!jack->key[i]) + jack->key[i] = BTN_0 + i; + + input_set_capability(jack->input_dev, EV_KEY, jack->key[i]); + } + err = input_register_device(jack->input_dev); if (err == 0) jack->registered = 1; @@ -150,6 +163,43 @@ void snd_jack_set_parent(struct snd_jack *jack, struct device *parent) } EXPORT_SYMBOL(snd_jack_set_parent); +/** + * snd_jack_set_key - Set a key mapping on a jack + * + * @jack: The jack to configure + * @type: Jack report type for this key + * @keytype: Input layer key type to be reported + * + * Map a SND_JACK_BTN_ button type to an input layer key, allowing + * reporting of keys on accessories via the jack abstraction. If no + * mapping is provided but keys are enabled in the jack type then + * BTN_n numeric buttons will be reported. + * + * Note that this is intended to be use by simple devices with small + * numbers of keys that can be reported. It is also possible to + * access the input device directly - devices with complex input + * capabilities on accessories should consider doing this rather than + * using this abstraction. + * + * This function may only be called prior to registration of the jack. + */ +int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, + int keytype) +{ + int key = fls(SND_JACK_BTN_0) - fls(type); + + WARN_ON(jack->registered); + + if (!keytype || key >= ARRAY_SIZE(jack->key)) + return -EINVAL; + + jack->type |= type; + jack->key[key] = keytype; + + return 0; +} +EXPORT_SYMBOL(snd_jack_set_key); + /** * snd_jack_report - Report the current status of a jack * @@ -163,6 +213,14 @@ void snd_jack_report(struct snd_jack *jack, int status) if (!jack) return; + for (i = 0; i < ARRAY_SIZE(jack->key); i++) { + int testbit = SND_JACK_BTN_0 >> i; + + if (jack->type & testbit) + input_report_key(jack->input_dev, jack->key[i], + status & testbit); + } + for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) { int testbit = 1 << i; if (jack->type & testbit) -- cgit v1.2.3 From d05468b72a32ec45aefb48caa00bd99350b9cf86 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Apr 2010 18:29:46 +0200 Subject: ALSA: pcm - Remove BKL from async callback It's simply calling fasync_helper(). Signed-off-by: Takashi Iwai --- sound/core/pcm_native.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'sound/core') diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 872887624030..cadba3087768 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3303,18 +3303,13 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) struct snd_pcm_file * pcm_file; struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; - int err = -ENXIO; - lock_kernel(); pcm_file = file->private_data; substream = pcm_file->substream; if (PCM_RUNTIME_CHECK(substream)) - goto out; + return -ENXIO; runtime = substream->runtime; - err = fasync_helper(fd, file, on, &runtime->fasync); -out: - unlock_kernel(); - return err; + return fasync_helper(fd, file, on, &runtime->fasync); } /* -- cgit v1.2.3 From 5b5cd553e3ac49e6a9bac148f07ab94d3d96dae5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Apr 2010 18:33:57 +0200 Subject: ALSA: info - Remove BKL Use the fine-grained mutex for the assigned info object, instead. Signed-off-by: Takashi Iwai --- sound/core/info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/core') diff --git a/sound/core/info.c b/sound/core/info.c index d749a0d394a7..fe836618fa25 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -167,7 +167,7 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) data = file->private_data; entry = data->entry; - lock_kernel(); + mutex_lock(&entry->access); switch (entry->content) { case SNDRV_INFO_CONTENT_TEXT: switch (orig) { @@ -196,7 +196,7 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) } ret = -ENXIO; out: - unlock_kernel(); + mutex_unlock(&entry->access); return ret; } -- cgit v1.2.3 From 4cf19b848f92641eeb2585949a09eedec57fb53a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Apr 2010 18:52:08 +0200 Subject: ALSA: Remove BKL from open multiplexer Use a local mutex instead of BKL. This should suffice since each device type has also its open_mutex. Also, a bit of clean-up of the legacy device auto-loading code. Signed-off-by: Takashi Iwai --- sound/core/sound.c | 73 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'sound/core') diff --git a/sound/core/sound.c b/sound/core/sound.c index 563d1967a0ad..ac42af42b787 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -120,7 +120,29 @@ void *snd_lookup_minor_data(unsigned int minor, int type) EXPORT_SYMBOL(snd_lookup_minor_data); -static int __snd_open(struct inode *inode, struct file *file) +#ifdef CONFIG_MODULES +static struct snd_minor *autoload_device(unsigned int minor) +{ + int dev; + mutex_unlock(&sound_mutex); /* release lock temporarily */ + dev = SNDRV_MINOR_DEVICE(minor); + if (dev == SNDRV_MINOR_CONTROL) { + /* /dev/aloadC? */ + int card = SNDRV_MINOR_CARD(minor); + if (snd_cards[card] == NULL) + snd_request_card(card); + } else if (dev == SNDRV_MINOR_GLOBAL) { + /* /dev/aloadSEQ */ + snd_request_other(minor); + } + mutex_lock(&sound_mutex); /* reacuire lock */ + return snd_minors[minor]; +} +#else /* !CONFIG_MODULES */ +#define autoload_device(minor) NULL +#endif /* CONFIG_MODULES */ + +static int snd_open(struct inode *inode, struct file *file) { unsigned int minor = iminor(inode); struct snd_minor *mptr = NULL; @@ -129,55 +151,36 @@ static int __snd_open(struct inode *inode, struct file *file) if (minor >= ARRAY_SIZE(snd_minors)) return -ENODEV; + mutex_lock(&sound_mutex); mptr = snd_minors[minor]; if (mptr == NULL) { -#ifdef CONFIG_MODULES - int dev = SNDRV_MINOR_DEVICE(minor); - if (dev == SNDRV_MINOR_CONTROL) { - /* /dev/aloadC? */ - int card = SNDRV_MINOR_CARD(minor); - if (snd_cards[card] == NULL) - snd_request_card(card); - } else if (dev == SNDRV_MINOR_GLOBAL) { - /* /dev/aloadSEQ */ - snd_request_other(minor); - } -#ifndef CONFIG_SND_DYNAMIC_MINORS - /* /dev/snd/{controlC?,seq} */ - mptr = snd_minors[minor]; - if (mptr == NULL) -#endif -#endif + mptr = autoload_device(minor); + if (!mptr) { + mutex_unlock(&sound_mutex); return -ENODEV; + } } old_fops = file->f_op; file->f_op = fops_get(mptr->f_ops); if (file->f_op == NULL) { file->f_op = old_fops; - return -ENODEV; + err = -ENODEV; } - if (file->f_op->open) + mutex_unlock(&sound_mutex); + if (err < 0) + return err; + + if (file->f_op->open) { err = file->f_op->open(inode, file); - if (err) { - fops_put(file->f_op); - file->f_op = fops_get(old_fops); + if (err) { + fops_put(file->f_op); + file->f_op = fops_get(old_fops); + } } fops_put(old_fops); return err; } - -/* BKL pushdown: nasty #ifdef avoidance wrapper */ -static int snd_open(struct inode *inode, struct file *file) -{ - int ret; - - lock_kernel(); - ret = __snd_open(inode, file); - unlock_kernel(); - return ret; -} - static const struct file_operations snd_fops = { .owner = THIS_MODULE, -- cgit v1.2.3 From d97e1b78239c7e7e441088e0b644bd3b076002e6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 13 Apr 2010 11:33:54 +0200 Subject: ALSA: info - Check file position validity in common layer Check the validity of the file position in the common info layer before calling read or write callbacks in assumption that entry->size is set up properly to indicate the max file size. Removed the redundant checks from the callbacks as well. Signed-off-by: Takashi Iwai --- sound/core/info.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sound/core') diff --git a/sound/core/info.c b/sound/core/info.c index ff968be81678..f90a6fd43fb4 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -232,10 +232,15 @@ static ssize_t snd_info_entry_read(struct file *file, char __user *buffer, return -EFAULT; break; case SNDRV_INFO_CONTENT_DATA: - if (entry->c.ops->read) + if (pos >= entry->size) + return 0; + if (entry->c.ops->read) { + size = entry->size - pos; + size = min(count, size); size = entry->c.ops->read(entry, data->file_private_data, - file, buffer, count, pos); + file, buffer, size, pos); + } break; } if ((ssize_t) size > 0) @@ -282,10 +287,13 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer size = count; break; case SNDRV_INFO_CONTENT_DATA: - if (entry->c.ops->write) + if (entry->c.ops->write && count > 0) { + size_t maxsize = entry->size - pos; + count = min(count, maxsize); size = entry->c.ops->write(entry, data->file_private_data, file, buffer, count, pos); + } break; } if ((ssize_t) size > 0) -- cgit v1.2.3 From 73029e0ff18dfac8a1aab1dc188e1e150bbe3adc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 13 Apr 2010 11:39:47 +0200 Subject: ALSA: info - Implement common llseek for binary mode The llseek implementation is identical for existing driver implementations, so let's merge to the common layer. The same code for the text proc file can be used even for the binary proc file. The driver can provide its own llseek method if needed. Then the common code will be skipped. Signed-off-by: Takashi Iwai --- sound/core/info.c | 56 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'sound/core') diff --git a/sound/core/info.c b/sound/core/info.c index f90a6fd43fb4..b70564ed8b37 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -164,39 +164,43 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) { struct snd_info_private_data *data; struct snd_info_entry *entry; - loff_t ret; + loff_t ret = -EINVAL, size; data = file->private_data; entry = data->entry; mutex_lock(&entry->access); - switch (entry->content) { - case SNDRV_INFO_CONTENT_TEXT: - switch (orig) { - case SEEK_SET: - file->f_pos = offset; - ret = file->f_pos; - goto out; - case SEEK_CUR: - file->f_pos += offset; - ret = file->f_pos; - goto out; - case SEEK_END: - default: - ret = -EINVAL; - goto out; - } + if (entry->content == SNDRV_INFO_CONTENT_DATA && + entry->c.ops->llseek) { + offset = entry->c.ops->llseek(entry, + data->file_private_data, + file, offset, orig); + goto out; + } + if (entry->content == SNDRV_INFO_CONTENT_DATA) + size = entry->size; + else + size = 0; + switch (orig) { + case SEEK_SET: break; - case SNDRV_INFO_CONTENT_DATA: - if (entry->c.ops->llseek) { - ret = entry->c.ops->llseek(entry, - data->file_private_data, - file, offset, orig); + case SEEK_CUR: + offset += file->f_pos; + break; + case SEEK_END: + if (!size) goto out; - } + offset += size; break; - } - ret = -ENXIO; -out: + default: + goto out; + } + if (offset < 0) + goto out; + if (size && offset > size) + offset = size; + file->f_pos = offset; + ret = offset; + out: mutex_unlock(&entry->access); return ret; } -- cgit v1.2.3 From 02f4865fa415a87de28cc8c2e4d798ff46be1cf8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 13 Apr 2010 11:49:04 +0200 Subject: ALSA: core - Define llseek fops Set no_llseek to llseek file ops of each sound component (but for hwdep). This avoids the implicit BKL invocation via generic_file_llseek() used as default when fops.llseek is NULL. Also call nonseekable_open() at each open ops to ensure the file flags have no seek bit. Signed-off-by: Takashi Iwai --- sound/core/control.c | 5 +++++ sound/core/oss/mixer_oss.c | 5 +++++ sound/core/oss/pcm_oss.c | 5 +++++ sound/core/pcm_native.c | 10 ++++++++-- sound/core/rawmidi.c | 5 +++++ sound/core/seq/seq_clientmgr.c | 6 ++++++ sound/core/timer.c | 6 ++++++ 7 files changed, 40 insertions(+), 2 deletions(-) (limited to 'sound/core') diff --git a/sound/core/control.c b/sound/core/control.c index 439ce64f9d82..070aab490191 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -50,6 +50,10 @@ static int snd_ctl_open(struct inode *inode, struct file *file) struct snd_ctl_file *ctl; int err; + err = nonseekable_open(inode, file); + if (err < 0) + return err; + card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL); if (!card) { err = -ENODEV; @@ -1388,6 +1392,7 @@ static const struct file_operations snd_ctl_f_ops = .read = snd_ctl_read, .open = snd_ctl_open, .release = snd_ctl_release, + .llseek = no_llseek, .poll = snd_ctl_poll, .unlocked_ioctl = snd_ctl_ioctl, .compat_ioctl = snd_ctl_ioctl_compat, diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 54e2eb56e4c2..f50ebf20df96 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -43,6 +43,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file) struct snd_mixer_oss_file *fmixer; int err; + err = nonseekable_open(inode, file); + if (err < 0) + return err; + card = snd_lookup_oss_minor_data(iminor(inode), SNDRV_OSS_DEVICE_TYPE_MIXER); if (card == NULL) @@ -397,6 +401,7 @@ static const struct file_operations snd_mixer_oss_f_ops = .owner = THIS_MODULE, .open = snd_mixer_oss_open, .release = snd_mixer_oss_release, + .llseek = no_llseek, .unlocked_ioctl = snd_mixer_oss_ioctl, .compat_ioctl = snd_mixer_oss_ioctl_compat, }; diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 82d4e3329b3d..5c8c7dff8ede 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -2379,6 +2379,10 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) int nonblock; wait_queue_t wait; + err = nonseekable_open(inode, file); + if (err < 0) + return err; + pcm = snd_lookup_oss_minor_data(iminor(inode), SNDRV_OSS_DEVICE_TYPE_PCM); if (pcm == NULL) { @@ -2977,6 +2981,7 @@ static const struct file_operations snd_pcm_oss_f_reg = .write = snd_pcm_oss_write, .open = snd_pcm_oss_open, .release = snd_pcm_oss_release, + .llseek = no_llseek, .poll = snd_pcm_oss_poll, .unlocked_ioctl = snd_pcm_oss_ioctl, .compat_ioctl = snd_pcm_oss_ioctl_compat, diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index cadba3087768..5b22443ed607 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2107,7 +2107,9 @@ static int snd_pcm_open_file(struct file *file, static int snd_pcm_playback_open(struct inode *inode, struct file *file) { struct snd_pcm *pcm; - + int err = nonseekable_open(inode, file); + if (err < 0) + return err; pcm = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_PCM_PLAYBACK); return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); @@ -2116,7 +2118,9 @@ static int snd_pcm_playback_open(struct inode *inode, struct file *file) static int snd_pcm_capture_open(struct inode *inode, struct file *file) { struct snd_pcm *pcm; - + int err = nonseekable_open(inode, file); + if (err < 0) + return err; pcm = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_PCM_CAPTURE); return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); @@ -3450,6 +3454,7 @@ const struct file_operations snd_pcm_f_ops[2] = { .aio_write = snd_pcm_aio_write, .open = snd_pcm_playback_open, .release = snd_pcm_release, + .llseek = no_llseek, .poll = snd_pcm_playback_poll, .unlocked_ioctl = snd_pcm_playback_ioctl, .compat_ioctl = snd_pcm_ioctl_compat, @@ -3463,6 +3468,7 @@ const struct file_operations snd_pcm_f_ops[2] = { .aio_read = snd_pcm_aio_read, .open = snd_pcm_capture_open, .release = snd_pcm_release, + .llseek = no_llseek, .poll = snd_pcm_capture_poll, .unlocked_ioctl = snd_pcm_capture_ioctl, .compat_ioctl = snd_pcm_ioctl_compat, diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 0f5a194695d9..eb68326c37d4 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -376,6 +376,10 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) return -EINVAL; /* invalid combination */ + err = nonseekable_open(inode, file); + if (err < 0) + return err; + if (maj == snd_major) { rmidi = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_RAWMIDI); @@ -1391,6 +1395,7 @@ static const struct file_operations snd_rawmidi_f_ops = .write = snd_rawmidi_write, .open = snd_rawmidi_open, .release = snd_rawmidi_release, + .llseek = no_llseek, .poll = snd_rawmidi_poll, .unlocked_ioctl = snd_rawmidi_ioctl, .compat_ioctl = snd_rawmidi_ioctl_compat, diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 48eca9ff9ee7..99a485f13648 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -318,6 +318,11 @@ static int snd_seq_open(struct inode *inode, struct file *file) int c, mode; /* client id */ struct snd_seq_client *client; struct snd_seq_user_client *user; + int err; + + err = nonseekable_open(inode, file); + if (err < 0) + return err; if (mutex_lock_interruptible(®ister_mutex)) return -ERESTARTSYS; @@ -2550,6 +2555,7 @@ static const struct file_operations snd_seq_f_ops = .write = snd_seq_write, .open = snd_seq_open, .release = snd_seq_release, + .llseek = no_llseek, .poll = snd_seq_poll, .unlocked_ioctl = snd_seq_ioctl, .compat_ioctl = snd_seq_ioctl_compat, diff --git a/sound/core/timer.c b/sound/core/timer.c index 73943651caed..8c9a661df05b 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1237,6 +1237,11 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, static int snd_timer_user_open(struct inode *inode, struct file *file) { struct snd_timer_user *tu; + int err; + + err = nonseekable_open(inode, file); + if (err < 0) + return err; tu = kzalloc(sizeof(*tu), GFP_KERNEL); if (tu == NULL) @@ -1921,6 +1926,7 @@ static const struct file_operations snd_timer_f_ops = .read = snd_timer_user_read, .open = snd_timer_user_open, .release = snd_timer_user_release, + .llseek = no_llseek, .poll = snd_timer_user_poll, .unlocked_ioctl = snd_timer_user_ioctl, .compat_ioctl = snd_timer_user_ioctl_compat, -- cgit v1.2.3