Skip to content

Commit c6c631d

Browse files
committed
driver core: mark async_driver as a const *
Within struct device_private, mark the async_driver * as const as it is never modified. This requires some internal-to-the-driver-core functions to also have their parameters marked as constant, and there is one place where we cast _back_ from the const pointer to a real one, as the driver core still wants to modify the structure in a number of remaining places. Cc: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f6e98ef commit c6c631d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

drivers/base/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct device_private {
112112
struct klist_node knode_bus;
113113
struct klist_node knode_class;
114114
struct list_head deferred_probe;
115-
struct device_driver *async_driver;
115+
const struct device_driver *async_driver;
116116
char *deferred_probe_reason;
117117
struct device *device;
118118
u8 dead:1;

drivers/base/dd.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ static void device_remove(struct device *dev)
568568
dev->driver->remove(dev);
569569
}
570570

571-
static int call_driver_probe(struct device *dev, struct device_driver *drv)
571+
static int call_driver_probe(struct device *dev, const struct device_driver *drv)
572572
{
573573
int ret = 0;
574574

@@ -599,7 +599,7 @@ static int call_driver_probe(struct device *dev, struct device_driver *drv)
599599
return ret;
600600
}
601601

602-
static int really_probe(struct device *dev, struct device_driver *drv)
602+
static int really_probe(struct device *dev, const struct device_driver *drv)
603603
{
604604
bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&
605605
!drv->suppress_bind_attrs;
@@ -628,7 +628,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
628628
}
629629

630630
re_probe:
631-
dev->driver = drv;
631+
// FIXME - this cast should not be needed "soon"
632+
dev->driver = (struct device_driver *)drv;
632633

633634
/* If using pinctrl, bind pins now before probing */
634635
ret = pinctrl_bind_pins(dev);
@@ -727,7 +728,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
727728
/*
728729
* For initcall_debug, show the driver probe time.
729730
*/
730-
static int really_probe_debug(struct device *dev, struct device_driver *drv)
731+
static int really_probe_debug(struct device *dev, const struct device_driver *drv)
731732
{
732733
ktime_t calltime, rettime;
733734
int ret;
@@ -774,7 +775,7 @@ void wait_for_device_probe(void)
774775
}
775776
EXPORT_SYMBOL_GPL(wait_for_device_probe);
776777

777-
static int __driver_probe_device(struct device_driver *drv, struct device *dev)
778+
static int __driver_probe_device(const struct device_driver *drv, struct device *dev)
778779
{
779780
int ret = 0;
780781

@@ -819,7 +820,7 @@ static int __driver_probe_device(struct device_driver *drv, struct device *dev)
819820
*
820821
* If the device has a parent, runtime-resume the parent before driver probing.
821822
*/
822-
static int driver_probe_device(struct device_driver *drv, struct device *dev)
823+
static int driver_probe_device(const struct device_driver *drv, struct device *dev)
823824
{
824825
int trigger_count = atomic_read(&deferred_trigger_count);
825826
int ret;
@@ -1137,7 +1138,7 @@ EXPORT_SYMBOL_GPL(device_driver_attach);
11371138
static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie)
11381139
{
11391140
struct device *dev = _dev;
1140-
struct device_driver *drv;
1141+
const struct device_driver *drv;
11411142
int ret;
11421143

11431144
__device_driver_lock(dev, dev->parent);

0 commit comments

Comments
 (0)