Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bus: mhi: ep: Add uevent support for module autoloading

Add uevent support to MHI endpoint bus so that the client drivers can be
autoloaded by udev when the MHI endpoint devices gets created. The client
drivers are expected to provide MODULE_DEVICE_TABLE with the MHI id_table
struct so that the alias can be exported.

The MHI endpoint reused the mhi_device_id structure of the MHI bus.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20220405135754.6622-19-manivannan.sadhasivam@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Manivannan Sadhasivam and committed by
Greg Kroah-Hartman
c268c0a8 e4b7b5f0

+21
+9
drivers/bus/mhi/ep/main.c
··· 1536 1536 } 1537 1537 EXPORT_SYMBOL_GPL(mhi_ep_driver_unregister); 1538 1538 1539 + static int mhi_ep_uevent(struct device *dev, struct kobj_uevent_env *env) 1540 + { 1541 + struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev); 1542 + 1543 + return add_uevent_var(env, "MODALIAS=" MHI_EP_DEVICE_MODALIAS_FMT, 1544 + mhi_dev->name); 1545 + } 1546 + 1539 1547 static int mhi_ep_match(struct device *dev, struct device_driver *drv) 1540 1548 { 1541 1549 struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev); ··· 1570 1562 .name = "mhi_ep", 1571 1563 .dev_name = "mhi_ep", 1572 1564 .match = mhi_ep_match, 1565 + .uevent = mhi_ep_uevent, 1573 1566 }; 1574 1567 1575 1568 static int __init mhi_ep_init(void)
+2
include/linux/mod_devicetable.h
··· 835 835 #define MHI_DEVICE_MODALIAS_FMT "mhi:%s" 836 836 #define MHI_NAME_SIZE 32 837 837 838 + #define MHI_EP_DEVICE_MODALIAS_FMT "mhi_ep:%s" 839 + 838 840 /** 839 841 * struct mhi_device_id - MHI device identification 840 842 * @chan: MHI channel name
+10
scripts/mod/file2alias.c
··· 1391 1391 return 1; 1392 1392 } 1393 1393 1394 + /* Looks like: mhi_ep:S */ 1395 + static int do_mhi_ep_entry(const char *filename, void *symval, char *alias) 1396 + { 1397 + DEF_FIELD_ADDR(symval, mhi_device_id, chan); 1398 + sprintf(alias, MHI_EP_DEVICE_MODALIAS_FMT, *chan); 1399 + 1400 + return 1; 1401 + } 1402 + 1394 1403 /* Looks like: ishtp:{guid} */ 1395 1404 static int do_ishtp_entry(const char *filename, void *symval, char *alias) 1396 1405 { ··· 1528 1519 {"tee", SIZE_tee_client_device_id, do_tee_entry}, 1529 1520 {"wmi", SIZE_wmi_device_id, do_wmi_entry}, 1530 1521 {"mhi", SIZE_mhi_device_id, do_mhi_entry}, 1522 + {"mhi_ep", SIZE_mhi_device_id, do_mhi_ep_entry}, 1531 1523 {"auxiliary", SIZE_auxiliary_device_id, do_auxiliary_entry}, 1532 1524 {"ssam", SIZE_ssam_device_id, do_ssam_entry}, 1533 1525 {"dfl", SIZE_dfl_device_id, do_dfl_entry},