diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-02-25 02:05:21 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-02-25 06:12:50 -0500 |
commit | 71e2e1c147e653ee4e861b8b5dc0ae5c394870d2 (patch) | |
tree | 1701a7be7dc767eba25d1993117dd900795d81ba /sound/core | |
parent | f806bdb2f7235907fcd310e6d147b3bcd281fa97 (diff) |
ALSA: hwdep: Allow to assign the given parent
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>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/hwdep.c | 19 |
1 files changed, 12 insertions, 7 deletions
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) | |||
416 | { | 416 | { |
417 | struct snd_hwdep *hwdep = device->device_data; | 417 | struct snd_hwdep *hwdep = device->device_data; |
418 | struct snd_card *card = hwdep->card; | 418 | struct snd_card *card = hwdep->card; |
419 | struct device *dev; | ||
419 | int err; | 420 | int err; |
420 | char name[32]; | 421 | char name[32]; |
421 | 422 | ||
@@ -426,10 +427,14 @@ static int snd_hwdep_dev_register(struct snd_device *device) | |||
426 | } | 427 | } |
427 | list_add_tail(&hwdep->list, &snd_hwdep_devices); | 428 | list_add_tail(&hwdep->list, &snd_hwdep_devices); |
428 | sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); | 429 | sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); |
429 | if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, | 430 | dev = hwdep->dev; |
430 | hwdep->card, hwdep->device, | 431 | if (!dev) |
431 | &snd_hwdep_f_ops, hwdep, name)) < 0) { | 432 | dev = snd_card_get_device_link(hwdep->card); |
432 | dev_err(card->dev, | 433 | err = snd_register_device_for_dev(SNDRV_DEVICE_TYPE_HWDEP, |
434 | hwdep->card, hwdep->device, | ||
435 | &snd_hwdep_f_ops, hwdep, name, dev); | ||
436 | if (err < 0) { | ||
437 | dev_err(dev, | ||
433 | "unable to register hardware dependent device %i:%i\n", | 438 | "unable to register hardware dependent device %i:%i\n", |
434 | card->number, hwdep->device); | 439 | card->number, hwdep->device); |
435 | list_del(&hwdep->list); | 440 | list_del(&hwdep->list); |
@@ -445,7 +450,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) | |||
445 | dev_set_drvdata(d, hwdep->private_data); | 450 | dev_set_drvdata(d, hwdep->private_data); |
446 | err = sysfs_create_groups(&d->kobj, hwdep->groups); | 451 | err = sysfs_create_groups(&d->kobj, hwdep->groups); |
447 | if (err < 0) | 452 | if (err < 0) |
448 | dev_warn(card->dev, | 453 | dev_warn(dev, |
449 | "hwdep %d:%d: cannot create sysfs groups\n", | 454 | "hwdep %d:%d: cannot create sysfs groups\n", |
450 | card->number, hwdep->device); | 455 | card->number, hwdep->device); |
451 | put_device(d); | 456 | put_device(d); |
@@ -456,13 +461,13 @@ static int snd_hwdep_dev_register(struct snd_device *device) | |||
456 | hwdep->ossreg = 0; | 461 | hwdep->ossreg = 0; |
457 | if (hwdep->oss_type >= 0) { | 462 | if (hwdep->oss_type >= 0) { |
458 | if ((hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM) && (hwdep->device != 0)) { | 463 | if ((hwdep->oss_type == SNDRV_OSS_DEVICE_TYPE_DMFM) && (hwdep->device != 0)) { |
459 | dev_warn(card->dev, | 464 | dev_warn(dev, |
460 | "only hwdep device 0 can be registered as OSS direct FM device!\n"); | 465 | "only hwdep device 0 can be registered as OSS direct FM device!\n"); |
461 | } else { | 466 | } else { |
462 | if (snd_register_oss_device(hwdep->oss_type, | 467 | if (snd_register_oss_device(hwdep->oss_type, |
463 | card, hwdep->device, | 468 | card, hwdep->device, |
464 | &snd_hwdep_f_ops, hwdep) < 0) { | 469 | &snd_hwdep_f_ops, hwdep) < 0) { |
465 | dev_err(card->dev, | 470 | dev_err(dev, |
466 | "unable to register OSS compatibility device %i:%i\n", | 471 | "unable to register OSS compatibility device %i:%i\n", |
467 | card->number, hwdep->device); | 472 | card->number, hwdep->device); |
468 | } else | 473 | } else |