diff options
author | Mattias Jacobsson <2pi@mok.nu> | 2019-02-19 14:59:50 -0500 |
---|---|---|
committer | Darren Hart (VMware) <dvhart@infradead.org> | 2019-03-07 11:46:29 -0500 |
commit | 0bc44b2b8ba39212258e2742c2806cdcabad7cba (patch) | |
tree | a35780c069952f17a4d470d20eb4084598245bb7 /scripts/mod/file2alias.c | |
parent | eacc95eae6837d3f41aed7d30b855a79ab2cb101 (diff) |
platform/x86: wmi: add WMI support to MODULE_DEVICE_TABLE()
The kernel provides the macro MODULE_DEVICE_TABLE() where driver authors
can specify their device type and their array of device_ids and thereby
trigger the generation of the appropriate MODULE_ALIAS() output. This is
opposed to having to specify one MODULE_ALIAS() for each device. The WMI
device type is currently not supported.
While using MODULE_DEVICE_TABLE() does increase the complexity as well
as spreading out the implementation across the kernel, it does come with
some benefits too;
* It makes different drivers look more similar; if you can specify the
array of device_ids any device type specific input to MODULE_ALIAS()
will automatically be generated for you.
* It helps each driver avoid keeping multiple versions of the same
information in sync. That is, both the array of device_ids and the
potential multitude of MODULE_ALIAS()'s.
Add WMI support to MODULE_DEVICE_TABLE() by adding info about struct
wmi_device_id in devicetable-offsets.c and add a WMI entry point in
file2alias.c.
The type argument for MODULE_DEVICE_TABLE(type, name) is wmi.
Suggested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Mattias Jacobsson <2pi@mok.nu>
Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r-- | scripts/mod/file2alias.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 4e4f03a12cc0..6dedc31a4925 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -1291,6 +1291,27 @@ static int do_typec_entry(const char *filename, void *symval, char *alias) | |||
1291 | return 1; | 1291 | return 1; |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | /* Looks like: wmi:guid */ | ||
1295 | static int do_wmi_entry(const char *filename, void *symval, char *alias) | ||
1296 | { | ||
1297 | int len; | ||
1298 | DEF_FIELD_ADDR(symval, wmi_device_id, guid_string); | ||
1299 | |||
1300 | if (strlen(*guid_string) != UUID_STRING_LEN) { | ||
1301 | warn("Invalid WMI device id 'wmi:%s' in '%s'\n", | ||
1302 | *guid_string, filename); | ||
1303 | return 0; | ||
1304 | } | ||
1305 | |||
1306 | len = snprintf(alias, ALIAS_SIZE, WMI_MODULE_PREFIX "%s", *guid_string); | ||
1307 | if (len < 0 || len >= ALIAS_SIZE) { | ||
1308 | warn("Could not generate all MODULE_ALIAS's in '%s'\n", | ||
1309 | filename); | ||
1310 | return 0; | ||
1311 | } | ||
1312 | return 1; | ||
1313 | } | ||
1314 | |||
1294 | /* Does namelen bytes of name exactly match the symbol? */ | 1315 | /* Does namelen bytes of name exactly match the symbol? */ |
1295 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) | 1316 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) |
1296 | { | 1317 | { |
@@ -1361,6 +1382,7 @@ static const struct devtable devtable[] = { | |||
1361 | {"fslmc", SIZE_fsl_mc_device_id, do_fsl_mc_entry}, | 1382 | {"fslmc", SIZE_fsl_mc_device_id, do_fsl_mc_entry}, |
1362 | {"tbsvc", SIZE_tb_service_id, do_tbsvc_entry}, | 1383 | {"tbsvc", SIZE_tb_service_id, do_tbsvc_entry}, |
1363 | {"typec", SIZE_typec_device_id, do_typec_entry}, | 1384 | {"typec", SIZE_typec_device_id, do_typec_entry}, |
1385 | {"wmi", SIZE_wmi_device_id, do_wmi_entry}, | ||
1364 | }; | 1386 | }; |
1365 | 1387 | ||
1366 | /* Create MODULE_ALIAS() statements. | 1388 | /* Create MODULE_ALIAS() statements. |