Message ID | 20220802212549.7184-1-andriy.shevchenko@linux.intel.com |
---|---|
State | Superseded |
Headers | show |
Series | [v1,1/1] leds: bcm6328: Get rid of custom led_init_default_state_get() | expand |
Hi Andy, I love your patch! Yet something to improve: [auto build test ERROR on pavel-leds/for-next] [also build test ERROR on linus/master v5.19 next-20220802] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/leds-bcm6328-Get-rid-of-custom-led_init_default_state_get/20220803-052959 base: git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next config: openrisc-randconfig-r035-20220801 (https://download.01.org/0day-ci/archive/20220803/202208032042.E6WmErcY-lkp@intel.com/config) compiler: or1k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/514383e5dd28e25f812c88b0454a02d59e4d205c git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/leds-bcm6328-Get-rid-of-custom-led_init_default_state_get/20220803-052959 git checkout 514383e5dd28e25f812c88b0454a02d59e4d205c # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=openrisc SHELL=/bin/bash drivers/leds/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/leds/leds-bcm6328.c: In function 'bcm6328_led': >> drivers/leds/leds-bcm6328.c:353:17: error: implicit declaration of function 'led_init_default_state_get'; did you mean 'led_get_default_pattern'? [-Werror=implicit-function-declaration] 353 | state = led_init_default_state_get(init_data.fwnode); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | led_get_default_pattern cc1: some warnings being treated as errors vim +353 drivers/leds/leds-bcm6328.c 326 327 static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, 328 void __iomem *mem, spinlock_t *lock, 329 unsigned long *blink_leds, unsigned long *blink_delay) 330 { 331 struct led_init_data init_data = {}; 332 struct bcm6328_led *led; 333 enum led_default_state state; 334 unsigned long val, shift; 335 void __iomem *mode; 336 int rc; 337 338 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); 339 if (!led) 340 return -ENOMEM; 341 342 led->pin = reg; 343 led->mem = mem; 344 led->lock = lock; 345 led->blink_leds = blink_leds; 346 led->blink_delay = blink_delay; 347 348 if (of_property_read_bool(nc, "active-low")) 349 led->active_low = true; 350 351 init_data.fwnode = of_fwnode_handle(nc); 352 > 353 state = led_init_default_state_get(init_data.fwnode); 354 switch (state) { 355 case LEDS_DEFSTATE_ON: 356 led->cdev.brightness = LED_FULL; 357 break; 358 case LEDS_DEFSTATE_KEEP: 359 shift = bcm6328_pin2shift(led->pin); 360 if (shift / 16) 361 mode = mem + BCM6328_REG_MODE_HI; 362 else 363 mode = mem + BCM6328_REG_MODE_LO; 364 365 val = bcm6328_led_read(mode) >> BCM6328_LED_SHIFT(shift % 16); 366 val &= BCM6328_LED_MODE_MASK; 367 if ((led->active_low && val == BCM6328_LED_MODE_OFF) || 368 (!led->active_low && val == BCM6328_LED_MODE_ON)) 369 led->cdev.brightness = LED_FULL; 370 else 371 led->cdev.brightness = LED_OFF; 372 break; 373 default: 374 led->cdev.brightness = LED_OFF; 375 } 376 377 bcm6328_led_set(&led->cdev, led->cdev.brightness); 378 379 led->cdev.brightness_set = bcm6328_led_set; 380 led->cdev.blink_set = bcm6328_blink_set; 381 382 rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); 383 if (rc < 0) 384 return rc; 385 386 dev_dbg(dev, "registered LED %s\n", led->cdev.name); 387 388 return 0; 389 } 390
Hi Andy, I love your patch! Yet something to improve: [auto build test ERROR on pavel-leds/for-next] [also build test ERROR on linus/master v5.19 next-20220802] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/leds-bcm6328-Get-rid-of-custom-led_init_default_state_get/20220803-052959 base: git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next config: arc-randconfig-r016-20220801 (https://download.01.org/0day-ci/archive/20220803/202208032028.jurRnUDS-lkp@intel.com/config) compiler: arceb-elf-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/514383e5dd28e25f812c88b0454a02d59e4d205c git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/leds-bcm6328-Get-rid-of-custom-led_init_default_state_get/20220803-052959 git checkout 514383e5dd28e25f812c88b0454a02d59e4d205c # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash drivers/leds/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/leds/leds-bcm6328.c: In function 'bcm6328_led': >> drivers/leds/leds-bcm6328.c:353:17: error: implicit declaration of function 'led_init_default_state_get'; did you mean 'led_get_default_pattern'? [-Werror=implicit-function-declaration] 353 | state = led_init_default_state_get(init_data.fwnode); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | led_get_default_pattern cc1: some warnings being treated as errors vim +353 drivers/leds/leds-bcm6328.c 326 327 static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, 328 void __iomem *mem, spinlock_t *lock, 329 unsigned long *blink_leds, unsigned long *blink_delay) 330 { 331 struct led_init_data init_data = {}; 332 struct bcm6328_led *led; 333 enum led_default_state state; 334 unsigned long val, shift; 335 void __iomem *mode; 336 int rc; 337 338 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); 339 if (!led) 340 return -ENOMEM; 341 342 led->pin = reg; 343 led->mem = mem; 344 led->lock = lock; 345 led->blink_leds = blink_leds; 346 led->blink_delay = blink_delay; 347 348 if (of_property_read_bool(nc, "active-low")) 349 led->active_low = true; 350 351 init_data.fwnode = of_fwnode_handle(nc); 352 > 353 state = led_init_default_state_get(init_data.fwnode); 354 switch (state) { 355 case LEDS_DEFSTATE_ON: 356 led->cdev.brightness = LED_FULL; 357 break; 358 case LEDS_DEFSTATE_KEEP: 359 shift = bcm6328_pin2shift(led->pin); 360 if (shift / 16) 361 mode = mem + BCM6328_REG_MODE_HI; 362 else 363 mode = mem + BCM6328_REG_MODE_LO; 364 365 val = bcm6328_led_read(mode) >> BCM6328_LED_SHIFT(shift % 16); 366 val &= BCM6328_LED_MODE_MASK; 367 if ((led->active_low && val == BCM6328_LED_MODE_OFF) || 368 (!led->active_low && val == BCM6328_LED_MODE_ON)) 369 led->cdev.brightness = LED_FULL; 370 else 371 led->cdev.brightness = LED_OFF; 372 break; 373 default: 374 led->cdev.brightness = LED_OFF; 375 } 376 377 bcm6328_led_set(&led->cdev, led->cdev.brightness); 378 379 led->cdev.brightness_set = bcm6328_led_set; 380 led->cdev.blink_set = bcm6328_blink_set; 381 382 rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); 383 if (rc < 0) 384 return rc; 385 386 dev_dbg(dev, "registered LED %s\n", led->cdev.name); 387 388 return 0; 389 } 390
diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index 2d4d87957a30..246f1296ab09 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -330,7 +330,9 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, { struct led_init_data init_data = {}; struct bcm6328_led *led; - const char *state; + enum led_default_state state; + unsigned long val, shift; + void __iomem *mode; int rc; led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); @@ -346,31 +348,29 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, if (of_property_read_bool(nc, "active-low")) led->active_low = true; - if (!of_property_read_string(nc, "default-state", &state)) { - if (!strcmp(state, "on")) { + init_data.fwnode = of_fwnode_handle(nc); + + state = led_init_default_state_get(init_data.fwnode); + switch (state) { + case LEDS_DEFSTATE_ON: + led->cdev.brightness = LED_FULL; + break; + case LEDS_DEFSTATE_KEEP: + shift = bcm6328_pin2shift(led->pin); + if (shift / 16) + mode = mem + BCM6328_REG_MODE_HI; + else + mode = mem + BCM6328_REG_MODE_LO; + + val = bcm6328_led_read(mode) >> BCM6328_LED_SHIFT(shift % 16); + val &= BCM6328_LED_MODE_MASK; + if ((led->active_low && val == BCM6328_LED_MODE_OFF) || + (!led->active_low && val == BCM6328_LED_MODE_ON)) led->cdev.brightness = LED_FULL; - } else if (!strcmp(state, "keep")) { - void __iomem *mode; - unsigned long val, shift; - - shift = bcm6328_pin2shift(led->pin); - if (shift / 16) - mode = mem + BCM6328_REG_MODE_HI; - else - mode = mem + BCM6328_REG_MODE_LO; - - val = bcm6328_led_read(mode) >> - BCM6328_LED_SHIFT(shift % 16); - val &= BCM6328_LED_MODE_MASK; - if ((led->active_low && val == BCM6328_LED_MODE_OFF) || - (!led->active_low && val == BCM6328_LED_MODE_ON)) - led->cdev.brightness = LED_FULL; - else - led->cdev.brightness = LED_OFF; - } else { + else led->cdev.brightness = LED_OFF; - } - } else { + break; + default: led->cdev.brightness = LED_OFF; } @@ -378,7 +378,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, led->cdev.brightness_set = bcm6328_led_set; led->cdev.blink_set = bcm6328_blink_set; - init_data.fwnode = of_fwnode_handle(nc); rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rc < 0)
LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/leds/leds-bcm6328.c | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-)