From e3d280fc6d42017b2379503fbda83655a05294fe Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 17 Feb 2015 21:46:37 +0100 Subject: ALSA: hda - Make snd_hda_bus_type public Define the common hd-audio driver and device types to bind over snd_hda_bus_type publicly. This allows to implement other type of device and driver code over hd-audio bus. Now both struct hda_codec and struct hda_codec_driver inherit these new struct hdac_device and struct hdac_driver, respectively. The bus registration is done in subsys_initcall() to assure it before any other driver registrations. Signed-off-by: Takashi Iwai --- sound/hda/Kconfig | 2 ++ sound/hda/Makefile | 3 +++ sound/hda/hda_bus_type.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 sound/hda/Kconfig create mode 100644 sound/hda/Makefile create mode 100644 sound/hda/hda_bus_type.c (limited to 'sound/hda') diff --git a/sound/hda/Kconfig b/sound/hda/Kconfig new file mode 100644 index 000000000000..4f428ccf64ad --- /dev/null +++ b/sound/hda/Kconfig @@ -0,0 +1,2 @@ +config SND_HDA_CORE + tristate diff --git a/sound/hda/Makefile b/sound/hda/Makefile new file mode 100644 index 000000000000..59c8d1feb5aa --- /dev/null +++ b/sound/hda/Makefile @@ -0,0 +1,3 @@ +snd-hda-core-objs := hda_bus_type.o + +obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o diff --git a/sound/hda/hda_bus_type.c b/sound/hda/hda_bus_type.c new file mode 100644 index 000000000000..519914a12e8a --- /dev/null +++ b/sound/hda/hda_bus_type.c @@ -0,0 +1,42 @@ +/* + * HD-audio bus + */ +#include +#include +#include +#include +#include + +MODULE_DESCRIPTION("HD-audio bus"); +MODULE_LICENSE("GPL"); + +static int hda_bus_match(struct device *dev, struct device_driver *drv) +{ + struct hdac_device *hdev = dev_to_hdac_dev(dev); + struct hdac_driver *hdrv = drv_to_hdac_driver(drv); + + if (hdev->type != hdrv->type) + return 0; + if (hdrv->match) + return hdrv->match(hdev, hdrv); + return 1; +} + +struct bus_type snd_hda_bus_type = { + .name = "hdaudio", + .match = hda_bus_match, +}; +EXPORT_SYMBOL_GPL(snd_hda_bus_type); + +static int __init hda_bus_init(void) +{ + return bus_register(&snd_hda_bus_type); +} + +static void __exit hda_bus_exit(void) +{ + bus_unregister(&snd_hda_bus_type); +} + +subsys_initcall(hda_bus_init); +module_exit(hda_bus_exit); -- cgit v1.2.3-59-g8ed1b