--- zzzz-none-000/linux-3.10.107/drivers/leds/leds-lp5562.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/leds/leds-lp5562.c 2021-02-04 17:41:59.000000000 +0000 @@ -13,10 +13,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -346,9 +346,9 @@ /* check the size of program count */ static inline bool _is_pc_overflow(struct lp55xx_predef_pattern *ptn) { - return (ptn->size_r >= LP5562_PROGRAM_LENGTH || - ptn->size_g >= LP5562_PROGRAM_LENGTH || - ptn->size_b >= LP5562_PROGRAM_LENGTH); + return ptn->size_r >= LP5562_PROGRAM_LENGTH || + ptn->size_g >= LP5562_PROGRAM_LENGTH || + ptn->size_b >= LP5562_PROGRAM_LENGTH; } static int lp5562_run_predef_led_pattern(struct lp55xx_chip *chip, int mode) @@ -477,8 +477,8 @@ return len; } -static DEVICE_ATTR(led_pattern, S_IWUSR, NULL, lp5562_store_pattern); -static DEVICE_ATTR(engine_mux, S_IWUSR, NULL, lp5562_store_engine_mux); +static LP55XX_DEV_ATTR_WO(led_pattern, lp5562_store_pattern); +static LP55XX_DEV_ATTR_WO(engine_mux, lp5562_store_engine_mux); static struct attribute *lp5562_attributes[] = { &dev_attr_led_pattern.attr, @@ -515,11 +515,18 @@ int ret; struct lp55xx_chip *chip; struct lp55xx_led *led; - struct lp55xx_platform_data *pdata = client->dev.platform_data; + struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); + struct device_node *np = client->dev.of_node; if (!pdata) { - dev_err(&client->dev, "no platform data\n"); - return -EINVAL; + if (np) { + pdata = lp55xx_of_populate_pdata(&client->dev, np); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + } else { + dev_err(&client->dev, "no platform data\n"); + return -EINVAL; + } } chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); @@ -583,9 +590,19 @@ }; MODULE_DEVICE_TABLE(i2c, lp5562_id); +#ifdef CONFIG_OF +static const struct of_device_id of_lp5562_leds_match[] = { + { .compatible = "ti,lp5562", }, + {}, +}; + +MODULE_DEVICE_TABLE(of, of_lp5562_leds_match); +#endif + static struct i2c_driver lp5562_driver = { .driver = { .name = "lp5562", + .of_match_table = of_match_ptr(of_lp5562_leds_match), }, .probe = lp5562_probe, .remove = lp5562_remove,