diff mbox series

power/supply/olpc_battery: Hold the reference returned by of_find_compatible_node

Message ID 20220621072408.4080461-1-windhl@126.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series power/supply/olpc_battery: Hold the reference returned by of_find_compatible_node | expand

Commit Message

Liang He June 21, 2022, 7:24 a.m. UTC
In olpc_battery_probe(), we should hold the reference returned by
of_find_compatible_node() and use it to call of_node_put() for
refcount balance.

Signed-off-by: Liang He <windhl@126.com>
---
 drivers/power/supply/olpc_battery.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

kernel test robot June 21, 2022, 1:43 p.m. UTC | #1
Hi Liang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on sre-power-supply/for-next]
[also build test WARNING on linus/master v5.19-rc3 next-20220621]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Liang-He/power-supply-olpc_battery-Hold-the-reference-returned-by-of_find_compatible_node/20220621-152751
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220621/202206212112.5idCYSI1-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/911b0892099263f0acd11bd5ae75509f9ac677db
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Liang-He/power-supply-olpc_battery-Hold-the-reference-returned-by-of_find_compatible_node/20220621-152751
        git checkout 911b0892099263f0acd11bd5ae75509f9ac677db
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/power/supply/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/power/supply/olpc_battery.c: In function 'olpc_battery_probe':
   drivers/power/supply/olpc_battery.c:653:67: error: expected ';' before 'if'
     653 |         np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")
         |                                                                   ^
         |                                                                   ;
     654 |         if (np) {
         |         ~~                                                         
>> drivers/power/supply/olpc_battery.c:639:17: warning: unused variable 'status' [-Wunused-variable]
     639 |         uint8_t status;
         |                 ^~~~~~
   drivers/power/supply/olpc_battery.c:638:29: warning: variable 'np' set but not used [-Wunused-but-set-variable]
     638 |         struct device_node *np;
         |                             ^~


vim +/status +639 drivers/power/supply/olpc_battery.c

cae659af87288a drivers/power/olpc_battery.c        Daniel Drake        2011-08-10  632  
c8afa6406e60ae drivers/power/olpc_battery.c        Bill Pemberton      2012-11-19  633  static int olpc_battery_probe(struct platform_device *pdev)
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  634  {
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  635  	struct power_supply_config bat_psy_cfg = {};
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  636  	struct power_supply_config ac_psy_cfg = {};
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  637  	struct olpc_battery_data *data;
911b0892099263 drivers/power/supply/olpc_battery.c Liang He            2022-06-21  638  	struct device_node *np;
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04 @639  	uint8_t status;
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  640  	uint8_t ecver;
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  641  	int ret;
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  642  
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  643  	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  644  	if (!data)
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  645  		return -ENOMEM;
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  646  	platform_set_drvdata(pdev, data);
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  647  
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  648  	/* See if the EC is already there and get the EC revision */
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  649  	ret = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ecver, 1);
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  650  	if (ret)
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  651  		return ret;
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  652  
911b0892099263 drivers/power/supply/olpc_battery.c Liang He            2022-06-21  653  	np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")
911b0892099263 drivers/power/supply/olpc_battery.c Liang He            2022-06-21  654  	if (np) {
911b0892099263 drivers/power/supply/olpc_battery.c Liang He            2022-06-21  655  		of_node_put(np);
76311b9a329554 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  656  		/* XO 1.75 */
76311b9a329554 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  657  		data->new_proto = true;
76311b9a329554 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  658  		data->little_endian = true;
76311b9a329554 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  659  	} else if (ecver > 0x44) {
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  660  		/* XO 1 or 1.5 with a new EC firmware. */
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  661  		data->new_proto = true;
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  662  	} else if (ecver < 0x44) {
484d6d50cca394 drivers/power/olpc_battery.c        Andres Salomon      2008-05-02  663  		/*
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  664  		 * We've seen a number of EC protocol changes; this driver
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  665  		 * requires the latest EC protocol, supported by 0x44 and above.
484d6d50cca394 drivers/power/olpc_battery.c        Andres Salomon      2008-05-02  666  		 */
484d6d50cca394 drivers/power/olpc_battery.c        Andres Salomon      2008-05-02  667  		printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
8ecefda2226203 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  668  			"battery driver.\n", ecver);
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  669  		return -ENXIO;
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  670  	}
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  671  
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  672  	ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1);
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  673  	if (ret)
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  674  		return ret;
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  675  
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  676  	/* Ignore the status. It doesn't actually matter */
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  677  
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  678  	ac_psy_cfg.of_node = pdev->dev.of_node;
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  679  	ac_psy_cfg.drv_data = data;
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  680  
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  681  	data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc,
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  682  								&ac_psy_cfg);
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  683  	if (IS_ERR(data->olpc_ac))
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  684  		return PTR_ERR(data->olpc_ac);
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  685  
f7a228eaf4f8aa drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  686  	if (of_device_is_compatible(pdev->dev.of_node, "olpc,xo1.5-battery")) {
f7a228eaf4f8aa drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  687  		/* XO-1.5 */
297d716f6260cc drivers/power/olpc_battery.c        Krzysztof Kozlowski 2015-03-12  688  		olpc_bat_desc.properties = olpc_xo15_bat_props;
297d716f6260cc drivers/power/olpc_battery.c        Krzysztof Kozlowski 2015-03-12  689  		olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props);
f7a228eaf4f8aa drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  690  	} else {
f7a228eaf4f8aa drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  691  		/* XO-1 */
297d716f6260cc drivers/power/olpc_battery.c        Krzysztof Kozlowski 2015-03-12  692  		olpc_bat_desc.properties = olpc_xo1_bat_props;
297d716f6260cc drivers/power/olpc_battery.c        Krzysztof Kozlowski 2015-03-12  693  		olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
c566d299f91bdb drivers/power/olpc_battery.c        Daniel Drake        2010-12-29  694  	}
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  695  
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  696  	bat_psy_cfg.of_node = pdev->dev.of_node;
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  697  	bat_psy_cfg.drv_data = data;
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  698  	bat_psy_cfg.attr_grp = olpc_bat_sysfs_groups;
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  699  
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  700  	data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc,
31e220877981d0 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  701  								&bat_psy_cfg);
b0280d05804ae8 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  702  	if (IS_ERR(data->olpc_bat))
b0280d05804ae8 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  703  		return PTR_ERR(data->olpc_bat);
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  704  
cae659af87288a drivers/power/olpc_battery.c        Daniel Drake        2011-08-10  705  	if (olpc_ec_wakeup_available()) {
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  706  		device_set_wakeup_capable(&data->olpc_ac->dev, true);
33554d818a9562 drivers/power/supply/olpc_battery.c Lubomir Rintel      2019-04-18  707  		device_set_wakeup_capable(&data->olpc_bat->dev, true);
cae659af87288a drivers/power/olpc_battery.c        Daniel Drake        2011-08-10  708  	}
cae659af87288a drivers/power/olpc_battery.c        Daniel Drake        2011-08-10  709  
c3503fd0255824 drivers/power/olpc_battery.c        Daniel Drake        2011-08-10  710  	return 0;
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  711  }
fb972873a76722 drivers/power/olpc_battery.c        David Woodhouse     2007-05-04  712
kernel test robot June 21, 2022, 1:53 p.m. UTC | #2
Hi Liang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sre-power-supply/for-next]
[also build test ERROR on linus/master v5.19-rc3 next-20220621]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Liang-He/power-supply-olpc_battery-Hold-the-reference-returned-by-of_find_compatible_node/20220621-152751
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: hexagon-randconfig-r041-20220621 (https://download.01.org/0day-ci/archive/20220621/202206212155.CveAC2KI-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project af6d2a0b6825e71965f3e2701a63c239fa0ad70f)
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/911b0892099263f0acd11bd5ae75509f9ac677db
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Liang-He/power-supply-olpc_battery-Hold-the-reference-returned-by-of_find_compatible_node/20220621-152751
        git checkout 911b0892099263f0acd11bd5ae75509f9ac677db
        # 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 <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/power/supply/olpc_battery.c:653:60: error: expected ';' after expression
           np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")
                                                                     ^
                                                                     ;
   1 error generated.


vim +653 drivers/power/supply/olpc_battery.c

   632	
   633	static int olpc_battery_probe(struct platform_device *pdev)
   634	{
   635		struct power_supply_config bat_psy_cfg = {};
   636		struct power_supply_config ac_psy_cfg = {};
   637		struct olpc_battery_data *data;
   638		struct device_node *np;
   639		uint8_t status;
   640		uint8_t ecver;
   641		int ret;
   642	
   643		data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
   644		if (!data)
   645			return -ENOMEM;
   646		platform_set_drvdata(pdev, data);
   647	
   648		/* See if the EC is already there and get the EC revision */
   649		ret = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ecver, 1);
   650		if (ret)
   651			return ret;
   652	
 > 653		np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")
   654		if (np) {
   655			of_node_put(np);
   656			/* XO 1.75 */
   657			data->new_proto = true;
   658			data->little_endian = true;
   659		} else if (ecver > 0x44) {
   660			/* XO 1 or 1.5 with a new EC firmware. */
   661			data->new_proto = true;
   662		} else if (ecver < 0x44) {
   663			/*
   664			 * We've seen a number of EC protocol changes; this driver
   665			 * requires the latest EC protocol, supported by 0x44 and above.
   666			 */
   667			printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
   668				"battery driver.\n", ecver);
   669			return -ENXIO;
   670		}
   671	
   672		ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1);
   673		if (ret)
   674			return ret;
   675	
   676		/* Ignore the status. It doesn't actually matter */
   677	
   678		ac_psy_cfg.of_node = pdev->dev.of_node;
   679		ac_psy_cfg.drv_data = data;
   680	
   681		data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc,
   682									&ac_psy_cfg);
   683		if (IS_ERR(data->olpc_ac))
   684			return PTR_ERR(data->olpc_ac);
   685	
   686		if (of_device_is_compatible(pdev->dev.of_node, "olpc,xo1.5-battery")) {
   687			/* XO-1.5 */
   688			olpc_bat_desc.properties = olpc_xo15_bat_props;
   689			olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props);
   690		} else {
   691			/* XO-1 */
   692			olpc_bat_desc.properties = olpc_xo1_bat_props;
   693			olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
   694		}
   695	
   696		bat_psy_cfg.of_node = pdev->dev.of_node;
   697		bat_psy_cfg.drv_data = data;
   698		bat_psy_cfg.attr_grp = olpc_bat_sysfs_groups;
   699	
   700		data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc,
   701									&bat_psy_cfg);
   702		if (IS_ERR(data->olpc_bat))
   703			return PTR_ERR(data->olpc_bat);
   704	
   705		if (olpc_ec_wakeup_available()) {
   706			device_set_wakeup_capable(&data->olpc_ac->dev, true);
   707			device_set_wakeup_capable(&data->olpc_bat->dev, true);
   708		}
   709	
   710		return 0;
   711	}
   712
kernel test robot June 21, 2022, 3:37 p.m. UTC | #3
Hi Liang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sre-power-supply/for-next]
[also build test ERROR on linus/master v5.19-rc3 next-20220621]
[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]

url:    https://github.com/intel-lab-lkp/linux/commits/Liang-He/power-supply-olpc_battery-Hold-the-reference-returned-by-of_find_compatible_node/20220621-152751
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20220621/202206212323.c8gOHmJb-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 11.3.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/911b0892099263f0acd11bd5ae75509f9ac677db
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Liang-He/power-supply-olpc_battery-Hold-the-reference-returned-by-of_find_compatible_node/20220621-152751
        git checkout 911b0892099263f0acd11bd5ae75509f9ac677db
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/power/supply/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/power/supply/olpc_battery.c: In function 'olpc_battery_probe':
>> drivers/power/supply/olpc_battery.c:653:67: error: expected ';' before 'if'
     653 |         np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")
         |                                                                   ^
         |                                                                   ;
     654 |         if (np) {
         |         ~~                                                         
   drivers/power/supply/olpc_battery.c:639:17: warning: unused variable 'status' [-Wunused-variable]
     639 |         uint8_t status;
         |                 ^~~~~~
>> drivers/power/supply/olpc_battery.c:638:29: warning: variable 'np' set but not used [-Wunused-but-set-variable]
     638 |         struct device_node *np;
         |                             ^~


vim +653 drivers/power/supply/olpc_battery.c

   632	
   633	static int olpc_battery_probe(struct platform_device *pdev)
   634	{
   635		struct power_supply_config bat_psy_cfg = {};
   636		struct power_supply_config ac_psy_cfg = {};
   637		struct olpc_battery_data *data;
 > 638		struct device_node *np;
   639		uint8_t status;
   640		uint8_t ecver;
   641		int ret;
   642	
   643		data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
   644		if (!data)
   645			return -ENOMEM;
   646		platform_set_drvdata(pdev, data);
   647	
   648		/* See if the EC is already there and get the EC revision */
   649		ret = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ecver, 1);
   650		if (ret)
   651			return ret;
   652	
 > 653		np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")
   654		if (np) {
   655			of_node_put(np);
   656			/* XO 1.75 */
   657			data->new_proto = true;
   658			data->little_endian = true;
   659		} else if (ecver > 0x44) {
   660			/* XO 1 or 1.5 with a new EC firmware. */
   661			data->new_proto = true;
   662		} else if (ecver < 0x44) {
   663			/*
   664			 * We've seen a number of EC protocol changes; this driver
   665			 * requires the latest EC protocol, supported by 0x44 and above.
   666			 */
   667			printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
   668				"battery driver.\n", ecver);
   669			return -ENXIO;
   670		}
   671	
   672		ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1);
   673		if (ret)
   674			return ret;
   675	
   676		/* Ignore the status. It doesn't actually matter */
   677	
   678		ac_psy_cfg.of_node = pdev->dev.of_node;
   679		ac_psy_cfg.drv_data = data;
   680	
   681		data->olpc_ac = devm_power_supply_register(&pdev->dev, &olpc_ac_desc,
   682									&ac_psy_cfg);
   683		if (IS_ERR(data->olpc_ac))
   684			return PTR_ERR(data->olpc_ac);
   685	
   686		if (of_device_is_compatible(pdev->dev.of_node, "olpc,xo1.5-battery")) {
   687			/* XO-1.5 */
   688			olpc_bat_desc.properties = olpc_xo15_bat_props;
   689			olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props);
   690		} else {
   691			/* XO-1 */
   692			olpc_bat_desc.properties = olpc_xo1_bat_props;
   693			olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
   694		}
   695	
   696		bat_psy_cfg.of_node = pdev->dev.of_node;
   697		bat_psy_cfg.drv_data = data;
   698		bat_psy_cfg.attr_grp = olpc_bat_sysfs_groups;
   699	
   700		data->olpc_bat = devm_power_supply_register(&pdev->dev, &olpc_bat_desc,
   701									&bat_psy_cfg);
   702		if (IS_ERR(data->olpc_bat))
   703			return PTR_ERR(data->olpc_bat);
   704	
   705		if (olpc_ec_wakeup_available()) {
   706			device_set_wakeup_capable(&data->olpc_ac->dev, true);
   707			device_set_wakeup_capable(&data->olpc_bat->dev, true);
   708		}
   709	
   710		return 0;
   711	}
   712
diff mbox series

Patch

diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index e0476ec06601..9f122a02b70c 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -635,6 +635,7 @@  static int olpc_battery_probe(struct platform_device *pdev)
 	struct power_supply_config bat_psy_cfg = {};
 	struct power_supply_config ac_psy_cfg = {};
 	struct olpc_battery_data *data;
+	struct device_node *np;
 	uint8_t status;
 	uint8_t ecver;
 	int ret;
@@ -649,7 +650,9 @@  static int olpc_battery_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	if (of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")) {
+	np = of_find_compatible_node(NULL, NULL, "olpc,xo1.75-ec")
+	if (np) {
+		of_node_put(np);
 		/* XO 1.75 */
 		data->new_proto = true;
 		data->little_endian = true;