~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/hda/hda_bus_type.c

Version: ~ [ linux-5.3 ] ~ [ linux-5.2.15 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.73 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.144 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.193 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.193 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.73 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * HD-audio bus
  3  */
  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>
  9 
 10 MODULE_DESCRIPTION("HD-audio bus");
 11 MODULE_LICENSE("GPL");
 12 
 13 /**
 14  * hdac_get_device_id - gets the hdac device id entry
 15  * @hdev: HD-audio core device
 16  * @drv: HD-audio codec driver
 17  *
 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.
 20  */
 21 const struct hda_device_id *
 22 hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv)
 23 {
 24         if (drv->id_table) {
 25                 const struct hda_device_id *id  = drv->id_table;
 26 
 27                 while (id->vendor_id) {
 28                         if (hdev->vendor_id == id->vendor_id &&
 29                                 (!id->rev_id || id->rev_id == hdev->revision_id))
 30                                 return id;
 31                         id++;
 32                 }
 33         }
 34 
 35         return NULL;
 36 }
 37 EXPORT_SYMBOL_GPL(hdac_get_device_id);
 38 
 39 static int hdac_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
 40 {
 41         if (hdac_get_device_id(dev, drv))
 42                 return 1;
 43         else
 44                 return 0;
 45 }
 46 
 47 static int hda_bus_match(struct device *dev, struct device_driver *drv)
 48 {
 49         struct hdac_device *hdev = dev_to_hdac_dev(dev);
 50         struct hdac_driver *hdrv = drv_to_hdac_driver(drv);
 51 
 52         if (hdev->type != hdrv->type)
 53                 return 0;
 54 
 55         /*
 56          * if driver provided a match function use that otherwise we will
 57          * use hdac_codec_match function
 58          */
 59         if (hdrv->match)
 60                 return hdrv->match(hdev, hdrv);
 61         else
 62                 return hdac_codec_match(hdev, hdrv);
 63         return 1;
 64 }
 65 
 66 struct bus_type snd_hda_bus_type = {
 67         .name = "hdaudio",
 68         .match = hda_bus_match,
 69 };
 70 EXPORT_SYMBOL_GPL(snd_hda_bus_type);
 71 
 72 static int __init hda_bus_init(void)
 73 {
 74         return bus_register(&snd_hda_bus_type);
 75 }
 76 
 77 static void __exit hda_bus_exit(void)
 78 {
 79         bus_unregister(&snd_hda_bus_type);
 80 }
 81 
 82 subsys_initcall(hda_bus_init);
 83 module_exit(hda_bus_exit);
 84 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp