From 6cd421231ea9165226f3cfad9206f8a793aa796f Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 5 Oct 2006 15:06:34 +0200 Subject: [PATCH] --- yaml --- r: 47035 b: refs/heads/master c: c78085fcd2ce7cd036e1488472eb41a64d70949a h: refs/heads/master i: 47033: 39e7655dcaef24141fff445fe6bb3af266a84df6 47031: 92b652bc15108035eec6b9140b694f6e860ea76c v: v3 --- [refs] | 2 +- trunk/include/sound/pcm.h | 1 + trunk/sound/core/pcm.c | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index f8a6ff985d4b..93226da71787 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 12b131c4cf3eb1dc8a60082a434b7b100774c2e7 +refs/heads/master: c78085fcd2ce7cd036e1488472eb41a64d70949a diff --git a/trunk/include/sound/pcm.h b/trunk/include/sound/pcm.h index 2f645dfd7f70..016c41893b06 100644 --- a/trunk/include/sound/pcm.h +++ b/trunk/include/sound/pcm.h @@ -427,6 +427,7 @@ struct snd_pcm { wait_queue_head_t open_wait; void *private_data; void (*private_free) (struct snd_pcm *pcm); + struct device *dev; /* actual hw device this belongs to */ #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) struct snd_pcm_oss oss; #endif diff --git a/trunk/sound/core/pcm.c b/trunk/sound/core/pcm.c index 8e0189885516..4701f07ee0ae 100644 --- a/trunk/sound/core/pcm.c +++ b/trunk/sound/core/pcm.c @@ -944,6 +944,7 @@ static int snd_pcm_dev_register(struct snd_device *device) struct list_head *list; char str[16]; struct snd_pcm *pcm = device->device_data; + struct device *dev; snd_assert(pcm != NULL && device != NULL, return -ENXIO); mutex_lock(®ister_mutex); @@ -966,11 +967,18 @@ 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, - &snd_pcm_f_ops[cidx], - pcm, str)) < 0) - { + /* device pointer to use, pcm->dev takes precedence if + * it is assigned, otherwise fall back to card's device + * if possible */ + dev = pcm->dev; + if (!dev) + dev = pcm->card ? pcm->card->dev : NULL; + /* register pcm */ + err = snd_register_device_for_dev(devtype, pcm->card, + pcm->device, + &snd_pcm_f_ops[cidx], + pcm, str, dev); + if (err < 0) { list_del(&pcm->list); mutex_unlock(®ister_mutex); return err;