Re: [PATCH 1/4] MMC: omap_hsmmc: set platform data after probe from DT node

Daniel Mack
2012-10-13T08:05:52Z

Hi Grant,

On 13.10.2012 02:05, Grant Likely wrote:
>
>
> Balaji T K <balajitk@ti.com> wrote:
>
>> On Friday 12 October 2012 08:44 PM, Daniel Mack wrote:
>>> On 12.10.2012 16:56, Balaji T K wrote:
>>>> On Friday 12 October 2012 07:59 PM, Daniel Mack wrote:
>>>>> On 12.10.2012 12:58, Daniel Mack wrote:
>>>>>> diff --git a/drivers/mmc/host/omap_hsmmc.c
>> b/drivers/mmc/host/omap_hsmmc.c
>>>>>> index 19ccb59..4b70823 100644 ---
>>>>>> a/drivers/mmc/host/omap_hsmmc.c +++
>>>>>> b/drivers/mmc/host/omap_hsmmc.c @@ -1728,6 +1728,7 @@
>>>>>> static int __devinit omap_hsmmc_probe(struct
>> platform_device *pdev)
>>>>>> const u16 *offsetp = match->data; pdata->reg_offset =
>>>>>> *offsetp; } + pdev->dev.platform_data = pdata; }
>>>>>>
>>>>>> if (pdata == NULL) {
>>>>>>
>>>>>
>>>>> FWIW, this is the Oops I see without this patch:
>>>> Hi, Shouldn't pdev->dev.platform_data be set to NULL on _remove
>>>> ?
>>>
>>> Why?
>>
>> To make sure on second insmod it is NULL, When built as module, So
>> that of_get_hsmmc_pdata is called to create pdata.
>
> Actually the driver should *never* modify the value of
> dev->platform_data. Ever.

That's interesting, because many drivers do this, especially since they
were converted to DT probing. Mostly because that way, the platform data
logic in callback functions can be reused, and often the platform
specific data is only stored in pdata and taken from there during the
lifetime of a device.

Is there any particular reason why this approach is frowned upon?

> Make a copy instead.

A copy of what exactly? Of all members of the legacy pdata you mean?

Thanks,
Daniel