* [PATCH v1 1/1] leds: syscon: Get rid of custom led_init_default_state_get()
@ 2022-08-02 21:25 Andy Shevchenko
2022-08-03 0:55 ` 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-syscon.c | 49 ++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 26 deletions(-)
diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c
index 7eddb8ecb44e..e38abb5e60c1 100644
--- a/drivers/leds/leds-syscon.c
+++ b/drivers/leds/leds-syscon.c
@@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev)
struct device *parent;
struct regmap *map;
struct syscon_led *sled;
- const char *state;
+ enum led_default_state state;
+ u32 value;
int ret;
parent = dev->parent;
@@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pdev)
if (of_property_read_u32(np, "mask", &sled->mask))
return -EINVAL;
- state = of_get_property(np, "default-state", NULL);
- if (state) {
- if (!strcmp(state, "keep")) {
- u32 val;
-
- ret = regmap_read(map, sled->offset, &val);
- if (ret < 0)
- return ret;
- sled->state = !!(val & sled->mask);
- } else if (!strcmp(state, "on")) {
- sled->state = true;
- ret = regmap_update_bits(map, sled->offset,
- sled->mask,
- sled->mask);
- if (ret < 0)
- return ret;
- } else {
- sled->state = false;
- ret = regmap_update_bits(map, sled->offset,
- sled->mask, 0);
- if (ret < 0)
- return ret;
- }
+ init_data.fwnode = of_fwnode_handle(np);
+
+ state = led_init_default_state_get(init_data.fwnode);
+ switch (state) {
+ case LEDS_DEFSTATE_ON:
+ ret = regmap_update_bits(map, sled->offset, sled->mask, sled->mask);
+ if (ret < 0)
+ return ret;
+ sled->state = true;
+ break;
+ case LEDS_DEFSTATE_KEEP:
+ ret = regmap_read(map, sled->offset, &value);
+ if (ret < 0)
+ return ret;
+ sled->state = !!(value & sled->mask);
+ break;
+ default:
+ ret = regmap_update_bits(map, sled->offset, sled->mask, 0);
+ if (ret < 0)
+ return ret;
+ sled->state = false;
}
sled->cdev.brightness_set = syscon_led_set;
- init_data.fwnode = of_fwnode_handle(np);
-
ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data);
if (ret < 0)
return ret;
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/1] leds: syscon: Get rid of custom led_init_default_state_get()
2022-08-02 21:25 [PATCH v1 1/1] leds: syscon: Get rid of custom led_init_default_state_get() Andy Shevchenko
@ 2022-08-03 0:55 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-08-03 0:55 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-syscon-Get-rid-of-custom-led_init_default_state_get/20220803-052528
base: git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next
config: hexagon-randconfig-r041-20220801 (https://download.01.org/0day-ci/archive/20220803/202208030858.VhHvPCPM-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
# https://github.com/intel-lab-lkp/linux/commit/485abd71bd954b7a2d1ea89818ca5c925714b1e1
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/leds-syscon-Get-rid-of-custom-led_init_default_state_get/20220803-052528
git checkout 485abd71bd954b7a2d1ea89818ca5c925714b1e1
# 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
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/leds/leds-syscon.c:92: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 +92 drivers/leds/leds-syscon.c
55
56 static int syscon_led_probe(struct platform_device *pdev)
57 {
58 struct led_init_data init_data = {};
59 struct device *dev = &pdev->dev;
60 struct device_node *np = dev_of_node(dev);
61 struct device *parent;
62 struct regmap *map;
63 struct syscon_led *sled;
64 enum led_default_state state;
65 u32 value;
66 int ret;
67
68 parent = dev->parent;
69 if (!parent) {
70 dev_err(dev, "no parent for syscon LED\n");
71 return -ENODEV;
72 }
73 map = syscon_node_to_regmap(dev_of_node(parent));
74 if (IS_ERR(map)) {
75 dev_err(dev, "no regmap for syscon LED parent\n");
76 return PTR_ERR(map);
77 }
78
79 sled = devm_kzalloc(dev, sizeof(*sled), GFP_KERNEL);
80 if (!sled)
81 return -ENOMEM;
82
83 sled->map = map;
84
85 if (of_property_read_u32(np, "offset", &sled->offset))
86 return -EINVAL;
87 if (of_property_read_u32(np, "mask", &sled->mask))
88 return -EINVAL;
89
90 init_data.fwnode = of_fwnode_handle(np);
91
> 92 state = led_init_default_state_get(init_data.fwnode);
93 switch (state) {
94 case LEDS_DEFSTATE_ON:
95 ret = regmap_update_bits(map, sled->offset, sled->mask, sled->mask);
96 if (ret < 0)
97 return ret;
98 sled->state = true;
99 break;
100 case LEDS_DEFSTATE_KEEP:
101 ret = regmap_read(map, sled->offset, &value);
102 if (ret < 0)
103 return ret;
104 sled->state = !!(value & sled->mask);
105 break;
106 default:
107 ret = regmap_update_bits(map, sled->offset, sled->mask, 0);
108 if (ret < 0)
109 return ret;
110 sled->state = false;
111 }
112 sled->cdev.brightness_set = syscon_led_set;
113
114 ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data);
115 if (ret < 0)
116 return ret;
117
118 platform_set_drvdata(pdev, sled);
119 dev_info(dev, "registered LED %s\n", sled->cdev.name);
120
121 return 0;
122 }
123
--
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 0:55 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: syscon: Get rid of custom led_init_default_state_get() Andy Shevchenko
2022-08-03 0:55 ` 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).