aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-05-11 17:16:57 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 12:50:47 -0400
commitb4028437876866aba4747a655ede00f892089e14 (patch)
treef6c34315c3e6d2899a894f028bd6f9899e80cd01 /drivers/base/core.c
parent2023c610dc54a4f4130b0494309a9bd668ca3df8 (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/core.c')
-rw-r--r--drivers/base/core.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index c34774d0b9d3..99dfe96fffcb 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -843,6 +843,17 @@ static void device_remove_sys_dev_entry(struct device *dev)
843 } 843 }
844} 844}
845 845
846int device_private_init(struct device *dev)
847{
848 dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL);
849 if (!dev->p)
850 return -ENOMEM;
851 dev->p->device = dev;
852 klist_init(&dev->p->klist_children, klist_children_get,
853 klist_children_put);
854 return 0;
855}
856
846/** 857/**
847 * device_add - add device to device hierarchy. 858 * device_add - add device to device hierarchy.
848 * @dev: device. 859 * @dev: device.
@@ -868,14 +879,11 @@ int device_add(struct device *dev)
868 if (!dev) 879 if (!dev)
869 goto done; 880 goto done;
870 881
871 dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL);
872 if (!dev->p) { 882 if (!dev->p) {
873 error = -ENOMEM; 883 error = device_private_init(dev);
874 goto done; 884 if (error)
885 goto done;
875 } 886 }
876 dev->p->device = dev;
877 klist_init(&dev->p->klist_children, klist_children_get,
878 klist_children_put);
879 887
880 /* 888 /*
881 * for statically allocated devices, which should all be converted 889 * for statically allocated devices, which should all be converted