Driver core: move dev_get/set_drvdata to drivers/base/dd.c
PATCH 1/1 Driver core: move dev_get/set_drvdata to drivers/base/dd.c
In my driver-core tree, I've cleaned up all direct accesses of the driver_data field in struct device. So here's a final patch I've also added that renames the field so that no one uses it again in the future. It will show up in linux-next tomorrow.
thanks,
greg k-h
----------------------
No one should directly access the driver_data field, so change the variable to hopefully state this. Then move the get/set functions into dd.c so that we can properly handle the changes that will be needed to these functions in the future when we add the multiple device/driver logic to the driver core.
Also update the copyright notices on these files while we are there.
Signed-off-by Greg Kroah-Hartman <[email protected]>
--- drivers/base/dd.c | 20 ++++++++++++++++++-- include/linux/device.h | 20 ++++++++------------ 2 files changed, 26 insertions(+), 14 deletions(-)
drivers/base/dd.c +18 -2
@@ -11,8 +11,8 @@* * Copyright (c) 2002-5 Patrick Mochel * Copyright (c) 2002-3 Open Source Development Labs -* Copyright (c) 2007 Greg Kroah-Hartman <[email protected]> -* Copyright (c) 2007 Novell Inc. +* Copyright (c) 2007-2009 Greg Kroah-Hartman <[email protected]> +* Copyright (c) 2007-2009 Novell Inc. * * This file is released under the GPLv2 */
@@ -380,3 +380,19 @@ void driver_detach(struct device_driverput_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->dd_DO_NOT_USE; +} +EXPORT_SYMBOL (dev_get_drvdata); + +void dev_set_drvdata (struct device *dev,void *data) +{ + dev->dd_DO_NOT_USE = data; +} +EXPORT_SYMBOL (dev_set_drvdata);
include/linux/device.h +8 -12
@@ -2,7 +2,8 @@* device.h - generic, centralized driver model * * Copyright (c) 2001-2003 Patrick Mochel <[email protected]> -* Copyright (c) 2004-2007 Greg Kroah-Hartman <[email protected]> +* Copyright (c) 2004-2009 Greg Kroah-Hartman <[email protected]> +* Copyright (c) 2008-2009 Novell Inc. * * This file is released under the GPLv2 *
@@ -387,7 +388,10 @@ struct device {struct bus_type *bus;/* type of bus device is on */ struct device_driver *driver;/* which driver has allocated this device */ -void *driver_data;/* data private to the driver */ +void *dd_DO_NOT_USE;/* data private to the driver, do +* not directly touch this field, +* use the dev_get/set_drvdata() +* functions instead. */ void *platform_data;/* Platform specific data, device core doesn't touch it */ struct dev_pm_info power;
@@ -453,16 +457,6 @@ static inline void set_dev_node(struct d }#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 unsigned int dev_get_uevent_suppress (const struct device *dev) {return dev->kobj.uevent_suppress;
@@ -496,6 +490,8 @@ extern int device_rename(struct device *extern int device_move (struct device *dev,struct device *new_parent,enum dpm_order dpm_order);extern const char *device_get_nodename (struct device *dev,const char **tmp); +extern void *dev_get_drvdata (const struct device *dev); +extern void dev_set_drvdata (struct device *dev,void *data);/* * Root device objects for grouping under /sys/devices