ALSA: compress: Fix kernel-doc warnings
[linux-2.6/btrfs-unstable.git] / sound / hda / hda_bus_type.c
blob3060e2aee36fd736ce3755559d26c7049ba11218
1 /*
2 * HD-audio bus
3 */
4 #include <linux/init.h>
5 #include <linux/device.h>
6 #include <linux/module.h>
7 #include <linux/mod_devicetable.h>
8 #include <linux/export.h>
9 #include <sound/hdaudio.h>
11 MODULE_DESCRIPTION("HD-audio bus");
12 MODULE_LICENSE("GPL");
14 /**
15 * hdac_get_device_id - gets the hdac device id entry
16 * @hdev: HD-audio core device
17 * @drv: HD-audio codec driver
19 * Compares the hdac device vendor_id and revision_id to the hdac_device
20 * driver id_table and returns the matching device id entry.
22 const struct hda_device_id *
23 hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv)
25 if (drv->id_table) {
26 const struct hda_device_id *id = drv->id_table;
28 while (id->vendor_id) {
29 if (hdev->vendor_id == id->vendor_id &&
30 (!id->rev_id || id->rev_id == hdev->revision_id))
31 return id;
32 id++;
36 return NULL;
38 EXPORT_SYMBOL_GPL(hdac_get_device_id);
40 static int hdac_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
42 if (hdac_get_device_id(dev, drv))
43 return 1;
44 else
45 return 0;
48 static int hda_bus_match(struct device *dev, struct device_driver *drv)
50 struct hdac_device *hdev = dev_to_hdac_dev(dev);
51 struct hdac_driver *hdrv = drv_to_hdac_driver(drv);
53 if (hdev->type != hdrv->type)
54 return 0;
57 * if driver provided a match function use that otherwise we will
58 * use hdac_codec_match function
60 if (hdrv->match)
61 return hdrv->match(hdev, hdrv);
62 else
63 return hdac_codec_match(hdev, hdrv);
64 return 1;
67 static int hda_uevent(struct device *dev, struct kobj_uevent_env *env)
69 char modalias[32];
71 snd_hdac_codec_modalias(dev_to_hdac_dev(dev), modalias,
72 sizeof(modalias));
73 if (add_uevent_var(env, "MODALIAS=%s", modalias))
74 return -ENOMEM;
75 return 0;
78 struct bus_type snd_hda_bus_type = {
79 .name = "hdaudio",
80 .match = hda_bus_match,
81 .uevent = hda_uevent,
83 EXPORT_SYMBOL_GPL(snd_hda_bus_type);
85 static int __init hda_bus_init(void)
87 return bus_register(&snd_hda_bus_type);
90 static void __exit hda_bus_exit(void)
92 bus_unregister(&snd_hda_bus_type);
95 subsys_initcall(hda_bus_init);
96 module_exit(hda_bus_exit);