On 10 September 2014 17:58, Thomas Petazzoni thomas.petazzoni@free-electrons.com wrote:
Dear Viresh Kumar,
On Wed, 10 Sep 2014 17:52:59 +0530, Viresh Kumar wrote:
On 10 September 2014 17:38, Thomas Petazzoni thomas.petazzoni@free-electrons.com wrote:
dt_cpufreq_driver.driver_data = dev_get_platdata(&pdev->dev);
I don't think this is right. What if platform device's platform data is freed later? That's why its always better to duplicate that structure instead of playing with pointers.
Isn't the piece of code registering the platform_device supposed to make sure that platform_data doesn't disappear? At least, in PATCH 3/4,
I don't know. I remember this from the days when I used to write individual drivers for SPEAr platform... Its been some time now that I have seen this :)
I'm using platform_device_register_data(), which does a kmemdup() of the custom data being passed before assigning the struct device->platform_data field.
Atleast in your case it isn't required to copy anymore but this driver can be used by others which may not guarantee that..
But if you like, I can add one more memory copy :)
Its not what I like, as wasting memory isn't sensible at all.. But about what's the right thing to do to make this code un-breakable..
@Arnd: Any inputs?