diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-02-28 16:42:09 +0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-02-28 17:02:21 +0400 |
commit | d604b3990884062873e3bef09ef5e89857c409c3 (patch) | |
tree | 2bb427552257ef1404ac61bb67e212b611fe92ea /sound/pci/hda/hda_codec.c | |
parent | 2b9e4a73fbd90cb8459cf84c12ae05d2eb81da41 (diff) | |
download | linux-d604b3990884062873e3bef09ef5e89857c409c3.tar.xz |
ALSA: hda - Fix registration of beep input device
The beep input device is registered via input_register_device(), but
this is called in snd_hda_attach_beep_device() where the sound devices
aren't registered yet. This leads to the binding to non-existing
object, thus results in failure. And, even if the binding worked
(against the PCI object), it's still racy; the input device appears
before the sound objects.
For fixing this, register the input device properly at dev_register
ops of the codec object it's bound with. Also, call
snd_hda_detach_beep_device() at dev_disconnection so that it's
detached at the right timing. As a bonus, since it's called in the
codec's ops, we can get rid of the further call from the other codec
drivers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 6db2dbcbf4d3..4c20277a6835 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1379,14 +1379,19 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, static int snd_hda_codec_dev_register(struct snd_device *device) { struct hda_codec *codec = device->device_data; + int err = device_add(&codec->dev); - return device_add(&codec->dev); + if (err < 0) + return err; + snd_hda_register_beep_device(codec); + return 0; } static int snd_hda_codec_dev_disconnect(struct snd_device *device) { struct hda_codec *codec = device->device_data; + snd_hda_detach_beep_device(codec); device_del(&codec->dev); return 0; } @@ -2692,6 +2697,7 @@ int snd_hda_codec_reset(struct hda_codec *codec) bus->pcm_dev_bits); } } + snd_hda_detach_beep_device(codec); if (codec->patch_ops.free) codec->patch_ops.free(codec); memset(&codec->patch_ops, 0, sizeof(codec->patch_ops)); |