diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-10-20 13:45:13 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-10-21 13:10:10 -0400 |
commit | 7096d0422153ffcc2264eef652fc3a7bca3e6d3c (patch) | |
tree | 2be6139f1e26acb4d0680e50a87623bc18938147 /include/linux/of_device.h | |
parent | bda80da469a93122121de601dd469ce1aaa6effa (diff) |
of/device: Rework to use common platform_device_alloc() for allocating devices
The current code allocates and manages platform_devices created from
the device tree manually. It also uses an unsafe shortcut for
allocating the platform_device and the resource table at the same
time. (which I added in the last rework; sorry).
This patch refactors the code to use platform_device_alloc() for
allocating new devices. This reduces the amount of custom code
implemented by of_platform, eliminates the unsafe alloc trick, and has
the side benefit of letting the platform_bus code manage freeing the
device data and resources when the device is freed.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'include/linux/of_device.h')
-rw-r--r-- | include/linux/of_device.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/include/linux/of_device.h b/include/linux/of_device.h index 835f85ecd2de..975d347079d9 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h | |||
@@ -27,20 +27,19 @@ static inline int of_driver_match_device(const struct device *dev, | |||
27 | extern struct platform_device *of_dev_get(struct platform_device *dev); | 27 | extern struct platform_device *of_dev_get(struct platform_device *dev); |
28 | extern void of_dev_put(struct platform_device *dev); | 28 | extern void of_dev_put(struct platform_device *dev); |
29 | 29 | ||
30 | extern int of_device_add(struct platform_device *pdev); | ||
30 | extern int of_device_register(struct platform_device *ofdev); | 31 | extern int of_device_register(struct platform_device *ofdev); |
31 | extern void of_device_unregister(struct platform_device *ofdev); | 32 | extern void of_device_unregister(struct platform_device *ofdev); |
32 | extern void of_release_dev(struct device *dev); | ||
33 | |||
34 | static inline void of_device_free(struct platform_device *dev) | ||
35 | { | ||
36 | of_release_dev(&dev->dev); | ||
37 | } | ||
38 | 33 | ||
39 | extern ssize_t of_device_get_modalias(struct device *dev, | 34 | extern ssize_t of_device_get_modalias(struct device *dev, |
40 | char *str, ssize_t len); | 35 | char *str, ssize_t len); |
41 | 36 | ||
42 | extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env); | 37 | extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env); |
43 | 38 | ||
39 | static inline void of_device_node_put(struct device *dev) | ||
40 | { | ||
41 | of_node_put(dev->of_node); | ||
42 | } | ||
44 | 43 | ||
45 | #else /* CONFIG_OF_DEVICE */ | 44 | #else /* CONFIG_OF_DEVICE */ |
46 | 45 | ||
@@ -56,6 +55,8 @@ static inline int of_device_uevent(struct device *dev, | |||
56 | return -ENODEV; | 55 | return -ENODEV; |
57 | } | 56 | } |
58 | 57 | ||
58 | static inline void of_device_node_put(struct device *dev) { } | ||
59 | |||
59 | #endif /* CONFIG_OF_DEVICE */ | 60 | #endif /* CONFIG_OF_DEVICE */ |
60 | 61 | ||
61 | #endif /* _LINUX_OF_DEVICE_H */ | 62 | #endif /* _LINUX_OF_DEVICE_H */ |