Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 030cf688 authored by Venkata Rao Kakani's avatar Venkata Rao Kakani Committed by Gerrit - the friendly Code Review server
Browse files

driver-core: remove lock for platform devices during probe



During driver probe procedure, lock on the parent of
platform devices could be removed to make probe in parallel.

Change-Id: I5457869e056a55b51dd91937d6202947b13977eb
Signed-off-by: default avatarvkakani <vkakani@codeaurora.org>
Signed-off-by: default avatarWei Li <weili@codeaurora.org>
parent c7a3fb0e
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -404,7 +404,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
		   -Wno-format-security \
		   -Wno-format-security \
		   -std=gnu89 $(call cc-option,-fno-PIE)
		   -std=gnu89 $(call cc-option,-fno-PIE)



ifeq ($(TARGET_BOARD_TYPE),auto)
KBUILD_CFLAGS    += -DCONFIG_PLATFORM_AUTO
endif
KBUILD_AFLAGS_KERNEL :=
KBUILD_AFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS   := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
KBUILD_AFLAGS   := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
+17 −3
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@
#include <linux/async.h>
#include <linux/async.h>
#include <linux/pm_runtime.h>
#include <linux/pm_runtime.h>
#include <linux/pinctrl/devinfo.h>
#include <linux/pinctrl/devinfo.h>
#include <linux/platform_device.h>


#include "base.h"
#include "base.h"
#include "power/power.h"
#include "power/power.h"
@@ -642,6 +643,20 @@ void device_initial_probe(struct device *dev)
{
{
	__device_attach(dev, true);
	__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)
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))
	if (!driver_match_device(drv, dev))
		return 0;
		return 0;

	if (lock_parent(dev))
	if (dev->parent)	/* Needed for USB */
		device_lock(dev->parent);
		device_lock(dev->parent);
	device_lock(dev);
	device_lock(dev);
	if (!dev->driver)
	if (!dev->driver)
		driver_probe_device(drv, dev);
		driver_probe_device(drv, dev);
	device_unlock(dev);
	device_unlock(dev);
	if (dev->parent)
	if (lock_parent(dev))
		device_unlock(dev->parent);
		device_unlock(dev->parent);


	return 0;
	return 0;