regulator: userspace-consumer: Retrieve supplies from DT
PATCH RESEND 1/1 regulator: userspace-consumer: Retrieve supplies from DT
Instead of hardcoding a single supply, retrieve supplies from DT.
--- drivers/regulator/userspace-consumer.c | 43 ++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-)
drivers/regulator/userspace-consumer.c +40 -3
@@ -153,11 +153,32 @@ static int regulator_userspace_notify(struct notifier_block *nb,return NOTIFY_OK ; } +#define SUPPLY_SUFFIX "-supply" +#define SUPPLY_SUFFIX_LEN 7 + +static int get_num_supplies (struct platform_device *pdev) +{ +struct property *prop; +int num_supplies =0 ; + +for_each_property_of_node (pdev->dev.of_node, prop) { +const char *prop_name = prop->name; +int len =strlen (prop_name); + +if (len >SUPPLY_SUFFIX_LEN && \ +strcmp (prop_name + len -SUPPLY_SUFFIX_LEN ,SUPPLY_SUFFIX ) ==0 ) { + num_supplies++; + } + } +return num_supplies; +} +static int regulator_userspace_consumer_probe (struct platform_device *pdev) {struct regulator_userspace_consumer_data tmpdata;struct regulator_userspace_consumer_data *pdata;struct userspace_consumer_data *drvdata; +struct property *prop;int i, ret; pdata =dev_get_platdata (&pdev->dev);
@@ -169,11 +190,27 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)memset (pdata,0 ,sizeof (*pdata)); pdata->no_autoswitch = true; - pdata->num_supplies =1 ; - pdata->supplies =devm_kzalloc (&pdev->dev,sizeof (*pdata->supplies),GFP_KERNEL ); + pdata->num_supplies =get_num_supplies (pdev); + + pdata->supplies =devm_kzalloc (&pdev->dev, pdata->num_supplies * \ +sizeof (*pdata->supplies),GFP_KERNEL );if (!pdata->supplies)return -ENOMEM ; - pdata->supplies[0 ].supply ="vout" ; + +for_each_property_of_node (pdev->dev.of_node, prop) { +const char *prop_name = prop->name; +int len =strlen (prop_name); + +if (len >7 && \ +strcmp (prop_name + len -SUPPLY_SUFFIX_LEN ,SUPPLY_SUFFIX ) ==0 ) { +char *supply_name =devm_kzalloc (&pdev->dev, + len -SUPPLY_SUFFIX_LEN +1 , +GFP_KERNEL ); +strscpy (supply_name, prop_name, len -SUPPLY_SUFFIX_LEN ); + supply_name[len -SUPPLY_SUFFIX_LEN ] ='\0' ; + pdata->supplies[0 ].supply = supply_name; + } + } }if (pdata->num_supplies <1 ) {
base-commit: 8950c4a350c188deb5f5b05df3244d4db82fe3d8
Signature · 1 line
2.41.0
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Naresh,
kernel test robot noticed the following build errors:
[auto build test ERROR on 8950c4a350c188deb5f5b05df3244d4db82fe3d8]
url: https://github.com/intel-lab-lkp/linux/commits/Naresh-Solanki/regulator-userspace-consumer-Retrieve-supplies-from-DT/20230829-222520 base: 8950c4a350c188deb5f5b05df3244d4db82fe3d8 patch link: https://lore.kernel.org/r/20230829141413.2605621-1-Naresh.Solanki%409elements.com patch subject: [RESEND PATCH] regulator: userspace-consumer: Retrieve supplies from DT config: s390-randconfig-r016-20230830 (https://download.01.org/0day-ci/archive/20230830/[email protected]/config) compiler: s390-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230830/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/regulator/userspace-consumer.c: In function 'get_num_supplies':
>> drivers/regulator/userspace-consumer.c:164:9: error: implicit declaration of function 'for_each_property_of_node'; did you mean 'for_each_child_of_node'? [-Werror=implicit-function-declaration]
164 | for_each_property_of_node(pdev->dev.of_node, prop) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| for_each_child_of_node
>> drivers/regulator/userspace-consumer.c:164:59: error: expected ';' before '{' token
164 | for_each_property_of_node(pdev->dev.of_node, prop) {
| ^~
| ;
>> drivers/regulator/userspace-consumer.c:162:13: warning: unused variable 'num_supplies' [-Wunused-variable]
162 | int num_supplies = 0;
| ^~~~~~~~~~~~
drivers/regulator/userspace-consumer.c:174:1: error: no return statement in function returning non-void [-Werror=return-type]
174 | }
| ^
drivers/regulator/userspace-consumer.c: In function 'regulator_userspace_consumer_probe':
drivers/regulator/userspace-consumer.c:200:67: error: expected ';' before '{' token
200 | for_each_property_of_node(pdev->dev.of_node, prop) {
| ^~
| ;cc1: some warnings being treated as errors
vim +164 drivers/regulator/userspace-consumer.c
158
159 static int get_num_supplies(struct platform_device *pdev)
160 {
161 struct property *prop;
> 162 int num_supplies = 0;
163
> 164 for_each_property_of_node(pdev->dev.of_node, prop) { 165 const char *prop_name = prop->name;
166 int len = strlen(prop_name);
167
168 if (len > SUPPLY_SUFFIX_LEN && \
169 strcmp(prop_name + len - SUPPLY_SUFFIX_LEN, SUPPLY_SUFFIX) == 0) {
170 num_supplies++;
171 }
172 }
173 return num_supplies;
174 }
175
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Naresh,
kernel test robot noticed the following build errors:
[auto build test ERROR on 8950c4a350c188deb5f5b05df3244d4db82fe3d8]
url: https://github.com/intel-lab-lkp/linux/commits/Naresh-Solanki/regulator-userspace-consumer-Retrieve-supplies-from-DT/20230829-222520 base: 8950c4a350c188deb5f5b05df3244d4db82fe3d8 patch link: https://lore.kernel.org/r/20230829141413.2605621-1-Naresh.Solanki%409elements.com patch subject: [RESEND PATCH] regulator: userspace-consumer: Retrieve supplies from DT config: i386-buildonly-randconfig-001-20230830 (https://download.01.org/0day-ci/archive/20230830/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230830/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/regulator/userspace-consumer.c:164:2: error: call to undeclared function 'for_each_property_of_node'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
for_each_property_of_node(pdev->dev.of_node, prop) {
^
>> drivers/regulator/userspace-consumer.c:164:52: error: expected ';' after expression
for_each_property_of_node(pdev->dev.of_node, prop) {
^
;
drivers/regulator/userspace-consumer.c:200:3: error: call to undeclared function 'for_each_property_of_node'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
for_each_property_of_node(pdev->dev.of_node, prop) {
^
drivers/regulator/userspace-consumer.c:200:53: error: expected ';' after expression
for_each_property_of_node(pdev->dev.of_node, prop) {
^
;4 errors generated.
vim +/for_each_property_of_node +164 drivers/regulator/userspace-consumer.c
158
159 static int get_num_supplies(struct platform_device *pdev)
160 {
161 struct property *prop;
162 int num_supplies = 0;
163
> 164 for_each_property_of_node(pdev->dev.of_node, prop) { 165 const char *prop_name = prop->name;
166 int len = strlen(prop_name);
167
168 if (len > SUPPLY_SUFFIX_LEN && \
169 strcmp(prop_name + len - SUPPLY_SUFFIX_LEN, SUPPLY_SUFFIX) == 0) {
170 num_supplies++;
171 }
172 }
173 return num_supplies;
174 }
175
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki