Skip to content

Commit e6b0de4

Browse files
Mani-Sadhasivamgregkh
authored andcommitted
bus: mhi: core: Add uevent support for module autoloading
Add uevent support to MHI bus so that the client drivers can be autoloaded by udev when the MHI 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. Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Tested-by: Jeffrey Hugo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 189ff97 commit e6b0de4

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

drivers/bus/mhi/core/init.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,14 @@ void mhi_driver_unregister(struct mhi_driver *mhi_drv)
12101210
}
12111211
EXPORT_SYMBOL_GPL(mhi_driver_unregister);
12121212

1213+
static int mhi_uevent(struct device *dev, struct kobj_uevent_env *env)
1214+
{
1215+
struct mhi_device *mhi_dev = to_mhi_device(dev);
1216+
1217+
return add_uevent_var(env, "MODALIAS=" MHI_DEVICE_MODALIAS_FMT,
1218+
mhi_dev->chan_name);
1219+
}
1220+
12131221
static int mhi_match(struct device *dev, struct device_driver *drv)
12141222
{
12151223
struct mhi_device *mhi_dev = to_mhi_device(dev);
@@ -1236,6 +1244,7 @@ struct bus_type mhi_bus_type = {
12361244
.name = "mhi",
12371245
.dev_name = "mhi",
12381246
.match = mhi_match,
1247+
.uevent = mhi_uevent,
12391248
};
12401249

12411250
static int __init mhi_init(void)

include/linux/mod_devicetable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ struct wmi_device_id {
821821
const void *context;
822822
};
823823

824+
#define MHI_DEVICE_MODALIAS_FMT "mhi:%s"
824825
#define MHI_NAME_SIZE 32
825826

826827
/**

scripts/mod/devicetable-offsets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,5 +231,8 @@ int main(void)
231231
DEVID(wmi_device_id);
232232
DEVID_FIELD(wmi_device_id, guid_string);
233233

234+
DEVID(mhi_device_id);
235+
DEVID_FIELD(mhi_device_id, chan);
236+
234237
return 0;
235238
}

scripts/mod/file2alias.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,15 @@ static int do_wmi_entry(const char *filename, void *symval, char *alias)
13351335
return 1;
13361336
}
13371337

1338+
/* Looks like: mhi:S */
1339+
static int do_mhi_entry(const char *filename, void *symval, char *alias)
1340+
{
1341+
DEF_FIELD_ADDR(symval, mhi_device_id, chan);
1342+
sprintf(alias, MHI_DEVICE_MODALIAS_FMT, *chan);
1343+
1344+
return 1;
1345+
}
1346+
13381347
/* Does namelen bytes of name exactly match the symbol? */
13391348
static bool sym_is(const char *name, unsigned namelen, const char *symbol)
13401349
{
@@ -1407,6 +1416,7 @@ static const struct devtable devtable[] = {
14071416
{"typec", SIZE_typec_device_id, do_typec_entry},
14081417
{"tee", SIZE_tee_client_device_id, do_tee_entry},
14091418
{"wmi", SIZE_wmi_device_id, do_wmi_entry},
1419+
{"mhi", SIZE_mhi_device_id, do_mhi_entry},
14101420
};
14111421

14121422
/* Create MODULE_ALIAS() statements.

0 commit comments

Comments
 (0)