[RFC] device.h: add device_set_platdata routine
From: Uwe Kleine-König <hidden>
Date: 2011-03-01 09:05:29
Also in:
lkml
Hi Viresh,
quoted
On Tue, Mar 01, 2011 at 10:03:20AM +0530, Viresh Kumar wrote:quoted
device.h supports device_get_platdata but doesn't support device_set_platdata. This routine is required by platforms in which device structure is declared in a machine specific file and platform data comes from board specific file. This will be used by SPEAr patches sent in separate patch series. Signed-off-by: Viresh Kumar <redacted> --- include/linux/device.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)diff --git a/include/linux/device.h b/include/linux/device.h index 1bf5cf0..6ce0f20 100644 --- a/include/linux/device.h +++ b/include/linux/device.h@@ -576,6 +576,11 @@ static inline void *dev_get_platdata(const struct device *dev) return dev->platform_data; } +static inline void dev_set_platdata(struct device *dev, void *platdata) +{ + dev->platform_data = platdata; +} +Note that dev->platform_data was designed to hold dynamically allocated memory, at least it's kfreed in platform_device_release. And note there is platform_device_add_data that kmemdups its argument into pdev->dev.platform_data.Ok. So we should use platform_device_add_data instead and mark our platform data's struct as __init. So that it doesn't consume any memory after this routine is done??
Yeah, either __initdata or still better const + __initconst if possible. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |