File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,16 @@ config DEBUG_DEVRES
212
212
213
213
If you are unsure about this, Say N here.
214
214
215
+ config DEBUG_TEST_DRIVER_REMOVE
216
+ bool "Test driver remove calls during probe"
217
+ depends on DEBUG_KERNEL
218
+ help
219
+ Say Y here if you want the Driver core to test driver remove functions
220
+ by calling probe, remove, probe. This tests the remove path without
221
+ having to unbind the driver or unload the driver module.
222
+
223
+ If you are unsure about this, say N here.
224
+
215
225
config SYS_HYPERVISOR
216
226
bool
217
227
default n
Original file line number Diff line number Diff line change @@ -329,6 +329,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
329
329
{
330
330
int ret = - EPROBE_DEFER ;
331
331
int local_trigger_count = atomic_read (& deferred_trigger_count );
332
+ bool test_remove = IS_ENABLED (CONFIG_DEBUG_TEST_DRIVER_REMOVE );
332
333
333
334
if (defer_all_probes ) {
334
335
/*
@@ -346,6 +347,7 @@ static int really_probe(struct device *dev, struct device_driver *drv)
346
347
drv -> bus -> name , __func__ , drv -> name , dev_name (dev ));
347
348
WARN_ON (!list_empty (& dev -> devres_head ));
348
349
350
+ re_probe :
349
351
dev -> driver = drv ;
350
352
351
353
/* If using pinctrl, bind pins now before probing */
@@ -383,6 +385,25 @@ static int really_probe(struct device *dev, struct device_driver *drv)
383
385
goto probe_failed ;
384
386
}
385
387
388
+ if (test_remove ) {
389
+ test_remove = false;
390
+
391
+ if (dev -> bus && dev -> bus -> remove )
392
+ dev -> bus -> remove (dev );
393
+ else if (drv -> remove )
394
+ drv -> remove (dev );
395
+
396
+ devres_release_all (dev );
397
+ driver_sysfs_remove (dev );
398
+ dev -> driver = NULL ;
399
+ dev_set_drvdata (dev , NULL );
400
+ if (dev -> pm_domain && dev -> pm_domain -> dismiss )
401
+ dev -> pm_domain -> dismiss (dev );
402
+ pm_runtime_reinit (dev );
403
+
404
+ goto re_probe ;
405
+ }
406
+
386
407
pinctrl_init_done (dev );
387
408
388
409
if (dev -> pm_domain && dev -> pm_domain -> sync )
You can’t perform that action at this time.
0 commit comments