* [PATCH v1 1/1] leds: pm8058: Get rid of custom led_init_default_state_get()
@ 2022-08-02 21:25 Andy Shevchenko
2022-08-03 1:16 ` kernel test robot
0 siblings, 1 reply; 2+ 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-pm8058.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c
index fb2ab72c0c40..b9233f14b646 100644
--- a/drivers/leds/leds-pm8058.c
+++ b/drivers/leds/leds-pm8058.c
@@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev)
struct device_node *np;
int ret;
struct regmap *map;
- const char *state;
enum led_brightness maxbright;
+ enum led_default_state state;
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
if (!led)
@@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *pdev)
maxbright = 15; /* 4 bits */
led->cdev.max_brightness = maxbright;
- state = of_get_property(np, "default-state", NULL);
- if (state) {
- if (!strcmp(state, "keep")) {
- led->cdev.brightness = pm8058_led_get(&led->cdev);
- } else if (!strcmp(state, "on")) {
- led->cdev.brightness = maxbright;
- pm8058_led_set(&led->cdev, maxbright);
- } else {
- led->cdev.brightness = LED_OFF;
- pm8058_led_set(&led->cdev, LED_OFF);
- }
+ init_data.fwnode = of_fwnode_handle(np);
+
+ state = led_init_default_state_get(init_data.fwnode);
+ switch (state) {
+ case LEDS_DEFSTATE_ON:
+ led->cdev.brightness = maxbright;
+ pm8058_led_set(&led->cdev, maxbright);
+ break;
+ case LEDS_DEFSTATE_KEEP:
+ led->cdev.brightness = pm8058_led_get(&led->cdev);
+ break;
+ default:
+ led->cdev.brightness = LED_OFF;
+ pm8058_led_set(&led->cdev, LED_OFF);
}
if (led->ledtype == PM8058_LED_TYPE_KEYPAD ||
led->ledtype == PM8058_LED_TYPE_FLASH)
led->cdev.flags = LED_CORE_SUSPENDRESUME;
- init_data.fwnode = of_fwnode_handle(np);
-
ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (ret)
dev_err(dev, "Failed to register LED for %pOF\n", np);
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v1 1/1] leds: pm8058: Get rid of custom led_init_default_state_get()
2022-08-02 21:25 [PATCH v1 1/1] leds: pm8058: Get rid of custom led_init_default_state_get() Andy Shevchenko
@ 2022-08-03 1:16 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-08-03 1:16 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-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-pm8058-Get-rid-of-custom-led_init_default_state_get/20220803-052610
base: git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next
config: arm-buildonly-randconfig-r002-20220801 (https://download.01.org/0day-ci/archive/20220803/202208030942.Sh3TajDz-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/58bf03fa835e906a28c49e4aef6060d140239d7f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/leds-pm8058-Get-rid-of-custom-led_init_default_state_get/20220803-052610
git checkout 58bf03fa835e906a28c49e4aef6060d140239d7f
# 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-pm8058.c:130: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 +130 drivers/leds/leds-pm8058.c
87
88 static int pm8058_led_probe(struct platform_device *pdev)
89 {
90 struct led_init_data init_data = {};
91 struct device *dev = &pdev->dev;
92 struct pm8058_led *led;
93 struct device_node *np;
94 int ret;
95 struct regmap *map;
96 enum led_brightness maxbright;
97 enum led_default_state state;
98
99 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
100 if (!led)
101 return -ENOMEM;
102
103 led->ledtype = (u32)(unsigned long)of_device_get_match_data(dev);
104
105 map = dev_get_regmap(dev->parent, NULL);
106 if (!map) {
107 dev_err(dev, "Parent regmap unavailable.\n");
108 return -ENXIO;
109 }
110 led->map = map;
111
112 np = dev_of_node(dev);
113
114 ret = of_property_read_u32(np, "reg", &led->reg);
115 if (ret) {
116 dev_err(dev, "no register offset specified\n");
117 return -EINVAL;
118 }
119
120 led->cdev.brightness_set = pm8058_led_set;
121 led->cdev.brightness_get = pm8058_led_get;
122 if (led->ledtype == PM8058_LED_TYPE_COMMON)
123 maxbright = 31; /* 5 bits */
124 else
125 maxbright = 15; /* 4 bits */
126 led->cdev.max_brightness = maxbright;
127
128 init_data.fwnode = of_fwnode_handle(np);
129
> 130 state = led_init_default_state_get(init_data.fwnode);
131 switch (state) {
132 case LEDS_DEFSTATE_ON:
133 led->cdev.brightness = maxbright;
134 pm8058_led_set(&led->cdev, maxbright);
135 break;
136 case LEDS_DEFSTATE_KEEP:
137 led->cdev.brightness = pm8058_led_get(&led->cdev);
138 break;
139 default:
140 led->cdev.brightness = LED_OFF;
141 pm8058_led_set(&led->cdev, LED_OFF);
142 }
143
144 if (led->ledtype == PM8058_LED_TYPE_KEYPAD ||
145 led->ledtype == PM8058_LED_TYPE_FLASH)
146 led->cdev.flags = LED_CORE_SUSPENDRESUME;
147
148 ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
149 if (ret)
150 dev_err(dev, "Failed to register LED for %pOF\n", np);
151
152 return ret;
153 }
154
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-03 1:16 UTC | newest]
Thread overview: 2+ 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: pm8058: Get rid of custom led_init_default_state_get() Andy Shevchenko
2022-08-03 1:16 ` 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).