• Milo Kim's avatar
    leds:lp55xx: use the private data instead of updating I2C device platform data · ed133352
    Milo Kim authored
    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 <toshik@chromium.org>
    Cc: linux-leds@vger.kernel.org
    Signed-off-by: default avatarMilo Kim <milo.kim@ti.com>
    Signed-off-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
    ed133352
leds-lp5523.c 23.9 KB