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");
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
)
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
))
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
))
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
)
57 * if driver provided a match function use that otherwise we will
58 * use hdac_codec_match function
61 return hdrv
->match(hdev
, hdrv
);
63 return hdac_codec_match(hdev
, hdrv
);
67 static int hda_uevent(struct device
*dev
, struct kobj_uevent_env
*env
)
71 snd_hdac_codec_modalias(dev_to_hdac_dev(dev
), modalias
,
73 if (add_uevent_var(env
, "MODALIAS=%s", modalias
))
78 struct bus_type snd_hda_bus_type
= {
80 .match
= hda_bus_match
,
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
);