On 08/24/2015 09:09 AM, Milo Kim wrote:
Currently, lp55xx_of_populate_pdata() allocates lp55xx_platform_data if
it's null. And it parses the DT and copies values into the
'client->dev.platform_data'. This may have architectural issue.
Platform data is configurable through the DT or I2C board info inside the
platform area. However, lp55xx common driver changes this configuration
when it is loaded. So 'client->dev.platform_data' is not null anymore.
Eventually, the driver initialization is not identical when it's unloaded
and loaded again.
The lp55xx common driver should use the private data, 'lp55xx_chip->pdata'
instead of changing the original platform data.

So, lp55xx_of_populate_pdata() is modified as follows.
* Do not update 'dev->platform_data'. Return the pointer of new allocated
    lp55xx_platform_data. Then the driver points it to private data,
    'lp55xx_chip->pdata'.
* Each lp55xx driver checks the pointer and handles an error case.

Then, original platform data configuration will be kept regardless of
loading or unloading the driver.
The driver allocates the memory and copies them from the DT if it's NULL.
After the driver is loaded again, 'client->dev.platform_data' is same as
initial load, so the driver is initialized identically.

Cc: Toshi Kikuchi <[email protected]>
Cc: [email protected]
Signed-off-by: Milo Kim <[email protected]>
---
  drivers/leds/leds-lp5521.c        | 11 +++++------
  drivers/leds/leds-lp5523.c        | 11 +++++------
  drivers/leds/leds-lp5562.c        | 11 +++++------
  drivers/leds/leds-lp55xx-common.c | 13 ++++++-------
  drivers/leds/leds-lp55xx-common.h |  4 ++--
  drivers/leds/leds-lp8501.c        | 11 +++++------
  6 files changed, 28 insertions(+), 33 deletions(-)

Merged, thanks.

--
Best Regards,
Jacek Anaszewski
--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to