From 86d56134f1b67d0c18025ba5cade95c048ed528d Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Thu, 10 Apr 2014 14:09:31 -0700 Subject: kobject: Make support for uevent_helper optional. Support for uevent_helper, aka hotplug, is not required on many systems these days but it can still be enabled via sysfs or sysctl. Reported-by: Darren Shepherd Signed-off-by: Michael Marineau Signed-off-by: Greg Kroah-Hartman --- drivers/base/Kconfig | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 8fa8deab6449..4b7b4522b64f 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -1,10 +1,10 @@ menu "Generic Driver Options" -config UEVENT_HELPER_PATH - string "path to uevent helper" - default "" +config UEVENT_HELPER + bool "Support for uevent helper" + default y help - Path to uevent helper program forked by the kernel for + The uevent helper program is forked by the kernel for every uevent. Before the switch to the netlink-based uevent source, this was used to hook hotplug scripts into kernel device events. It @@ -15,8 +15,13 @@ config UEVENT_HELPER_PATH that it creates a high system load, or on smaller systems it is known to create out-of-memory situations during bootup. - To disable user space helper program execution at early boot - time specify an empty string here. This setting can be altered +config UEVENT_HELPER_PATH + string "path to uevent helper" + depends on UEVENT_HELPER + default "" + help + To disable user space helper program execution at by default + specify an empty string here. This setting can still be altered via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper later at runtime. -- cgit v1.2.3 From 1bb6c08abfb653ce6e65d8ab4ddef403227afedf Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 14 Apr 2014 12:54:47 +0200 Subject: driver core: Move driver_data back to struct device Having to allocate memory as part of dev_set_drvdata() is a problem because that memory may never get freed if the device itself is not created. So move driver_data back to struct device. This is a partial revert of commit b4028437. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/base/base.h | 3 --- drivers/base/dd.c | 13 +++---------- include/linux/device.h | 3 +++ 3 files changed, 6 insertions(+), 13 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/base.h b/drivers/base/base.h index 24f424249d9b..251c5d30f963 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -63,8 +63,6 @@ struct driver_private { * binding of drivers which were unable to get all the resources needed by * the device; typically because it depends on another driver getting * probed first. - * @driver_data - private pointer for driver specific info. Will turn into a - * list soon. * @device - pointer back to the struct class that this structure is * associated with. * @@ -76,7 +74,6 @@ struct device_private { struct klist_node knode_driver; struct klist_node knode_bus; struct list_head deferred_probe; - void *driver_data; struct device *device; }; #define to_device_private_parent(obj) \ diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 62ec61e8f84a..d14b6e895896 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -594,22 +594,15 @@ void driver_detach(struct device_driver *drv) */ void *dev_get_drvdata(const struct device *dev) { - if (dev && dev->p) - return dev->p->driver_data; + if (dev) + return dev->driver_data; return NULL; } EXPORT_SYMBOL(dev_get_drvdata); int dev_set_drvdata(struct device *dev, void *data) { - int error; - - if (!dev->p) { - error = device_private_init(dev); - if (error) - return error; - } - dev->p->driver_data = data; + dev->driver_data = data; return 0; } EXPORT_SYMBOL(dev_set_drvdata); diff --git a/include/linux/device.h b/include/linux/device.h index d1d1c055b48e..5c94ac3e7972 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -673,6 +673,7 @@ struct acpi_dev_node { * variants, which GPIO pins act in what additional roles, and so * on. This shrinks the "Board Support Packages" (BSPs) and * minimizes board-specific #ifdefs in drivers. + * @driver_data: Private pointer for driver specific info. * @power: For device power management. * See Documentation/power/devices.txt for details. * @pm_domain: Provide callbacks that are executed during system suspend, @@ -734,6 +735,8 @@ struct device { device */ void *platform_data; /* Platform specific data, device core doesn't touch it */ + void *driver_data; /* Driver data, set and get with + dev_set/get_drvdata */ struct dev_pm_info power; struct dev_pm_domain *pm_domain; -- cgit v1.2.3 From 2c1f1ff0f0d9e0df8c9b6d3697ac250900091541 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 14 Apr 2014 12:56:34 +0200 Subject: driver core: dev_set_drvdata returns void dev_set_drvdata can no longer fail, so it could return void. All callers have hopefully been updated to no longer check for the return value. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 3 +-- include/linux/device.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/dd.c b/drivers/base/dd.c index d14b6e895896..d21f4b8dc37b 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -600,9 +600,8 @@ void *dev_get_drvdata(const struct device *dev) } EXPORT_SYMBOL(dev_get_drvdata); -int dev_set_drvdata(struct device *dev, void *data) +void dev_set_drvdata(struct device *dev, void *data) { dev->driver_data = data; - return 0; } EXPORT_SYMBOL(dev_set_drvdata); diff --git a/include/linux/device.h b/include/linux/device.h index 5c94ac3e7972..6d3a75773cd4 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -911,7 +911,7 @@ extern const char *device_get_devnode(struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid, const char **tmp); extern void *dev_get_drvdata(const struct device *dev); -extern int dev_set_drvdata(struct device *dev, void *data); +extern void dev_set_drvdata(struct device *dev, void *data); static inline bool device_supports_offline(struct device *dev) { -- cgit v1.2.3 From d4332013919aa87dbdede67d677e4cf2cd32e898 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 14 Apr 2014 12:57:43 +0200 Subject: driver core: dev_get_drvdata: Don't check for NULL dev There is no point in calling dev_get_drvdata without a valid device. So checking for dev == NULL is pointless. If such a check is ever needed - which I doubt - the driver should do it before calling dev_get_drvdata. We were returning NULL if dev was NULL, which the caller certainly did not expect anyway, so that was only delaying the crash if the caller is not paying attention. Signed-off-by: Jean Delvare Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/dd.c b/drivers/base/dd.c index d21f4b8dc37b..ba03353ff243 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -594,9 +594,7 @@ void driver_detach(struct device_driver *drv) */ void *dev_get_drvdata(const struct device *dev) { - if (dev) - return dev->driver_data; - return NULL; + return dev->driver_data; } EXPORT_SYMBOL(dev_get_drvdata); -- cgit v1.2.3 From a996d010b648788b615938f6a26be6cf08d96aaf Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 14 Apr 2014 12:58:53 +0200 Subject: driver core: Inline dev_set/get_drvdata dev_set_drvdata and dev_get_drvdata are now simple enough again that we can inline them as they used to be before commit b40284378. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 16 ---------------- include/linux/device.h | 12 ++++++++++-- 2 files changed, 10 insertions(+), 18 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/dd.c b/drivers/base/dd.c index ba03353ff243..e4ffbcf2f519 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -587,19 +587,3 @@ void driver_detach(struct device_driver *drv) put_device(dev); } } - -/* - * These exports can't be _GPL due to .h files using this within them, and it - * might break something that was previously working... - */ -void *dev_get_drvdata(const struct device *dev) -{ - return dev->driver_data; -} -EXPORT_SYMBOL(dev_get_drvdata); - -void dev_set_drvdata(struct device *dev, void *data) -{ - dev->driver_data = data; -} -EXPORT_SYMBOL(dev_set_drvdata); diff --git a/include/linux/device.h b/include/linux/device.h index 6d3a75773cd4..1b18c886445c 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -826,6 +826,16 @@ static inline void set_dev_node(struct device *dev, int node) } #endif +static inline void *dev_get_drvdata(const struct device *dev) +{ + return dev->driver_data; +} + +static inline void dev_set_drvdata(struct device *dev, void *data) +{ + dev->driver_data = data; +} + static inline struct pm_subsys_data *dev_to_psd(struct device *dev) { return dev ? dev->power.subsys_data : NULL; @@ -910,8 +920,6 @@ extern int device_move(struct device *dev, struct device *new_parent, extern const char *device_get_devnode(struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid, const char **tmp); -extern void *dev_get_drvdata(const struct device *dev); -extern void dev_set_drvdata(struct device *dev, void *data); static inline bool device_supports_offline(struct device *dev) { -- cgit v1.2.3