diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2018-06-27 01:07:27 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-06-27 01:07:27 -0700 |
| commit | e130a419a73ab080f845d1ffcc8b3e63d6738535 (patch) | |
| tree | 22e361e89e34b2cd0a1218726db1f1525377ad66 | |
| parent | a0209303bb669a263fa7650a1de9d61d3e1ca7f3 (diff) | |
| parent | 030cf6885022647656be6fe53e86dd320a6a6d51 (diff) | |
Merge "driver-core: remove lock for platform devices during probe"
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | drivers/base/dd.c | 20 |
2 files changed, 20 insertions, 4 deletions
@@ -404,7 +404,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -Wno-format-security \ -std=gnu89 $(call cc-option,-fno-PIE) - +ifeq ($(TARGET_BOARD_TYPE),auto) +KBUILD_CFLAGS += -DCONFIG_PLATFORM_AUTO +endif KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 0dd6379ac215..7e00d10d5a94 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -25,6 +25,7 @@ #include <linux/async.h> #include <linux/pm_runtime.h> #include <linux/pinctrl/devinfo.h> +#include <linux/platform_device.h> #include "base.h" #include "power/power.h" @@ -642,6 +643,20 @@ void device_initial_probe(struct device *dev) { __device_attach(dev, true); } +#ifdef CONFIG_PLATFORM_AUTO +static inline int lock_parent(struct device *dev) +{ + if (!dev->parent || dev->bus == &platform_bus_type) + return 0; + + return 1; +} +#else +static inline int lock_parent(struct device *dev) +{ + return dev->parent ? 1 : 0; +} +#endif static int __driver_attach(struct device *dev, void *data) { @@ -659,14 +674,13 @@ static int __driver_attach(struct device *dev, void *data) if (!driver_match_device(drv, dev)) return 0; - - if (dev->parent) /* Needed for USB */ + if (lock_parent(dev)) device_lock(dev->parent); device_lock(dev); if (!dev->driver) driver_probe_device(drv, dev); device_unlock(dev); - if (dev->parent) + if (lock_parent(dev)) device_unlock(dev->parent); return 0; |
