Commit 02184c60 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-v4.7-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply fixes from Sebastian Reichel.

* tag 'for-v4.7-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
  power_supply: tps65217-charger: Fix NULL deref during property export
  power_supply: power_supply_read_temp only if use_cnt > 0
parents 18751e2e 36276129
...@@ -565,11 +565,12 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd, ...@@ -565,11 +565,12 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd,
WARN_ON(tzd == NULL); WARN_ON(tzd == NULL);
psy = tzd->devdata; psy = tzd->devdata;
ret = psy->desc->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
if (ret)
return ret;
/* Convert tenths of degree Celsius to milli degree Celsius. */ /* Convert tenths of degree Celsius to milli degree Celsius. */
if (!ret) *temp = val.intval * 100;
*temp = val.intval * 100;
return ret; return ret;
} }
...@@ -612,10 +613,12 @@ static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd, ...@@ -612,10 +613,12 @@ static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd,
int ret; int ret;
psy = tcd->devdata; psy = tcd->devdata;
ret = psy->desc->get_property(psy, ret = power_supply_get_property(psy,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val); POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val);
if (!ret) if (ret)
*state = val.intval; return ret;
*state = val.intval;
return ret; return ret;
} }
...@@ -628,10 +631,12 @@ static int ps_get_cur_chrage_cntl_limit(struct thermal_cooling_device *tcd, ...@@ -628,10 +631,12 @@ static int ps_get_cur_chrage_cntl_limit(struct thermal_cooling_device *tcd,
int ret; int ret;
psy = tcd->devdata; psy = tcd->devdata;
ret = psy->desc->get_property(psy, ret = power_supply_get_property(psy,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val); POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
if (!ret) if (ret)
*state = val.intval; return ret;
*state = val.intval;
return ret; return ret;
} }
......
...@@ -197,6 +197,7 @@ static int tps65217_charger_probe(struct platform_device *pdev) ...@@ -197,6 +197,7 @@ static int tps65217_charger_probe(struct platform_device *pdev)
{ {
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger; struct tps65217_charger *charger;
struct power_supply_config cfg = {};
int ret; int ret;
dev_dbg(&pdev->dev, "%s\n", __func__); dev_dbg(&pdev->dev, "%s\n", __func__);
...@@ -208,9 +209,12 @@ static int tps65217_charger_probe(struct platform_device *pdev) ...@@ -208,9 +209,12 @@ static int tps65217_charger_probe(struct platform_device *pdev)
charger->tps = tps; charger->tps = tps;
charger->dev = &pdev->dev; charger->dev = &pdev->dev;
cfg.of_node = pdev->dev.of_node;
cfg.drv_data = charger;
charger->ac = devm_power_supply_register(&pdev->dev, charger->ac = devm_power_supply_register(&pdev->dev,
&tps65217_charger_desc, &tps65217_charger_desc,
NULL); &cfg);
if (IS_ERR(charger->ac)) { if (IS_ERR(charger->ac)) {
dev_err(&pdev->dev, "failed: power supply register\n"); dev_err(&pdev->dev, "failed: power supply register\n");
return PTR_ERR(charger->ac); return PTR_ERR(charger->ac);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment