4 #include <linux/init.h>
5 #include <linux/device.h>
6 #include <linux/module.h>
7 #include <linux/export.h>
8 #include <sound/hdaudio.h>
10 MODULE_DESCRIPTION("HD-audio bus");
11 MODULE_LICENSE("GPL");
14 * hdac_get_device_id - gets the hdac device id entry
15 * @hdev: HD-audio core device
16 * @drv: HD-audio codec driver
18 * Compares the hdac device vendor_id and revision_id to the hdac_device
19 * driver id_table and returns the matching device id entry.
21 const struct hda_device_id
*
22 hdac_get_device_id(struct hdac_device
*hdev
, struct hdac_driver
*drv
)
25 const struct hda_device_id
*id
= drv
->id_table
;
27 while (id
->vendor_id
) {
28 if (hdev
->vendor_id
== id
->vendor_id
&&
29 (!id
->rev_id
|| id
->rev_id
== hdev
->revision_id
))
37 EXPORT_SYMBOL_GPL(hdac_get_device_id
);
39 static int hdac_codec_match(struct hdac_device
*dev
, struct hdac_driver
*drv
)
41 if (hdac_get_device_id(dev
, drv
))
47 static int hda_bus_match(struct device
*dev
, struct device_driver
*drv
)
49 struct hdac_device
*hdev
= dev_to_hdac_dev(dev
);
50 struct hdac_driver
*hdrv
= drv_to_hdac_driver(drv
);
52 if (hdev
->type
!= hdrv
->type
)
56 * if driver provided a match function use that otherwise we will
57 * use hdac_codec_match function
60 return hdrv
->match(hdev
, hdrv
);
62 return hdac_codec_match(hdev
, hdrv
);
66 struct bus_type snd_hda_bus_type
= {
68 .match
= hda_bus_match
,
70 EXPORT_SYMBOL_GPL(snd_hda_bus_type
);
72 static int __init
hda_bus_init(void)
74 return bus_register(&snd_hda_bus_type
);
77 static void __exit
hda_bus_exit(void)
79 bus_unregister(&snd_hda_bus_type
);
82 subsys_initcall(hda_bus_init
);
83 module_exit(hda_bus_exit
);