Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 110855
b: refs/heads/master
c: 896e6cc
h: refs/heads/master
i:
  110853: dca1f8a
  110851: b4a22e7
  110847: b872747
v: v3
  • Loading branch information
Jaroslav Kysela committed Aug 1, 2008
1 parent 20c0e29 commit d85a556
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 46 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 687fbc3fece34e7e1c2ac529348ad897095a0bde
refs/heads/master: 896e6cc20e67038af12e1a7711eef32647e62f23
2 changes: 0 additions & 2 deletions trunk/include/sound/minors.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
*
*/

#define SNDRV_OS_MINORS 256

#define SNDRV_MINOR_DEVICES 32
#define SNDRV_MINOR_CARD(minor) ((minor) >> 5)
#define SNDRV_MINOR_DEVICE(minor) ((minor) & 0x001f)
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/sound/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct snd_pcm_ops {
*
*/

#define SNDRV_PCM_DEVICES 8

#define SNDRV_PCM_IOCTL1_FALSE ((void *)0)
#define SNDRV_PCM_IOCTL1_TRUE ((void *)1)

Expand Down Expand Up @@ -414,7 +416,7 @@ struct snd_pcm_str {
struct snd_pcm {
struct snd_card *card;
struct list_head list;
int device; /* device number */
unsigned int device; /* device number */
unsigned int info_flags;
unsigned short dev_class;
unsigned short dev_subclass;
Expand Down
10 changes: 5 additions & 5 deletions trunk/sound/core/oss/pcm_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -2947,7 +2947,7 @@ static void register_oss_dsp(struct snd_pcm *pcm, int index)
static int snd_pcm_oss_register_minor(struct snd_pcm *pcm)
{
pcm->oss.reg = 0;
if (dsp_map[pcm->card->number] == pcm->device) {
if (dsp_map[pcm->card->number] == (int)pcm->device) {
char name[128];
int duplex;
register_oss_dsp(pcm, 0);
Expand All @@ -2963,7 +2963,7 @@ static int snd_pcm_oss_register_minor(struct snd_pcm *pcm)
pcm->oss.reg++;
pcm->oss.reg_mask |= 1;
}
if (adsp_map[pcm->card->number] == pcm->device) {
if (adsp_map[pcm->card->number] == (int)pcm->device) {
register_oss_dsp(pcm, 1);
pcm->oss.reg++;
pcm->oss.reg_mask |= 2;
Expand All @@ -2988,7 +2988,7 @@ static int snd_pcm_oss_disconnect_minor(struct snd_pcm *pcm)
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM,
pcm->card, 1);
}
if (dsp_map[pcm->card->number] == pcm->device) {
if (dsp_map[pcm->card->number] == (int)pcm->device) {
#ifdef SNDRV_OSS_INFO_DEV_AUDIO
snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_AUDIO, pcm->card->number);
#endif
Expand Down Expand Up @@ -3019,12 +3019,12 @@ static int __init alsa_pcm_oss_init(void)

/* check device map table */
for (i = 0; i < SNDRV_CARDS; i++) {
if (dsp_map[i] < 0 || dsp_map[i] >= SNDRV_OS_MINORS) {
if (dsp_map[i] < 0 || dsp_map[i] >= SNDRV_PCM_DEVICES) {
snd_printk(KERN_ERR "invalid dsp_map[%d] = %d\n",
i, dsp_map[i]);
dsp_map[i] = 0;
}
if (adsp_map[i] < 0 || adsp_map[i] >= SNDRV_OS_MINORS) {
if (adsp_map[i] < 0 || adsp_map[i] >= SNDRV_PCM_DEVICES) {
snd_printk(KERN_ERR "invalid adsp_map[%d] = %d\n",
i, adsp_map[i]);
adsp_map[i] = 1;
Expand Down
50 changes: 13 additions & 37 deletions trunk/sound/core/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int snd_pcm_dev_free(struct snd_device *device);
static int snd_pcm_dev_register(struct snd_device *device);
static int snd_pcm_dev_disconnect(struct snd_device *device);

static inline struct snd_pcm *snd_pcm_get(struct snd_card *card, int device)
static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device)
{
struct snd_pcm *pcm;

Expand All @@ -53,37 +53,6 @@ static inline struct snd_pcm *snd_pcm_get(struct snd_card *card, int device)
return NULL;
}

static inline int snd_pcm_next(struct snd_card *card, int device)
{
struct snd_pcm *pcm;

list_for_each_entry(pcm, &snd_pcm_devices, list) {
if (pcm->card == card && pcm->device > device)
return pcm->device;
else if (pcm->card->number > card->number)
return -1;
}
return -1;
}

static inline int snd_pcm_add(struct snd_pcm *newpcm)
{
struct snd_pcm *pcm;

list_for_each_entry(pcm, &snd_pcm_devices, list) {
if (pcm->card == newpcm->card && pcm->device == newpcm->device)
return -EBUSY;
if (pcm->card->number > newpcm->card->number ||
(pcm->card == newpcm->card &&
pcm->device > newpcm->device)) {
list_add(&newpcm->list, pcm->list.prev);
return 0;
}
}
list_add_tail(&newpcm->list, &snd_pcm_devices);
return 0;
}

static int snd_pcm_control_ioctl(struct snd_card *card,
struct snd_ctl_file *control,
unsigned int cmd, unsigned long arg)
Expand All @@ -96,7 +65,14 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
if (get_user(device, (int __user *)arg))
return -EFAULT;
mutex_lock(&register_mutex);
device = snd_pcm_next(card, device);
device = device < 0 ? 0 : device + 1;
while (device < SNDRV_PCM_DEVICES) {
if (snd_pcm_search(card, device))
break;
device++;
}
if (device == SNDRV_PCM_DEVICES)
device = -1;
mutex_unlock(&register_mutex);
if (put_user(device, (int __user *)arg))
return -EFAULT;
Expand All @@ -122,7 +98,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
if (get_user(subdevice, &info->subdevice))
return -EFAULT;
mutex_lock(&register_mutex);
pcm = snd_pcm_get(card, device);
pcm = snd_pcm_search(card, device);
if (pcm == NULL) {
err = -ENXIO;
goto _error;
Expand Down Expand Up @@ -955,11 +931,11 @@ static int snd_pcm_dev_register(struct snd_device *device)

snd_assert(pcm != NULL && device != NULL, return -ENXIO);
mutex_lock(&register_mutex);
err = snd_pcm_add(pcm);
if (err) {
if (snd_pcm_search(pcm->card, pcm->device)) {
mutex_unlock(&register_mutex);
return err;
return -EBUSY;
}
list_add_tail(&pcm->list, &snd_pcm_devices);
for (cidx = 0; cidx < 2; cidx++) {
int devtype = -1;
if (pcm->streams[cidx].substream == NULL)
Expand Down
2 changes: 2 additions & 0 deletions trunk/sound/core/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <linux/kmod.h>
#include <linux/mutex.h>

#define SNDRV_OS_MINORS 256

static int major = CONFIG_SND_MAJOR;
int snd_major;
EXPORT_SYMBOL(snd_major);
Expand Down

0 comments on commit d85a556

Please sign in to comment.