|
| 1 | +driver core: introduce device_set_driver() helper |
| 2 | + |
| 3 | +jira LE-3587 |
| 4 | +Rebuild_History Non-Buildable kernel-4.18.0-553.62.1.el8_10 |
| 5 | +commit-author Dmitry Torokhov < [email protected]> |
| 6 | +commit 04d3e5461c1f5cf8eec964ab64948ebed826e95e |
| 7 | +Empty-Commit: Cherry-Pick Conflicts during history rebuild. |
| 8 | +Will be included in final tarball splat. Ref for failed cherry-pick at: |
| 9 | +ciq/ciq_backports/kernel-4.18.0-553.62.1.el8_10/04d3e546.failed |
| 10 | + |
| 11 | +In preparation to closing a race when reading driver pointer in |
| 12 | +dev_uevent() code, instead of setting device->driver pointer directly |
| 13 | +introduce device_set_driver() helper. |
| 14 | + |
| 15 | + Signed-off-by: Dmitry Torokhov < [email protected]> |
| 16 | + Reviewed-by: Masami Hiramatsu (Google) < [email protected]> |
| 17 | +Link: https://lore.kernel.org/r/ [email protected] |
| 18 | + Signed-off-by: Greg Kroah-Hartman < [email protected]> |
| 19 | +(cherry picked from commit 04d3e5461c1f5cf8eec964ab64948ebed826e95e) |
| 20 | + Signed-off-by: Jonathan Maple < [email protected]> |
| 21 | + |
| 22 | +# Conflicts: |
| 23 | +# drivers/base/base.h |
| 24 | +# drivers/base/dd.c |
| 25 | +diff --cc drivers/base/base.h |
| 26 | +index f1ca94ed4ea3,eb203cf8370b..000000000000 |
| 27 | +--- a/drivers/base/base.h |
| 28 | ++++ b/drivers/base/base.h |
| 29 | +@@@ -161,19 -176,23 +161,33 @@@ static inline void dev_sync_state(struc |
| 30 | + dev->driver->sync_state(dev); |
| 31 | + } |
| 32 | + |
| 33 | + -int driver_add_groups(const struct device_driver *drv, const struct attribute_group **groups); |
| 34 | + -void driver_remove_groups(const struct device_driver *drv, const struct attribute_group **groups); |
| 35 | + +extern int driver_add_groups(struct device_driver *drv, |
| 36 | + + const struct attribute_group **groups); |
| 37 | + +extern void driver_remove_groups(struct device_driver *drv, |
| 38 | + + const struct attribute_group **groups); |
| 39 | + void device_driver_detach(struct device *dev); |
| 40 | + |
| 41 | +++<<<<<<< HEAD |
| 42 | + +extern int devres_release_all(struct device *dev); |
| 43 | + +extern void device_block_probing(void); |
| 44 | + +extern void device_unblock_probing(void); |
| 45 | +++======= |
| 46 | ++ static inline void device_set_driver(struct device *dev, const struct device_driver *drv) |
| 47 | ++ { |
| 48 | ++ // FIXME - this cast should not be needed "soon" |
| 49 | ++ dev->driver = (struct device_driver *)drv; |
| 50 | ++ } |
| 51 | ++ |
| 52 | ++ int devres_release_all(struct device *dev); |
| 53 | ++ void device_block_probing(void); |
| 54 | ++ void device_unblock_probing(void); |
| 55 | ++ void deferred_probe_extend_timeout(void); |
| 56 | ++ void driver_deferred_probe_trigger(void); |
| 57 | +++>>>>>>> 04d3e5461c1f (driver core: introduce device_set_driver() helper) |
| 58 | + const char *device_get_devnode(const struct device *dev, umode_t *mode, |
| 59 | + kuid_t *uid, kgid_t *gid, const char **tmp); |
| 60 | + +extern void deferred_probe_extend_timeout(void); |
| 61 | + +extern void driver_deferred_probe_trigger(void); |
| 62 | + |
| 63 | + /* /sys/devices directory */ |
| 64 | + extern struct kset *devices_kset; |
| 65 | +diff --cc drivers/base/dd.c |
| 66 | +index 9c5db2007422,b526e0e0f52d..000000000000 |
| 67 | +--- a/drivers/base/dd.c |
| 68 | ++++ b/drivers/base/dd.c |
| 69 | +@@@ -648,12 -620,16 +648,16 @@@ static int really_probe(struct device * |
| 70 | + if (link_ret == -EPROBE_DEFER) |
| 71 | + return link_ret; |
| 72 | + |
| 73 | + - dev_dbg(dev, "bus: '%s': %s: probing driver %s with device\n", |
| 74 | + - drv->bus->name, __func__, drv->name); |
| 75 | + - if (!list_empty(&dev->devres_head)) { |
| 76 | + - dev_crit(dev, "Resources present before probing\n"); |
| 77 | + - ret = -EBUSY; |
| 78 | + - goto done; |
| 79 | + - } |
| 80 | + + pr_debug("bus: '%s': %s: probing driver %s with device %s\n", |
| 81 | + + drv->bus->name, __func__, drv->name, dev_name(dev)); |
| 82 | + + WARN_ON(!list_empty(&dev->devres_head)); |
| 83 | + |
| 84 | + re_probe: |
| 85 | +++<<<<<<< HEAD |
| 86 | + + dev->driver = drv; |
| 87 | +++======= |
| 88 | ++ device_set_driver(dev, drv); |
| 89 | +++>>>>>>> 04d3e5461c1f (driver core: introduce device_set_driver() helper) |
| 90 | + |
| 91 | + /* If using pinctrl, bind pins now before probing */ |
| 92 | + ret = pinctrl_bind_pins(dev); |
| 93 | +* Unmerged path drivers/base/base.h |
| 94 | +diff --git a/drivers/base/core.c b/drivers/base/core.c |
| 95 | +index 85168dc6be18..2e041155b2da 100644 |
| 96 | +--- a/drivers/base/core.c |
| 97 | ++++ b/drivers/base/core.c |
| 98 | +@@ -3603,7 +3603,7 @@ int device_add(struct device *dev) |
| 99 | + device_pm_remove(dev); |
| 100 | + dpm_sysfs_remove(dev); |
| 101 | + DPMError: |
| 102 | +- dev->driver = NULL; |
| 103 | ++ device_set_driver(dev, NULL); |
| 104 | + bus_remove_device(dev); |
| 105 | + BusError: |
| 106 | + device_remove_attrs(dev); |
| 107 | +* Unmerged path drivers/base/dd.c |
0 commit comments