From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 03/10] ALSA: hwdep: Allow to assign the given parent
Date: Wed, 26 Feb 2014 07:47:25 +0100 [thread overview]
Message-ID: <1393397252-11690-4-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1393397252-11690-1-git-send-email-tiwai@suse.de>
Just like PCM, allow hwdep to be assigned to a different parent device
than the card. It'll be used for the HD-audio codec device in the
later patches.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
include/sound/hwdep.h | 1 +
sound/core/hwdep.c | 19 ++++++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h
index 193a3c57ed25..ae04a3ec9c77 100644
--- a/include/sound/hwdep.h
+++ b/include/sound/hwdep.h
@@ -68,6 +68,7 @@ struct snd_hwdep {
wait_queue_head_t open_wait;
void *private_data;
void (*private_free) (struct snd_hwdep *hwdep);
+ struct device *dev;
const struct attribute_group **groups;
struct mutex open_mutex;
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 825cd2847940..d6eb3ef3e3c7 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -416,6 +416,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
{
struct snd_hwdep *hwdep = device->device_data;
struct snd_card *card = hwdep->card;
+ struct device *dev;
int err;
char name[32];
@@ -426,10 +427,14 @@ static int snd_hwdep_dev_register(struct snd_device *device)
}
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, hwdep, name)) < 0) {
- dev_err(card->dev,
+ dev = hwdep->dev;
+ if (!dev)
+ dev = snd_card_get_device_link(hwdep->card);
+ err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_HWDEP,
+ hwdep->card, hwdep->device,
+ &snd_hwdep_f_ops, hwdep, name, dev);
+ if (err < 0) {
+ dev_err(dev,
"unable to register hardware dependent device %i:%i\n",
card->number, hwdep->device);
list_del(&hwdep->list);
@@ -445,7 +450,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
dev_set_drvdata(d, hwdep->private_data);
err = sysfs_create_groups(&d->kobj, hwdep->groups);
if (err < 0)
- dev_warn(card->dev,
+ dev_warn(dev,
"hwdep %d:%d: cannot create sysfs groups\n",
card->number, hwdep->device);
put_device(d);
@@ -456,13 +461,13 @@ static int snd_hwdep_dev_register(struct snd_device *device)
hwdep->ossreg = 0;
if (hwdep->oss_type >= 0) {
if ((hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM) && (hwdep->device != 0)) {
- dev_warn(card->dev,
+ dev_warn(dev,
"only hwdep device 0 can be registered as OSS direct FM device!\n");
} else {
if (snd_register_oss_device(hwdep->oss_type,
card, hwdep->device,
&snd_hwdep_f_ops, hwdep) < 0) {
- dev_err(card->dev,
+ dev_err(dev,
"unable to register OSS compatibility device %i:%i\n",
card->number, hwdep->device);
} else
--
1.9.0
next prev parent reply other threads:[~2014-02-26 6:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 6:47 [PATCH 00/10] A few more ALSA and HD-audio core updates Takashi Iwai
2014-02-26 6:47 ` [PATCH 01/10] ALSA: Create sysfs attribute files via groups Takashi Iwai
2014-02-26 6:47 ` [PATCH 02/10] ALSA: hwdep: Take private_data as drvdata for sysfs Takashi Iwai
2014-02-26 6:47 ` Takashi Iwai [this message]
2014-02-26 6:47 ` [PATCH 04/10] ALSA: Use priority list for managing device list Takashi Iwai
2014-02-26 6:47 ` [PATCH 05/10] ALSA: Clean up snd_device_*() codes Takashi Iwai
2014-02-26 6:47 ` [PATCH 06/10] ALSA: hda - Manage each codec instance individually Takashi Iwai
2014-02-26 6:47 ` [PATCH 07/10] ALSA: hda - Create own device struct for each codec Takashi Iwai
2014-02-26 6:47 ` [PATCH 08/10] ALSA: hda - Add sysfs to codec object, too Takashi Iwai
2014-02-26 6:47 ` [PATCH 09/10] ALSA: hda - Enable sysfs attributes without CONFIG_SND_HDA_RECONFIG Takashi Iwai
2014-02-26 6:47 ` [PATCH 10/10] ALSA: hda - Replace with standard printk Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1393397252-11690-4-git-send-email-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox