leds: bcm6328: Get rid of custom led_init_default_state_get()
PATCH 1/1 leds: bcm6328: Get rid of custom led_init_default_state_get()
LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation.
--- drivers/leds/leds-bcm6328.c | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-)
drivers/leds/leds-bcm6328.c +24 -25
@@ -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 )
Signature · 1 line
2.35.1
kernel test robot
build botI love your patch! Yet something to improve:
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-20220728] [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: hexagon-randconfig-r045-20220802 (https://download.01.org/0day-ci/archive/20220803/[email protected]/config) compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 52cd00cabf479aa7eb6dbb063b7ba41ea57bce9e)
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=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/leds/
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
>> drivers/leds/leds-bcm6328.c:353:10: error: call to undeclared function 'led_init_default_state_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
state = led_init_default_state_get(init_data.fwnode);
^1 error generated.
vim +/led_init_default_state_get +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
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botI love your patch! Yet something to improve:
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/[email protected]/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
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_patterncc1: 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
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botI love your patch! Yet something to improve:
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/[email protected]/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
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_patterncc1: 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
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp