aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-06-26 11:24:45 -0400
committerTakashi Iwai <tiwai@suse.de>2014-06-26 12:00:01 -0400
commit703c759f38cce7950ab460552236ca1d15adb916 (patch)
treeb451c198836b0a7daff82d2e564017d17e3cd32c /sound/pci
parent9a34af4a33270acbd60a85f819553463866aecbb (diff)
ALSA: hda - Use common reboot notifier
The very same notifier code is used in both hda_intel.c and hda_tegra.c. Move it to the generic code. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_controller.c26
-rw-r--r--sound/pci/hda/hda_controller.h3
-rw-r--r--sound/pci/hda/hda_intel.c24
-rw-r--r--sound/pci/hda/hda_tegra.c29
4 files changed, 31 insertions, 51 deletions
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index a562d86c02fb..8d9398a4c7c9 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/pm_runtime.h> 28#include <linux/pm_runtime.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/reboot.h>
30#include <sound/core.h> 31#include <sound/core.h>
31#include <sound/initval.h> 32#include <sound/initval.h>
32#include "hda_priv.h" 33#include "hda_priv.h"
@@ -1946,5 +1947,30 @@ int azx_init_stream(struct azx *chip)
1946} 1947}
1947EXPORT_SYMBOL_GPL(azx_init_stream); 1948EXPORT_SYMBOL_GPL(azx_init_stream);
1948 1949
1950/*
1951 * reboot notifier for hang-up problem at power-down
1952 */
1953static int azx_halt(struct notifier_block *nb, unsigned long event, void *buf)
1954{
1955 struct azx *chip = container_of(nb, struct azx, reboot_notifier);
1956 snd_hda_bus_reboot_notify(chip->bus);
1957 azx_stop_chip(chip);
1958 return NOTIFY_OK;
1959}
1960
1961void azx_notifier_register(struct azx *chip)
1962{
1963 chip->reboot_notifier.notifier_call = azx_halt;
1964 register_reboot_notifier(&chip->reboot_notifier);
1965}
1966EXPORT_SYMBOL_GPL(azx_notifier_register);
1967
1968void azx_notifier_unregister(struct azx *chip)
1969{
1970 if (chip->reboot_notifier.notifier_call)
1971 unregister_reboot_notifier(&chip->reboot_notifier);
1972}
1973EXPORT_SYMBOL_GPL(azx_notifier_unregister);
1974
1949MODULE_LICENSE("GPL"); 1975MODULE_LICENSE("GPL");
1950MODULE_DESCRIPTION("Common HDA driver funcitons"); 1976MODULE_DESCRIPTION("Common HDA driver funcitons");
diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
index 91f04958e2b0..c90d10fd4d8f 100644
--- a/sound/pci/hda/hda_controller.h
+++ b/sound/pci/hda/hda_controller.h
@@ -50,4 +50,7 @@ int azx_codec_configure(struct azx *chip);
50int azx_mixer_create(struct azx *chip); 50int azx_mixer_create(struct azx *chip);
51int azx_init_stream(struct azx *chip); 51int azx_init_stream(struct azx *chip);
52 52
53void azx_notifier_register(struct azx *chip);
54void azx_notifier_unregister(struct azx *chip);
55
53#endif /* __SOUND_HDA_CONTROLLER_H */ 56#endif /* __SOUND_HDA_CONTROLLER_H */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index bbb446aef67a..1e971e2f1d50 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -44,7 +44,6 @@
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/reboot.h>
48#include <linux/io.h> 47#include <linux/io.h>
49#include <linux/pm_runtime.h> 48#include <linux/pm_runtime.h>
50#include <linux/clocksource.h> 49#include <linux/clocksource.h>
@@ -952,29 +951,6 @@ static const struct dev_pm_ops azx_pm = {
952#endif /* CONFIG_PM */ 951#endif /* CONFIG_PM */
953 952
954 953
955/*
956 * reboot notifier for hang-up problem at power-down
957 */
958static int azx_halt(struct notifier_block *nb, unsigned long event, void *buf)
959{
960 struct azx *chip = container_of(nb, struct azx, reboot_notifier);
961 snd_hda_bus_reboot_notify(chip->bus);
962 azx_stop_chip(chip);
963 return NOTIFY_OK;
964}
965
966static void azx_notifier_register(struct azx *chip)
967{
968 chip->reboot_notifier.notifier_call = azx_halt;
969 register_reboot_notifier(&chip->reboot_notifier);
970}
971
972static void azx_notifier_unregister(struct azx *chip)
973{
974 if (chip->reboot_notifier.notifier_call)
975 unregister_reboot_notifier(&chip->reboot_notifier);
976}
977
978static int azx_probe_continue(struct azx *chip); 954static int azx_probe_continue(struct azx *chip);
979 955
980#ifdef SUPPORT_VGA_SWITCHEROO 956#ifdef SUPPORT_VGA_SWITCHEROO
diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index 12920b99d238..cf69dafa91c0 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -29,7 +29,6 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/of_device.h> 31#include <linux/of_device.h>
32#include <linux/reboot.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
34#include <linux/time.h> 33#include <linux/time.h>
35 34
@@ -295,30 +294,6 @@ static const struct dev_pm_ops hda_tegra_pm = {
295}; 294};
296 295
297/* 296/*
298 * reboot notifier for hang-up problem at power-down
299 */
300static int hda_tegra_halt(struct notifier_block *nb, unsigned long event,
301 void *buf)
302{
303 struct azx *chip = container_of(nb, struct azx, reboot_notifier);
304 snd_hda_bus_reboot_notify(chip->bus);
305 azx_stop_chip(chip);
306 return NOTIFY_OK;
307}
308
309static void hda_tegra_notifier_register(struct azx *chip)
310{
311 chip->reboot_notifier.notifier_call = hda_tegra_halt;
312 register_reboot_notifier(&chip->reboot_notifier);
313}
314
315static void hda_tegra_notifier_unregister(struct azx *chip)
316{
317 if (chip->reboot_notifier.notifier_call)
318 unregister_reboot_notifier(&chip->reboot_notifier);
319}
320
321/*
322 * destructor 297 * destructor
323 */ 298 */
324static int hda_tegra_dev_free(struct snd_device *device) 299static int hda_tegra_dev_free(struct snd_device *device)
@@ -326,7 +301,7 @@ static int hda_tegra_dev_free(struct snd_device *device)
326 int i; 301 int i;
327 struct azx *chip = device->device_data; 302 struct azx *chip = device->device_data;
328 303
329 hda_tegra_notifier_unregister(chip); 304 azx_notifier_unregister(chip);
330 305
331 if (chip->initialized) { 306 if (chip->initialized) {
332 for (i = 0; i < chip->num_streams; i++) 307 for (i = 0; i < chip->num_streams; i++)
@@ -557,7 +532,7 @@ static int hda_tegra_probe(struct platform_device *pdev)
557 532
558 chip->running = 1; 533 chip->running = 1;
559 power_down_all_codecs(chip); 534 power_down_all_codecs(chip);
560 hda_tegra_notifier_register(chip); 535 azx_notifier_register(chip);
561 536
562 return 0; 537 return 0;
563 538