linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] leds: bcm6358: Get rid of custom led_init_default_state_get()
@ 2022-08-02 21:25 Andy Shevchenko
  2022-08-06 15:00 ` kernel test robot
  2022-08-06 16:43 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-08-02 21:25 UTC (permalink / raw)
  To: Andy Shevchenko, linux-leds, linux-kernel; +Cc: Pavel Machek

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-bcm6358.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
index 9d2e487fa08a..86e51d44a5a7 100644
--- a/drivers/leds/leds-bcm6358.c
+++ b/drivers/leds/leds-bcm6358.c
@@ -96,7 +96,8 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
 {
 	struct led_init_data init_data = {};
 	struct bcm6358_led *led;
-	const char *state;
+	enum led_default_state state;
+	unsigned long val;
 	int rc;
 
 	led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
@@ -110,29 +111,28 @@ static int bcm6358_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:
+		val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
+		val &= BIT(led->pin);
+		if ((led->active_low && !val) || (!led->active_low && val))
 			led->cdev.brightness = LED_FULL;
-		} else if (!strcmp(state, "keep")) {
-			unsigned long val;
-			val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
-			val &= BIT(led->pin);
-			if ((led->active_low && !val) ||
-			    (!led->active_low && val))
-				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;
 	}
 
 	bcm6358_led_set(&led->cdev, led->cdev.brightness);
 
 	led->cdev.brightness_set = bcm6358_led_set;
-	init_data.fwnode = of_fwnode_handle(nc);
 
 	rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
 	if (rc < 0)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] leds: bcm6358: Get rid of custom led_init_default_state_get()
  2022-08-02 21:25 [PATCH v1 1/1] leds: bcm6358: Get rid of custom led_init_default_state_get() Andy Shevchenko
@ 2022-08-06 15:00 ` kernel test robot
  2022-08-06 16:43 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-08-06 15:00 UTC (permalink / raw)
  To: Andy Shevchenko, linux-leds, linux-kernel; +Cc: kbuild-all, Pavel Machek

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-20220805]
[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-bcm6358-Get-rid-of-custom-led_init_default_state_get/20220803-053220
base:   git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next
config: parisc-randconfig-r014-20220801 (https://download.01.org/0day-ci/archive/20220806/202208062208.6mgNYMMy-lkp@intel.com/config)
compiler: hppa-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/ad3083d8ac0e2beb10b75a7d87085911b4f6139a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/leds-bcm6358-Get-rid-of-custom-led_init_default_state_get/20220803-053220
        git checkout ad3083d8ac0e2beb10b75a7d87085911b4f6139a
        # 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=parisc 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-bcm6358.c: In function 'bcm6358_led':
>> drivers/leds/leds-bcm6358.c:116:17: error: implicit declaration of function 'led_init_default_state_get'; did you mean 'led_get_default_pattern'? [-Werror=implicit-function-declaration]
     116 |         state = led_init_default_state_get(init_data.fwnode);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
         |                 led_get_default_pattern
   cc1: some warnings being treated as errors


vim +116 drivers/leds/leds-bcm6358.c

    93	
    94	static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
    95			       void __iomem *mem, spinlock_t *lock)
    96	{
    97		struct led_init_data init_data = {};
    98		struct bcm6358_led *led;
    99		enum led_default_state state;
   100		unsigned long val;
   101		int rc;
   102	
   103		led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
   104		if (!led)
   105			return -ENOMEM;
   106	
   107		led->pin = reg;
   108		led->mem = mem;
   109		led->lock = lock;
   110	
   111		if (of_property_read_bool(nc, "active-low"))
   112			led->active_low = true;
   113	
   114		init_data.fwnode = of_fwnode_handle(nc);
   115	
 > 116		state = led_init_default_state_get(init_data.fwnode);
   117		switch (state) {
   118		case LEDS_DEFSTATE_ON:
   119			led->cdev.brightness = LED_FULL;
   120			break;
   121		case LEDS_DEFSTATE_KEEP:
   122			val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
   123			val &= BIT(led->pin);
   124			if ((led->active_low && !val) || (!led->active_low && val))
   125				led->cdev.brightness = LED_FULL;
   126			else
   127				led->cdev.brightness = LED_OFF;
   128			break;
   129		default:
   130			led->cdev.brightness = LED_OFF;
   131		}
   132	
   133		bcm6358_led_set(&led->cdev, led->cdev.brightness);
   134	
   135		led->cdev.brightness_set = bcm6358_led_set;
   136	
   137		rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
   138		if (rc < 0)
   139			return rc;
   140	
   141		dev_dbg(dev, "registered LED %s\n", led->cdev.name);
   142	
   143		return 0;
   144	}
   145	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] leds: bcm6358: Get rid of custom led_init_default_state_get()
  2022-08-02 21:25 [PATCH v1 1/1] leds: bcm6358: Get rid of custom led_init_default_state_get() Andy Shevchenko
  2022-08-06 15:00 ` kernel test robot
@ 2022-08-06 16:43 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-08-06 16:43 UTC (permalink / raw)
  To: Andy Shevchenko, linux-leds, linux-kernel; +Cc: llvm, kbuild-all, Pavel Machek

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-20220805]
[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-bcm6358-Get-rid-of-custom-led_init_default_state_get/20220803-053220
base:   git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next
config: arm-buildonly-randconfig-r004-20220801 (https://download.01.org/0day-ci/archive/20220807/202208070030.kV6Z7e9R-lkp@intel.com/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
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/ad3083d8ac0e2beb10b75a7d87085911b4f6139a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Andy-Shevchenko/leds-bcm6358-Get-rid-of-custom-led_init_default_state_get/20220803-053220
        git checkout ad3083d8ac0e2beb10b75a7d87085911b4f6139a
        # 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=arm 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-bcm6358.c:116: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 +116 drivers/leds/leds-bcm6358.c

    93	
    94	static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
    95			       void __iomem *mem, spinlock_t *lock)
    96	{
    97		struct led_init_data init_data = {};
    98		struct bcm6358_led *led;
    99		enum led_default_state state;
   100		unsigned long val;
   101		int rc;
   102	
   103		led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
   104		if (!led)
   105			return -ENOMEM;
   106	
   107		led->pin = reg;
   108		led->mem = mem;
   109		led->lock = lock;
   110	
   111		if (of_property_read_bool(nc, "active-low"))
   112			led->active_low = true;
   113	
   114		init_data.fwnode = of_fwnode_handle(nc);
   115	
 > 116		state = led_init_default_state_get(init_data.fwnode);
   117		switch (state) {
   118		case LEDS_DEFSTATE_ON:
   119			led->cdev.brightness = LED_FULL;
   120			break;
   121		case LEDS_DEFSTATE_KEEP:
   122			val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
   123			val &= BIT(led->pin);
   124			if ((led->active_low && !val) || (!led->active_low && val))
   125				led->cdev.brightness = LED_FULL;
   126			else
   127				led->cdev.brightness = LED_OFF;
   128			break;
   129		default:
   130			led->cdev.brightness = LED_OFF;
   131		}
   132	
   133		bcm6358_led_set(&led->cdev, led->cdev.brightness);
   134	
   135		led->cdev.brightness_set = bcm6358_led_set;
   136	
   137		rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
   138		if (rc < 0)
   139			return rc;
   140	
   141		dev_dbg(dev, "registered LED %s\n", led->cdev.name);
   142	
   143		return 0;
   144	}
   145	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-06 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-02 21:25 [PATCH v1 1/1] leds: bcm6358: Get rid of custom led_init_default_state_get() Andy Shevchenko
2022-08-06 15:00 ` kernel test robot
2022-08-06 16:43 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).