diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-05-11 17:16:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 12:50:47 -0400 |
commit | b4028437876866aba4747a655ede00f892089e14 (patch) | |
tree | f6c34315c3e6d2899a894f028bd6f9899e80cd01 /drivers/base/dd.c | |
parent | 2023c610dc54a4f4130b0494309a9bd668ca3df8 (diff) |
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 <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/dd.c')
-rw-r--r-- | drivers/base/dd.c | 31 |
1 files changed, 29 insertions, 2 deletions
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 @@ | |||
11 | * | 11 | * |
12 | * Copyright (c) 2002-5 Patrick Mochel | 12 | * Copyright (c) 2002-5 Patrick Mochel |
13 | * Copyright (c) 2002-3 Open Source Development Labs | 13 | * Copyright (c) 2002-3 Open Source Development Labs |
14 | * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> | 14 | * Copyright (c) 2007-2009 Greg Kroah-Hartman <gregkh@suse.de> |
15 | * Copyright (c) 2007 Novell Inc. | 15 | * Copyright (c) 2007-2009 Novell Inc. |
16 | * | 16 | * |
17 | * This file is released under the GPLv2 | 17 | * This file is released under the GPLv2 |
18 | */ | 18 | */ |
@@ -391,3 +391,30 @@ void driver_detach(struct device_driver *drv) | |||
391 | put_device(dev); | 391 | put_device(dev); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | |||
395 | /* | ||
396 | * These exports can't be _GPL due to .h files using this within them, and it | ||
397 | * might break something that was previously working... | ||
398 | */ | ||
399 | void *dev_get_drvdata(const struct device *dev) | ||
400 | { | ||
401 | if (dev && dev->p) | ||
402 | return dev->p->driver_data; | ||
403 | return NULL; | ||
404 | } | ||
405 | EXPORT_SYMBOL(dev_get_drvdata); | ||
406 | |||
407 | void dev_set_drvdata(struct device *dev, void *data) | ||
408 | { | ||
409 | int error; | ||
410 | |||
411 | if (!dev) | ||
412 | return; | ||
413 | if (!dev->p) { | ||
414 | error = device_private_init(dev); | ||
415 | if (error) | ||
416 | return; | ||
417 | } | ||
418 | dev->p->driver_data = data; | ||
419 | } | ||
420 | EXPORT_SYMBOL(dev_set_drvdata); | ||