diff --git a/Makefile b/Makefile index ea532bf51579..609770fc3666 100644 --- a/Makefile +++ b/Makefile @@ -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 #include #include +#include #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;