From b4028437876866aba4747a655ede00f892089e14 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 11 May 2009 14:16:57 -0700 Subject: Driver core: move dev_get/set_drvdata to drivers/base/dd.c No one should directly access the driver_data field, so remove the field and make it private. We dynamically create the private field now if it is needed, to handle drivers that call get/set before they are registered with the driver core. Also update the copyright notices on these files while we are there. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'drivers/base/dd.c') diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 7b34b3a48f67..979d159b5cd1 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -11,8 +11,8 @@ * * Copyright (c) 2002-5 Patrick Mochel * Copyright (c) 2002-3 Open Source Development Labs - * Copyright (c) 2007 Greg Kroah-Hartman - * Copyright (c) 2007 Novell Inc. + * Copyright (c) 2007-2009 Greg Kroah-Hartman + * Copyright (c) 2007-2009 Novell Inc. * * This file is released under the GPLv2 */ @@ -391,3 +391,30 @@ 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) +{ + if (dev && dev->p) + return dev->p->driver_data; + return NULL; +} +EXPORT_SYMBOL(dev_get_drvdata); + +void dev_set_drvdata(struct device *dev, void *data) +{ + int error; + + if (!dev) + return; + if (!dev->p) { + error = device_private_init(dev); + if (error) + return; + } + dev->p->driver_data = data; +} +EXPORT_SYMBOL(dev_set_drvdata); -- cgit v1.2.3