On Fri, Sep 18, 2026 at 11:29:50AM +0200, Hans de Goede wrote: > From: Bjorn Andersson > > SCMI client drivers already describe their bus match data with > MODULE_DEVICE_TABLE(scmi, ...), but modpost does not know how to consume > SCMI device tables. As a result, SCMI modules do not get generated module > aliases from their id tables. > > Move struct scmi_device_id to mod_devicetable.h so it has a fixed layout > visible to modpost, add the corresponding generated offsets and teach > file2alias to emit scmi:: aliases. > > Use the same stable alias format for SCMI device uevents and sysfs > modaliases. The previous string included the instance-specific device > name, which is not useful for matching modules. > > Assisted-by: Codex:GPT-5.5 > Reviewed-by: Hans de Goede > Tested-by: Hans de Goede > Signed-off-by: Bjorn Andersson > Signed-off-by: Hans de Goede > --- > Changes in v7: > - Rebase on top of v7.3-rc3 > > Changes in v4: > - Drop unused driver_data member from struct scmi_device_id (Uwe) > - Drop device-id/scmi.h include from mod_devicetable.h (Uwe) > - Add device-id/scmi.h to devicetable-offsets.c and file2alias.c (Uwe) > > Changes in v3: > - Adjust for ad428f5811bd ("mod_devicetable.h: Split into per subsystem > headers") > - Add '\n' to modalias_show() output, matching other subsystems' modalias > > Changes in v2: > - Drop #include from scmi_protocol.h > - Link to v1: https://patch.msgid.link/20260616-scmi-modalias-v1-0-662b8dd52ab2@oss.qualcomm.com > --- > MAINTAINERS | 1 + > drivers/firmware/arm_scmi/bus.c | 21 ++++++++++----------- > include/linux/device-id/scmi.h | 17 +++++++++++++++++ > include/linux/scmi_protocol.h | 6 +----- > scripts/mod/devicetable-offsets.c | 5 +++++ > scripts/mod/file2alias.c | 12 ++++++++++++ > 6 files changed, 46 insertions(+), 16 deletions(-) > create mode 100644 include/linux/device-id/scmi.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index c2414447892c..f351ec56a2ec 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -26604,6 +26604,7 @@ F: drivers/pmdomain/arm/ > F: drivers/powercap/arm_scmi_powercap.c > F: drivers/regulator/scmi-regulator.c > F: drivers/reset/reset-scmi.c > +F: include/linux/device-id/scmi.h > F: include/linux/sc[mp]i_protocol.h > F: include/trace/events/scmi.h > F: include/uapi/linux/virtio_scmi.h > diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c > index e060edbe7e83..51de50fbc382 100644 > --- a/drivers/firmware/arm_scmi/bus.c > +++ b/drivers/firmware/arm_scmi/bus.c > @@ -12,11 +12,12 @@ > #include > #include > #include > +#include > #include > > #include "common.h" > > -#define SCMI_UEVENT_MODALIAS_FMT "%s:%02x:%s" > +#define SCMI_UEVENT_MODALIAS_FMT SCMI_MODULE_PREFIX "%02x:%s" > > BLOCKING_NOTIFIER_HEAD(scmi_requested_devices_nh); > EXPORT_SYMBOL_GPL(scmi_requested_devices_nh); > @@ -185,7 +186,7 @@ static int scmi_protocol_table_register(const struct scmi_device_id *id_table) > const struct scmi_device_id *entry; > int ret; > > - for (entry = id_table; entry->name; entry++) { > + for (entry = id_table; entry->name[0]; entry++) { > ret = scmi_protocol_device_request(entry); > if (ret) > goto err_unrequest; > @@ -205,7 +206,7 @@ scmi_protocol_table_unregister(const struct scmi_device_id *id_table) > { > const struct scmi_device_id *entry; > > - for (entry = id_table; entry->name; entry++) > + for (entry = id_table; entry->name[0]; entry++) > scmi_protocol_device_unrequest(entry); > } > > @@ -219,10 +220,10 @@ static int __scmi_dev_match_by_id_table(struct scmi_device *scmi_dev, > const struct scmi_device_id *id_table, > bool skip_transport) > { > - if (!id_table || !id_table->name) > + if (!id_table || !id_table->name[0]) > return 0; > > - for (; id_table->protocol_id && id_table->name; id_table++) > + for (; id_table->protocol_id && id_table->name[0]; id_table++) > if (id_table->protocol_id == scmi_dev->protocol_id && > !(skip_transport && scmi_device_is_transport(scmi_dev)) && > !strcmp(id_table->name, scmi_dev->name)) > @@ -266,7 +267,7 @@ scmi_child_dev_find_get(struct device *parent, int prot_id, const char *name) > struct device *dev; > > id_table[0].protocol_id = prot_id; > - id_table[0].name = name; > + strscpy(id_table[0].name, name, sizeof(id_table[0].name)); > > dev = device_find_child(parent, &id_table, scmi_match_by_id_table); > if (!dev) > @@ -300,8 +301,7 @@ static int scmi_device_uevent(const struct device *dev, struct kobj_uevent_env * > const struct scmi_device *scmi_dev = to_scmi_dev(dev); > > return add_uevent_var(env, "MODALIAS=" SCMI_UEVENT_MODALIAS_FMT, > - dev_name(&scmi_dev->dev), scmi_dev->protocol_id, > - scmi_dev->name); > + scmi_dev->protocol_id, scmi_dev->name); > } > > static ssize_t modalias_show(struct device *dev, > @@ -309,9 +309,8 @@ static ssize_t modalias_show(struct device *dev, > { > struct scmi_device *scmi_dev = to_scmi_dev(dev); > > - return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT, > - dev_name(&scmi_dev->dev), scmi_dev->protocol_id, > - scmi_dev->name); > + return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT "\n", > + scmi_dev->protocol_id, scmi_dev->name); > } > static DEVICE_ATTR_RO(modalias); > > diff --git a/include/linux/device-id/scmi.h b/include/linux/device-id/scmi.h > new file mode 100644 > index 000000000000..1b4ccfa9dcc5 > --- /dev/null > +++ b/include/linux/device-id/scmi.h > @@ -0,0 +1,17 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +#ifndef LINUX_DEVICE_ID_SCMI_H > +#define LINUX_DEVICE_ID_SCMI_H > + > +#ifdef __KERNEL__ > +#include > +#endif > + > +#define SCMI_NAME_SIZE 32 > +#define SCMI_MODULE_PREFIX "scmi:" > + > +struct scmi_device_id { > + __u8 protocol_id; > + char name[SCMI_NAME_SIZE]; I wonder if you tried to keep this a char *. ISTR someone did something similar recently and they claimed it worked. That would get rid of the artificial name size limit and simplify this patch. > +}; > + > +#endif /* ifndef LINUX_DEVICE_ID_SCMI_H */ > diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h > index 5ab73b1ab9aa..ba53302d95f5 100644 > --- a/include/linux/scmi_protocol.h > +++ b/include/linux/scmi_protocol.h > @@ -9,6 +9,7 @@ > #define _LINUX_SCMI_PROTOCOL_H > > #include > +#include > #include > #include > #include > @@ -951,11 +952,6 @@ struct scmi_device { > > #define to_scmi_dev(d) container_of_const(d, struct scmi_device, dev) > > -struct scmi_device_id { > - u8 protocol_id; > - const char *name; > -}; > - > struct scmi_driver { > const char *name; > int (*probe)(struct scmi_device *sdev); > diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c > index b4178c42d08f..91ec3704ee2b 100644 > --- a/scripts/mod/devicetable-offsets.c > +++ b/scripts/mod/devicetable-offsets.c > @@ -1,5 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0 > #define COMPILE_OFFSETS > +#include > #include > #include > > @@ -144,6 +145,10 @@ int main(void) > DEVID(rpmsg_device_id); > DEVID_FIELD(rpmsg_device_id, name); > > + DEVID(scmi_device_id); > + DEVID_FIELD(scmi_device_id, protocol_id); > + DEVID_FIELD(scmi_device_id, name); > + > DEVID(i2c_device_id); > DEVID_FIELD(i2c_device_id, name); > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > index 8d36c74dec2d..5379b1def07b 100644 > --- a/scripts/mod/file2alias.c > +++ b/scripts/mod/file2alias.c > @@ -121,6 +121,7 @@ typedef struct { > /* Big exception to the "don't include kernel headers into userspace, which > * even potentially has different endianness and word sizes, since > * we handle those differences explicitly below */ > +#include "../../include/linux/device-id/scmi.h" > #include "../../include/linux/mod_devicetable.h" > > struct devtable { > @@ -852,6 +853,16 @@ static void do_rpmsg_entry(struct module *mod, void *symval) > module_alias_printf(mod, false, RPMSG_DEVICE_MODALIAS_FMT, *name); > } > > +/* Looks like: scmi:NN:S */ > +static void do_scmi_entry(struct module *mod, void *symval) > +{ > + DEF_FIELD(symval, scmi_device_id, protocol_id); > + DEF_FIELD_ADDR(symval, scmi_device_id, name); > + > + module_alias_printf(mod, false, SCMI_MODULE_PREFIX "%02x:%s", > + protocol_id, *name); > +} > + > /* Looks like: i2c:S */ > static void do_i2c_entry(struct module *mod, void *symval) > { > @@ -1491,6 +1502,7 @@ static const struct devtable devtable[] = { > {"virtio", SIZE_virtio_device_id, do_virtio_entry}, > {"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry}, > {"rpmsg", SIZE_rpmsg_device_id, do_rpmsg_entry}, > + {"scmi", SIZE_scmi_device_id, do_scmi_entry}, > {"i2c", SIZE_i2c_device_id, do_i2c_entry}, > {"i3c", SIZE_i3c_device_id, do_i3c_entry}, > {"slim", SIZE_slim_device_id, do_slim_entry}, I wonder if this is supposed to be ordered alphabetically ... Best regards Uwe