2022-11-17 07:59:53

by ye.xingchen

[permalink] [raw]
Subject: [PATCH linux-next] power: supply: core: Use device_match_of_node()

From: ye xingchen <[email protected]>

Replace the open-code with device_match_of_node().

Signed-off-by: ye xingchen <[email protected]>
---
drivers/power/supply/power_supply_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 9035e349bf53..46d0cb0c5026 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -203,7 +203,7 @@ static int __power_supply_find_supply_from_node(struct device *dev,
struct power_supply *epsy = dev_get_drvdata(dev);

/* returning non-zero breaks out of class_for_each_device loop */
- if (epsy->of_node == np)
+ if (device_match_of_node(epsy, np))
return 1;

return 0;
--
2.25.1


2022-11-17 22:53:55

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH linux-next] power: supply: core: Use device_match_of_node()

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20221116]

url: https://github.com/intel-lab-lkp/linux/commits/ye-xingchen-zte-com-cn/power-supply-core-Use-device_match_of_node/20221117-153158
patch link: https://lore.kernel.org/r/202211171530030836446%40zte.com.cn
patch subject: [PATCH linux-next] power: supply: core: Use device_match_of_node()
config: hexagon-buildonly-randconfig-r003-20221117
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project bbe6bd724a6335e497c7edaed191d37a828d0390)
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/894b25157cccad0781bd21bf3990c9f1b51bb6ac
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review ye-xingchen-zte-com-cn/power-supply-core-Use-device_match_of_node/20221117-153158
git checkout 894b25157cccad0781bd21bf3990c9f1b51bb6ac
# 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/power/supply/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/power/supply/power_supply_core.c:206:27: error: incompatible pointer types passing 'struct power_supply *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
if (device_match_of_node(epsy, np))
^~~~
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^~~~
include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^~~~
include/linux/device/bus.h:145:41: note: passing argument to parameter 'dev' here
int device_match_of_node(struct device *dev, const void *np);
^
>> drivers/power/supply/power_supply_core.c:206:27: error: incompatible pointer types passing 'struct power_supply *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
if (device_match_of_node(epsy, np))
^~~~
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^~~~
include/linux/compiler.h:58:61: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^~~~
include/linux/device/bus.h:145:41: note: passing argument to parameter 'dev' here
int device_match_of_node(struct device *dev, const void *np);
^
>> drivers/power/supply/power_supply_core.c:206:27: error: incompatible pointer types passing 'struct power_supply *' to parameter of type 'struct device *' [-Werror,-Wincompatible-pointer-types]
if (device_match_of_node(epsy, np))
^~~~
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^~~~
include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^~~~
include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
(cond) ? \
^~~~
include/linux/device/bus.h:145:41: note: passing argument to parameter 'dev' here
int device_match_of_node(struct device *dev, const void *np);
^
3 errors generated.


vim +206 drivers/power/supply/power_supply_core.c

198
199 static int __power_supply_find_supply_from_node(struct device *dev,
200 void *data)
201 {
202 struct device_node *np = data;
203 struct power_supply *epsy = dev_get_drvdata(dev);
204
205 /* returning non-zero breaks out of class_for_each_device loop */
> 206 if (device_match_of_node(epsy, np))
207 return 1;
208
209 return 0;
210 }
211

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


Attachments:
(No filename) (4.89 kB)
config (155.31 kB)
Download all attachments

2022-11-17 22:54:57

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH linux-next] power: supply: core: Use device_match_of_node()

Hi,

On Thu, Nov 17, 2022 at 03:30:03PM +0800, [email protected] wrote:
> From: ye xingchen <[email protected]>
>
> Replace the open-code with device_match_of_node().
>
> Signed-off-by: ye xingchen <[email protected]>
> ---

struct power_supply != struct device

-- Sebastian

> drivers/power/supply/power_supply_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 9035e349bf53..46d0cb0c5026 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -203,7 +203,7 @@ static int __power_supply_find_supply_from_node(struct device *dev,
> struct power_supply *epsy = dev_get_drvdata(dev);
>
> /* returning non-zero breaks out of class_for_each_device loop */
> - if (epsy->of_node == np)
> + if (device_match_of_node(epsy, np))
> return 1;
>
> return 0;
> --
> 2.25.1


Attachments:
(No filename) (0.98 kB)
signature.asc (849.00 B)
Download all attachments