History

HID: intel-ish-hid: fix module device-id handling

A late addititon to the intel-ish-hid framework caused a build failure with clang, and introduced an ABI to the module loader that stops working if any driver ever needs to bind to more than one UUID: drivers/hid/intel-ish-hid/ishtp-fw-loader.c:1067:4: error: initializer element is not a compile-time constant Change the ishtp_device_id to have correct documentation and a driver_data field like all the other ones, and change the drivers to use the ID table as the primary identification in a way that works with all compilers and avoids duplciating the identifiers.

Arnd Bergmann committed 5 years ago

Commit bf9167a1 parent 64355db7 files · +37 −47Browse files

Unified · Split

7 files
  1. drivers/hid/intel-ish-hid/ishtp-fw-loader.c +8 −11
  2. drivers/hid/intel-ish-hid/ishtp-hid-client.c +8 −11
  3. drivers/hid/intel-ish-hid/ishtp/bus.c +1 −1
  4. drivers/platform/chrome/cros_ec_ishtp.c +8 −11
  5. drivers/platform/x86/intel/ishtp_eclite.c +8 −11
  6. include/linux/intel-ish-client-if.h +2 −2
  7. include/linux/mod_devicetable.h +2 −0
drivers/hid/intel-ish-hid/ishtp-fw-loader.c+8−11
@@ -76,9 +76,12 @@ enum ish_loader_commands { · 75 unmodified lines
7676 #define LOADER_XFER_MODE_ISHTP BIT(1)
7777
7878 /* ISH Transport Loader client unique GUID */
79−static const guid_t loader_ishtp_guid =
80− GUID_INIT(0xc804d06a, 0x55bd, 0x4ea7,
81− 0xad, 0xed, 0x1e, 0x31, 0x22, 0x8c, 0x76, 0xdc);
79+static const struct ishtp_device_id loader_ishtp_id_table[] = {
80+ { .guid = GUID_INIT(0xc804d06a, 0x55bd, 0x4ea7,
81+ 0xad, 0xed, 0x1e, 0x31, 0x22, 0x8c, 0x76, 0xdc) },
82+ { }
83+};
84+MODULE_DEVICE_TABLE(ishtp, loader_ishtp_id_table);
8285
8386 #define FILENAME_SIZE 256
8487
@@ -880,7 +883,7 @@ static int loader_init(struct ishtp_cl *loader_ishtp_cl, int reset) · 795 unmodified lines
880883
881884 fw_client =
882885 ishtp_fw_cl_get_client(ishtp_get_ishtp_device(loader_ishtp_cl),
883− &loader_ishtp_guid);
886+ &loader_ishtp_id_table[0].guid);
884887 if (!fw_client) {
885888 dev_err(cl_data_to_dev(client_data),
886889 "ISH client uuid not found\n");
@@ -1057,18 +1060,12 @@ static int loader_ishtp_cl_reset(struct ishtp_cl_device *cl_device) · 170 unmodified lines
10571060
10581061 static struct ishtp_cl_driver loader_ishtp_cl_driver = {
10591062 .name = "ish-loader",
1060− .guid = &loader_ishtp_guid,
1063+ .id = loader_ishtp_id_table,
10611064 .probe = loader_ishtp_cl_probe,
10621065 .remove = loader_ishtp_cl_remove,
10631066 .reset = loader_ishtp_cl_reset,
10641067 };
10651068
1066−static const struct ishtp_device_id loader_ishtp_id_table[] = {
1067− { loader_ishtp_guid },
1068− { }
1069−};
1070−MODULE_DEVICE_TABLE(ishtp, loader_ishtp_id_table);
1071−
10721069 static int __init ish_loader_init(void)
10731070 {
10741071 return ishtp_cl_driver_register(&loader_ishtp_cl_driver, THIS_MODULE);
drivers/hid/intel-ish-hid/ishtp-hid-client.c+8−11
@@ -12,9 +12,12 @@ · 11 unmodified lines
1212 #include "ishtp-hid.h"
1313
1414 /* ISH Transport protocol (ISHTP in short) GUID */
15−static const guid_t hid_ishtp_guid =
16− GUID_INIT(0x33AECD58, 0xB679, 0x4E54,
17− 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26);
15+static const struct ishtp_device_id hid_ishtp_id_table[] = {
16+ { .guid = GUID_INIT(0x33AECD58, 0xB679, 0x4E54,
17+ 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26), },
18+ { }
19+};
20+MODULE_DEVICE_TABLE(ishtp, hid_ishtp_id_table);
1821
1922 /* Rx ring buffer pool size */
2023 #define HID_CL_RX_RING_SIZE 32
@@ -662,7 +665,7 @@ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, int reset) · 641 unmodified lines
662665 ishtp_set_tx_ring_size(hid_ishtp_cl, HID_CL_TX_RING_SIZE);
663666 ishtp_set_rx_ring_size(hid_ishtp_cl, HID_CL_RX_RING_SIZE);
664667
665− fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_guid);
668+ fw_client = ishtp_fw_cl_get_client(dev, &hid_ishtp_id_table[0].guid);
666669 if (!fw_client) {
667670 dev_err(cl_data_to_dev(client_data),
668671 "ish client uuid not found\n");
@@ -945,19 +948,13 @@ static const struct dev_pm_ops hid_ishtp_pm_ops = { · 276 unmodified lines
945948
946949 static struct ishtp_cl_driver hid_ishtp_cl_driver = {
947950 .name = "ish-hid",
948− .guid = &hid_ishtp_guid,
951+ .id = hid_ishtp_id_table,
949952 .probe = hid_ishtp_cl_probe,
950953 .remove = hid_ishtp_cl_remove,
951954 .reset = hid_ishtp_cl_reset,
952955 .driver.pm = &hid_ishtp_pm_ops,
953956 };
954957
955−static const struct ishtp_device_id hid_ishtp_id_table[] = {
956− { hid_ishtp_guid },
957− { }
958−};
959−MODULE_DEVICE_TABLE(ishtp, hid_ishtp_id_table);
960−
961958 static int __init ish_hid_init(void)
962959 {
963960 int rv;
drivers/hid/intel-ish-hid/ishtp/bus.c+1−1
@@ -241,7 +241,7 @@ static int ishtp_cl_bus_match(struct device *dev, struct device_driver *drv) · 240 unmodified lines
241241 struct ishtp_cl_device *device = to_ishtp_cl_device(dev);
242242 struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv);
243243
244− return guid_equal(driver->guid,
244+ return guid_equal(&driver->id[0].guid,
245245 &device->fw_client->props.protocol_name);
246246 }
247247
drivers/platform/chrome/cros_ec_ishtp.c+8−11
@@ -41,9 +41,12 @@ enum cros_ec_ish_channel { · 40 unmodified lines
4141 #define ISHTP_SEND_TIMEOUT (3 * HZ)
4242
4343 /* ISH Transport CrOS EC ISH client unique GUID */
44−static const guid_t cros_ish_guid =
45− GUID_INIT(0x7b7154d0, 0x56f4, 0x4bdc,
46− 0xb0, 0xd8, 0x9e, 0x7c, 0xda, 0xe0, 0xd6, 0xa0);
44+static const struct ishtp_device_id cros_ec_ishtp_id_table[] = {
45+ { .guid = GUID_INIT(0x7b7154d0, 0x56f4, 0x4bdc,
46+ 0xb0, 0xd8, 0x9e, 0x7c, 0xda, 0xe0, 0xd6, 0xa0), },
47+ { }
48+};
49+MODULE_DEVICE_TABLE(ishtp, cros_ec_ishtp_id_table);
4750
4851 struct header {
4952 u8 channel;
@@ -389,7 +392,7 @@ static int cros_ish_init(struct ishtp_cl *cros_ish_cl) · 339 unmodified lines
389392 ishtp_set_tx_ring_size(cros_ish_cl, CROS_ISH_CL_TX_RING_SIZE);
390393 ishtp_set_rx_ring_size(cros_ish_cl, CROS_ISH_CL_RX_RING_SIZE);
391394
392− fw_client = ishtp_fw_cl_get_client(dev, &cros_ish_guid);
395+ fw_client = ishtp_fw_cl_get_client(dev, &cros_ec_ishtp_id_table[0].guid);
393396 if (!fw_client) {
394397 dev_err(cl_data_to_dev(client_data),
395398 "ish client uuid not found\n");
@@ -765,7 +768,7 @@ static SIMPLE_DEV_PM_OPS(cros_ec_ishtp_pm_ops, cros_ec_ishtp_suspend, · 369 unmodified lines
765768
766769 static struct ishtp_cl_driver cros_ec_ishtp_driver = {
767770 .name = "cros_ec_ishtp",
768− .guid = &cros_ish_guid,
771+ .id = cros_ec_ishtp_id_table,
769772 .probe = cros_ec_ishtp_probe,
770773 .remove = cros_ec_ishtp_remove,
771774 .reset = cros_ec_ishtp_reset,
@@ -774,12 +777,6 @@ static struct ishtp_cl_driver cros_ec_ishtp_driver = { · 2 unmodified lines
774777 },
775778 };
776779
777−static const struct ishtp_device_id cros_ec_ishtp_id_table[] = {
778− { cros_ish_guid },
779− { }
780−};
781−MODULE_DEVICE_TABLE(ishtp, cros_ec_ishtp_id_table);
782−
783780 static int __init cros_ec_ishtp_mod_init(void)
784781 {
785782 return ishtp_cl_driver_register(&cros_ec_ishtp_driver, THIS_MODULE);
drivers/platform/x86/intel/ishtp_eclite.c+8−11
@@ -93,9 +93,12 @@ struct ishtp_opregion_dev { · 92 unmodified lines
9393 };
9494
9595 /* eclite ishtp client UUID: 6a19cc4b-d760-4de3-b14d-f25ebd0fbcd9 */
96−static const guid_t ecl_ishtp_guid =
97− GUID_INIT(0x6a19cc4b, 0xd760, 0x4de3,
98− 0xb1, 0x4d, 0xf2, 0x5e, 0xbd, 0xf, 0xbc, 0xd9);
96+static const struct ishtp_device_id ecl_ishtp_id_table[] = {
97+ { .guid = GUID_INIT(0x6a19cc4b, 0xd760, 0x4de3,
98+ 0xb1, 0x4d, 0xf2, 0x5e, 0xbd, 0xf, 0xbc, 0xd9), },
99+ { }
100+};
101+MODULE_DEVICE_TABLE(ishtp, ecl_ishtp_id_table);
99102
100103 /* ACPI DSM UUID: 91d936a7-1f01-49c6-a6b4-72f00ad8d8a5 */
101104 static const guid_t ecl_acpi_guid =
@@ -462,7 +465,7 @@ static int ecl_ishtp_cl_init(struct ishtp_cl *ecl_ishtp_cl) · 360 unmodified lines
462465 ishtp_set_tx_ring_size(ecl_ishtp_cl, ECL_CL_TX_RING_SIZE);
463466 ishtp_set_rx_ring_size(ecl_ishtp_cl, ECL_CL_RX_RING_SIZE);
464467
465− fw_client = ishtp_fw_cl_get_client(dev, &ecl_ishtp_guid);
468+ fw_client = ishtp_fw_cl_get_client(dev, &ecl_ishtp_id_table[0].guid);
466469 if (!fw_client) {
467470 dev_err(cl_data_to_dev(opr_dev), "fw client not found\n");
468471 return -ENOENT;
@@ -674,19 +677,13 @@ static const struct dev_pm_ops ecl_ishtp_pm_ops = { · 205 unmodified lines
674677
675678 static struct ishtp_cl_driver ecl_ishtp_cl_driver = {
676679 .name = "ishtp-eclite",
677− .guid = &ecl_ishtp_guid,
680+ .id = ecl_ishtp_id_table,
678681 .probe = ecl_ishtp_cl_probe,
679682 .remove = ecl_ishtp_cl_remove,
680683 .reset = ecl_ishtp_cl_reset,
681684 .driver.pm = &ecl_ishtp_pm_ops,
682685 };
683686
684−static const struct ishtp_device_id ecl_ishtp_id_table[] = {
685− { ecl_ishtp_guid },
686− { }
687−};
688−MODULE_DEVICE_TABLE(ishtp, ecl_ishtp_id_table);
689−
690687 static int __init ecl_ishtp_init(void)
691688 {
692689 return ishtp_cl_driver_register(&ecl_ishtp_cl_driver, THIS_MODULE);
include/linux/intel-ish-client-if.h+2−2
@@ -9,7 +9,7 @@ · 8 unmodified lines
99 #define _INTEL_ISH_CLIENT_IF_H_
1010
1111 #include <linux/device.h>
12−#include <linux/uuid.h>
12+#include <linux/mod_devicetable.h>
1313
1414 struct ishtp_cl_device;
1515 struct ishtp_device;
@@ -40,7 +40,7 @@ enum cl_state { · 24 unmodified lines
4040 struct ishtp_cl_driver {
4141 struct device_driver driver;
4242 const char *name;
43− const guid_t *guid;
43+ const struct ishtp_device_id *id;
4444 int (*probe)(struct ishtp_cl_device *dev);
4545 void (*remove)(struct ishtp_cl_device *dev);
4646 int (*reset)(struct ishtp_cl_device *dev);
include/linux/mod_devicetable.h+2−0
@@ -902,9 +902,11 @@ struct dfl_device_id { · 901 unmodified lines
902902 /**
903903 * struct ishtp_device_id - ISHTP device identifier
904904 * @guid: GUID of the device.
905+ * @driver_data: pointer to driver specific data
905906 */
906907 struct ishtp_device_id {
907908 guid_t guid;
909+ kernel_ulong_t driver_data;
908910 };
909911
910912 #endif /* LINUX_MOD_DEVICETABLE_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t