Commit c78085fc authored by Johannes Berg's avatar Johannes Berg Committed by Jaroslav Kysela

[ALSA] alsa core: add struct device pointer to struct snd_pcm

This patch adds a struct device pointer to struct snd_pcm in order to be
able to give it a different device than the card. It defaults to the card's
device, however, so it should behave identically for drivers not touching
the field.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 12b131c4
...@@ -427,6 +427,7 @@ struct snd_pcm { ...@@ -427,6 +427,7 @@ struct snd_pcm {
wait_queue_head_t open_wait; wait_queue_head_t open_wait;
void *private_data; void *private_data;
void (*private_free) (struct snd_pcm *pcm); 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) #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
struct snd_pcm_oss oss; struct snd_pcm_oss oss;
#endif #endif
......
...@@ -944,6 +944,7 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -944,6 +944,7 @@ static int snd_pcm_dev_register(struct snd_device *device)
struct list_head *list; struct list_head *list;
char str[16]; char str[16];
struct snd_pcm *pcm = device->device_data; struct snd_pcm *pcm = device->device_data;
struct device *dev;
snd_assert(pcm != NULL && device != NULL, return -ENXIO); snd_assert(pcm != NULL && device != NULL, return -ENXIO);
mutex_lock(&register_mutex); mutex_lock(&register_mutex);
...@@ -966,11 +967,18 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -966,11 +967,18 @@ static int snd_pcm_dev_register(struct snd_device *device)
devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
break; break;
} }
if ((err = snd_register_device(devtype, pcm->card, /* 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, pcm->device,
&snd_pcm_f_ops[cidx], &snd_pcm_f_ops[cidx],
pcm, str)) < 0) pcm, str, dev);
{ if (err < 0) {
list_del(&pcm->list); list_del(&pcm->list);
mutex_unlock(&register_mutex); mutex_unlock(&register_mutex);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment