[linux-yocto] [PATCH 1/2] ALSA: hda - Add hduadio support to DEVTABLE

Yong, Jonathan jonathan.yong at intel.com
Mon Mar 14 19:01:59 PDT 2016


From: "Subhransu S. Prusty" <subhransu.s.prusty at intel.com>

For generating modalias entries automatically, move the definition of
struct hda_device_id to linux/mod_devicetable.h and add the handling
of this record in file2alias helper.  The new modalias is represented
with combination of vendor id, device id, and api version as
"hdaudio:vNrNaN".

This patch itself doesn't convert the existing modaliases.  Since they
were added manually, this patch won't give any regression by itself at
this point.

[Modified the modalias format to adapt the api_version field, and drop
 invalid ANY_ID definition by tiwai]

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty at intel.com>
Reviewed-by: Vinod Koul <vinod.koul at intel.com>
Tested-by: Subhransu S Prusty <subhransu.s.prusty at intel.com>
Signed-off-by: Takashi Iwai <tiwai at suse.de>
(cherry picked from commit da23ac1e40ce844d1a9553906bdacce160af76f6)
Signed-off-by: Yong, Jonathan <jonathan.yong at intel.com>
---
 include/linux/mod_devicetable.h   |  8 ++++++++
 include/sound/hdaudio.h           |  1 +
 scripts/mod/devicetable-offsets.c |  5 +++++
 scripts/mod/file2alias.c          | 17 +++++++++++++++++
 sound/hda/hda_bus_type.c          |  1 +
 5 files changed, 32 insertions(+)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 7ab00d6..e62e8d0 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -217,6 +217,14 @@ struct serio_device_id {
 	__u8 proto;
 };
 
+struct hda_device_id {
+	__u32 vendor_id;
+	__u32 rev_id;
+	__u8 api_version;
+	const char *name;
+	unsigned long driver_data;
+};
+
 /*
  * Struct used for matching a device
  */
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index 2a8aa9d..10113e3 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -15,6 +15,7 @@ struct hdac_bus;
 struct hdac_device;
 struct hdac_driver;
 struct hdac_widget_tree;
+struct hda_device_id;
 
 /*
  * exported bus type
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index ada8417..4ae6f9b 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -193,5 +193,10 @@ int main(void)
 	DEVID_FIELD(ulpi_device_id, vendor);
 	DEVID_FIELD(ulpi_device_id, product);
 
+	DEVID(hda_device_id);
+	DEVID_FIELD(hda_device_id, vendor_id);
+	DEVID_FIELD(hda_device_id, rev_id);
+	DEVID_FIELD(hda_device_id, api_version);
+
 	return 0;
 }
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index a7a8560..b696ee1 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1205,6 +1205,23 @@ static int do_ulpi_entry(const char *filename, void *symval,
 }
 ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry);
 
+/* Looks like: hdaudio:vNrNaN */
+static int do_hda_entry(const char *filename, void *symval, char *alias)
+{
+	DEF_FIELD(symval, hda_device_id, vendor_id);
+	DEF_FIELD(symval, hda_device_id, rev_id);
+	DEF_FIELD(symval, hda_device_id, api_version);
+
+	strcpy(alias, "hdaudio:");
+	ADD(alias, "v", vendor_id != 0, vendor_id);
+	ADD(alias, "r", rev_id != 0, rev_id);
+	ADD(alias, "a", api_version != 0, api_version);
+
+	add_wildcard(alias);
+	return 1;
+}
+ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry);
+
 /* Does namelen bytes of name exactly match the symbol? */
 static bool sym_is(const char *name, unsigned namelen, const char *symbol)
 {
diff --git a/sound/hda/hda_bus_type.c b/sound/hda/hda_bus_type.c
index 519914a..1dc12f4 100644
--- a/sound/hda/hda_bus_type.c
+++ b/sound/hda/hda_bus_type.c
@@ -4,6 +4,7 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/export.h>
 #include <sound/hdaudio.h>
 
-- 
2.4.10



More information about the linux-yocto mailing list