diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2025-03-10 22:24:15 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-04-15 17:04:35 +0200 |
| commit | 04d3e5461c1f5cf8eec964ab64948ebed826e95e (patch) | |
| tree | 351d0dae5f9a8a932f0b3cd0cb0cc797ff94abfd /drivers/base/base.h | |
| parent | dc1771f718548f7d4b93991b174c6e7b5e1ba410 (diff) | |
driver core: introduce device_set_driver() helper
In preparation to closing a race when reading driver pointer in
dev_uevent() code, instead of setting device->driver pointer directly
introduce device_set_driver() helper.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20250311052417.1846985-2-dmitry.torokhov@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/base.h')
| -rw-r--r-- | drivers/base/base.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index 0042e4774b0c..eb203cf8370b 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -180,6 +180,12 @@ int driver_add_groups(const struct device_driver *drv, const struct attribute_gr void driver_remove_groups(const struct device_driver *drv, const struct attribute_group **groups); void device_driver_detach(struct device *dev); +static inline void device_set_driver(struct device *dev, const struct device_driver *drv) +{ + // FIXME - this cast should not be needed "soon" + dev->driver = (struct device_driver *)drv; +} + int devres_release_all(struct device *dev); void device_block_probing(void); void device_unblock_probing(void); |