mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
driver core: platform: set mod_name in driver registration
Pass KBUILD_MODNAME through the driver registration macro so that the
driver core can create the module symlink in sysfs for built-in drivers,
and fixup all callers.
The Rust platform adapter is updated to pass the module name through to
the new parameter.
Tested on qemu with:
- x86 defconfig + CONFIG_RUST
- arm64 defconfig + CONFIG_RUST + CONFIG_CORESIGHT stuff
Examples after this patch:
/sys/bus/platform/drivers/...
coresight-itnoc/module -> coresight_tnoc
coresight-static-tpdm/module -> coresight_tpdm
coresight-catu-platform/module -> coresight_catu
serial8250/module -> 8250
acpi-ged/module -> acpi
vmclock/module -> ptp_vmclock
Co-developed-by: Rahul Bukte <rahul.bukte@sony.com>
Signed-off-by: Rahul Bukte <rahul.bukte@sony.com>
Signed-off-by: Shashank Balaji <shashank.mahadasyam@sony.com>
Link: https://patch.msgid.link/20260518-acpi_mod_name-v5-4-705ccc430885@sony.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
committed by
Danilo Krummrich
parent
efc22b3f89
commit
a7a7dc5c46
@@ -70,7 +70,8 @@ Kernel modules can be composed of several platform drivers. The platform core
|
||||
provides helpers to register and unregister an array of drivers::
|
||||
|
||||
int __platform_register_drivers(struct platform_driver * const *drivers,
|
||||
unsigned int count, struct module *owner);
|
||||
unsigned int count, struct module *owner,
|
||||
const char *mod_name);
|
||||
void platform_unregister_drivers(struct platform_driver * const *drivers,
|
||||
unsigned int count);
|
||||
|
||||
|
||||
@@ -915,11 +915,14 @@ EXPORT_SYMBOL_GPL(platform_device_register_full);
|
||||
* __platform_driver_register - register a driver for platform-level devices
|
||||
* @drv: platform driver structure
|
||||
* @owner: owning module/driver
|
||||
* @mod_name: module name string
|
||||
*/
|
||||
int __platform_driver_register(struct platform_driver *drv, struct module *owner)
|
||||
int __platform_driver_register(struct platform_driver *drv, struct module *owner,
|
||||
const char *mod_name)
|
||||
{
|
||||
drv->driver.owner = owner;
|
||||
drv->driver.bus = &platform_bus_type;
|
||||
drv->driver.mod_name = mod_name;
|
||||
|
||||
return driver_register(&drv->driver);
|
||||
}
|
||||
@@ -952,6 +955,7 @@ static int is_bound_to_driver(struct device *dev, void *driver)
|
||||
* @drv: platform driver structure
|
||||
* @probe: the driver probe routine, probably from an __init section
|
||||
* @module: module which will be the owner of the driver
|
||||
* @mod_name: module name string
|
||||
*
|
||||
* Use this instead of platform_driver_register() when you know the device
|
||||
* is not hotpluggable and has already been registered, and you want to
|
||||
@@ -969,7 +973,8 @@ static int is_bound_to_driver(struct device *dev, void *driver)
|
||||
*/
|
||||
int __init_or_module __platform_driver_probe(struct platform_driver *drv,
|
||||
int (*probe)(struct platform_device *),
|
||||
struct module *module)
|
||||
struct module *module,
|
||||
const char *mod_name)
|
||||
{
|
||||
int retval;
|
||||
|
||||
@@ -997,7 +1002,7 @@ int __init_or_module __platform_driver_probe(struct platform_driver *drv,
|
||||
|
||||
/* temporary section violation during probe() */
|
||||
drv->probe = probe;
|
||||
retval = __platform_driver_register(drv, module);
|
||||
retval = __platform_driver_register(drv, module, mod_name);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
@@ -1025,6 +1030,7 @@ EXPORT_SYMBOL_GPL(__platform_driver_probe);
|
||||
* @data: platform specific data for this platform device
|
||||
* @size: size of platform specific data
|
||||
* @module: module which will be the owner of the driver
|
||||
* @mod_name: module name string
|
||||
*
|
||||
* Use this in legacy-style modules that probe hardware directly and
|
||||
* register a single platform device and corresponding platform driver.
|
||||
@@ -1035,7 +1041,7 @@ struct platform_device * __init_or_module
|
||||
__platform_create_bundle(struct platform_driver *driver,
|
||||
int (*probe)(struct platform_device *),
|
||||
struct resource *res, unsigned int n_res,
|
||||
const void *data, size_t size, struct module *module)
|
||||
const void *data, size_t size, struct module *module, const char *mod_name)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
int error;
|
||||
@@ -1058,7 +1064,7 @@ __platform_create_bundle(struct platform_driver *driver,
|
||||
if (error)
|
||||
goto err_pdev_put;
|
||||
|
||||
error = __platform_driver_probe(driver, probe, module);
|
||||
error = __platform_driver_probe(driver, probe, module, mod_name);
|
||||
if (error)
|
||||
goto err_pdev_del;
|
||||
|
||||
@@ -1078,6 +1084,7 @@ EXPORT_SYMBOL_GPL(__platform_create_bundle);
|
||||
* @drivers: an array of drivers to register
|
||||
* @count: the number of drivers to register
|
||||
* @owner: module owning the drivers
|
||||
* @mod_name: module name string
|
||||
*
|
||||
* Registers platform drivers specified by an array. On failure to register a
|
||||
* driver, all previously registered drivers will be unregistered. Callers of
|
||||
@@ -1087,7 +1094,7 @@ EXPORT_SYMBOL_GPL(__platform_create_bundle);
|
||||
* Returns: 0 on success or a negative error code on failure.
|
||||
*/
|
||||
int __platform_register_drivers(struct platform_driver * const *drivers,
|
||||
unsigned int count, struct module *owner)
|
||||
unsigned int count, struct module *owner, const char *mod_name)
|
||||
{
|
||||
unsigned int i;
|
||||
int err;
|
||||
@@ -1095,7 +1102,7 @@ int __platform_register_drivers(struct platform_driver * const *drivers,
|
||||
for (i = 0; i < count; i++) {
|
||||
pr_debug("registering platform driver %ps\n", drivers[i]);
|
||||
|
||||
err = __platform_driver_register(drivers[i], owner);
|
||||
err = __platform_driver_register(drivers[i], owner, mod_name);
|
||||
if (err < 0) {
|
||||
pr_err("failed to register platform driver %ps: %d\n",
|
||||
drivers[i], err);
|
||||
|
||||
@@ -1695,7 +1695,8 @@ module_init(coresight_init);
|
||||
module_exit(coresight_exit);
|
||||
|
||||
int coresight_init_driver_with_owner(const char *drv, struct amba_driver *amba_drv,
|
||||
struct platform_driver *pdev_drv, struct module *owner)
|
||||
struct platform_driver *pdev_drv, struct module *owner,
|
||||
const char *mod_name)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -1705,7 +1706,7 @@ int coresight_init_driver_with_owner(const char *drv, struct amba_driver *amba_d
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = __platform_driver_register(pdev_drv, owner);
|
||||
ret = __platform_driver_register(pdev_drv, owner, mod_name);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -692,9 +692,10 @@ coresight_find_output_type(struct coresight_platform_data *pdata,
|
||||
union coresight_dev_subtype subtype);
|
||||
|
||||
int coresight_init_driver_with_owner(const char *drv, struct amba_driver *amba_drv,
|
||||
struct platform_driver *pdev_drv, struct module *owner);
|
||||
struct platform_driver *pdev_drv, struct module *owner,
|
||||
const char *mod_name);
|
||||
#define coresight_init_driver(drv, amba_drv, pdev_drv) \
|
||||
coresight_init_driver_with_owner(drv, amba_drv, pdev_drv, THIS_MODULE)
|
||||
coresight_init_driver_with_owner(drv, amba_drv, pdev_drv, THIS_MODULE, KBUILD_MODNAME)
|
||||
|
||||
void coresight_remove_driver(struct amba_driver *amba_drv,
|
||||
struct platform_driver *pdev_drv);
|
||||
|
||||
@@ -293,18 +293,19 @@ struct platform_driver {
|
||||
* use a macro to avoid include chaining to get THIS_MODULE
|
||||
*/
|
||||
#define platform_driver_register(drv) \
|
||||
__platform_driver_register(drv, THIS_MODULE)
|
||||
__platform_driver_register(drv, THIS_MODULE, KBUILD_MODNAME)
|
||||
extern int __platform_driver_register(struct platform_driver *,
|
||||
struct module *);
|
||||
struct module *, const char *mod_name);
|
||||
extern void platform_driver_unregister(struct platform_driver *);
|
||||
|
||||
/* non-hotpluggable platform devices may use this so that probe() and
|
||||
* its support may live in __init sections, conserving runtime memory.
|
||||
*/
|
||||
#define platform_driver_probe(drv, probe) \
|
||||
__platform_driver_probe(drv, probe, THIS_MODULE)
|
||||
__platform_driver_probe(drv, probe, THIS_MODULE, KBUILD_MODNAME)
|
||||
extern int __platform_driver_probe(struct platform_driver *driver,
|
||||
int (*probe)(struct platform_device *), struct module *module);
|
||||
int (*probe)(struct platform_device *), struct module *module,
|
||||
const char *mod_name);
|
||||
|
||||
static inline void *platform_get_drvdata(const struct platform_device *pdev)
|
||||
{
|
||||
@@ -368,19 +369,19 @@ static int __init __platform_driver##_init(void) \
|
||||
device_initcall(__platform_driver##_init); \
|
||||
|
||||
#define platform_create_bundle(driver, probe, res, n_res, data, size) \
|
||||
__platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE)
|
||||
__platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE, KBUILD_MODNAME)
|
||||
extern struct platform_device *__platform_create_bundle(
|
||||
struct platform_driver *driver, int (*probe)(struct platform_device *),
|
||||
struct resource *res, unsigned int n_res,
|
||||
const void *data, size_t size, struct module *module);
|
||||
const void *data, size_t size, struct module *module, const char *mod_name);
|
||||
|
||||
int __platform_register_drivers(struct platform_driver * const *drivers,
|
||||
unsigned int count, struct module *owner);
|
||||
unsigned int count, struct module *owner, const char *mod_name);
|
||||
void platform_unregister_drivers(struct platform_driver * const *drivers,
|
||||
unsigned int count);
|
||||
|
||||
#define platform_register_drivers(drivers, count) \
|
||||
__platform_register_drivers(drivers, count, THIS_MODULE)
|
||||
__platform_register_drivers(drivers, count, THIS_MODULE, KBUILD_MODNAME)
|
||||
|
||||
#ifdef CONFIG_SUSPEND
|
||||
extern int platform_pm_suspend(struct device *dev);
|
||||
|
||||
@@ -82,7 +82,9 @@ unsafe fn register(
|
||||
}
|
||||
|
||||
// SAFETY: `pdrv` is guaranteed to be a valid `DriverType`.
|
||||
to_result(unsafe { bindings::__platform_driver_register(pdrv.get(), module.0) })
|
||||
to_result(unsafe {
|
||||
bindings::__platform_driver_register(pdrv.get(), module.0, name.as_char_ptr())
|
||||
})
|
||||
}
|
||||
|
||||
unsafe fn unregister(pdrv: &Opaque<Self::DriverType>) {
|
||||
|
||||
Reference in New Issue
Block a user