mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
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>
This commit is contained in:
parent
bda80da469
commit
7096d04221
5 changed files with 32 additions and 44 deletions
|
@ -27,20 +27,19 @@ static inline int of_driver_match_device(const struct device *dev,
|
|||
extern struct platform_device *of_dev_get(struct platform_device *dev);
|
||||
extern void of_dev_put(struct platform_device *dev);
|
||||
|
||||
extern int of_device_add(struct platform_device *pdev);
|
||||
extern int of_device_register(struct platform_device *ofdev);
|
||||
extern void of_device_unregister(struct platform_device *ofdev);
|
||||
extern void of_release_dev(struct device *dev);
|
||||
|
||||
static inline void of_device_free(struct platform_device *dev)
|
||||
{
|
||||
of_release_dev(&dev->dev);
|
||||
}
|
||||
|
||||
extern ssize_t of_device_get_modalias(struct device *dev,
|
||||
char *str, ssize_t len);
|
||||
|
||||
extern int of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
|
||||
|
||||
static inline void of_device_node_put(struct device *dev)
|
||||
{
|
||||
of_node_put(dev->of_node);
|
||||
}
|
||||
|
||||
#else /* CONFIG_OF_DEVICE */
|
||||
|
||||
|
@ -56,6 +55,8 @@ static inline int of_device_uevent(struct device *dev,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
static inline void of_device_node_put(struct device *dev) { }
|
||||
|
||||
#endif /* CONFIG_OF_DEVICE */
|
||||
|
||||
#endif /* _LINUX_OF_DEVICE_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue