Skip to content

Commit ec7de65

Browse files
committed
Merge tag 'for-v3.18-rc' of git://git.infradead.org/battery-2.6
Pull power supply updates from Sebastian Reichel: "Power supply and reset changes for the v3.18-rc: - misc. charger-manager fixes - year 2038 fix in ab8500_fg - fix error handling of bq2415x_charger" * tag 'for-v3.18-rc' of git://git.infradead.org/battery-2.6: power: charger-manager: Fix accessing invalidated power supply after charger unbind power: charger-manager: Fix accessing invalidated power supply after fuel gauge unbind power: charger-manager: Avoid recursive thermal get_temp call power_supply: Add no_thermal property to prevent recursive get_temp calls power: bq2415x_charger: Fix memory leak on DTS parsing error power: bq2415x_charger: Properly handle ENODEV from power_supply_get_by_phandle power: ab8500_fg.c: use 64-bit time types
2 parents e061167 + cdaf3e1 commit ec7de65

6 files changed

Lines changed: 144 additions & 72 deletions

File tree

‎drivers/power/ab8500_fg.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/slab.h>
2626
#include <linux/delay.h>
2727
#include <linux/time.h>
28+
#include <linux/time64.h>
2829
#include <linux/of.h>
2930
#include <linux/completion.h>
3031
#include <linux/mfd/core.h>
@@ -108,7 +109,7 @@ enum ab8500_fg_calibration_state {
108109
struct ab8500_fg_avg_cap {
109110
int avg;
110111
int samples[NBR_AVG_SAMPLES];
111-
__kernel_time_t time_stamps[NBR_AVG_SAMPLES];
112+
time64_t time_stamps[NBR_AVG_SAMPLES];
112113
int pos;
113114
int nbr_samples;
114115
int sum;
@@ -386,15 +387,15 @@ static int ab8500_fg_is_low_curr(struct ab8500_fg *di, int curr)
386387
*/
387388
static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
388389
{
389-
struct timespec ts;
390+
struct timespec64 ts64;
390391
struct ab8500_fg_avg_cap *avg = &di->avg_cap;
391392

392-
getnstimeofday(&ts);
393+
getnstimeofday64(&ts64);
393394

394395
do {
395396
avg->sum += sample - avg->samples[avg->pos];
396397
avg->samples[avg->pos] = sample;
397-
avg->time_stamps[avg->pos] = ts.tv_sec;
398+
avg->time_stamps[avg->pos] = ts64.tv_sec;
398399
avg->pos++;
399400

400401
if (avg->pos == NBR_AVG_SAMPLES)
@@ -407,7 +408,7 @@ static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
407408
* Check the time stamp for each sample. If too old,
408409
* replace with latest sample
409410
*/
410-
} while (ts.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]);
411+
} while (ts64.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]);
411412

412413
avg->avg = avg->sum / avg->nbr_samples;
413414

@@ -446,14 +447,14 @@ static void ab8500_fg_clear_cap_samples(struct ab8500_fg *di)
446447
static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample)
447448
{
448449
int i;
449-
struct timespec ts;
450+
struct timespec64 ts64;
450451
struct ab8500_fg_avg_cap *avg = &di->avg_cap;
451452

452-
getnstimeofday(&ts);
453+
getnstimeofday64(&ts64);
453454

454455
for (i = 0; i < NBR_AVG_SAMPLES; i++) {
455456
avg->samples[i] = sample;
456-
avg->time_stamps[i] = ts.tv_sec;
457+
avg->time_stamps[i] = ts64.tv_sec;
457458
}
458459

459460
avg->pos = 0;

‎drivers/power/bq2415x_charger.c‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,15 @@ static int bq2415x_probe(struct i2c_client *client,
15791579
if (np) {
15801580
bq->notify_psy = power_supply_get_by_phandle(np, "ti,usb-charger-detection");
15811581

1582-
if (!bq->notify_psy)
1583-
return -EPROBE_DEFER;
1582+
if (IS_ERR(bq->notify_psy)) {
1583+
dev_info(&client->dev,
1584+
"no 'ti,usb-charger-detection' property (err=%ld)\n",
1585+
PTR_ERR(bq->notify_psy));
1586+
bq->notify_psy = NULL;
1587+
} else if (!bq->notify_psy) {
1588+
ret = -EPROBE_DEFER;
1589+
goto error_2;
1590+
}
15841591
}
15851592
else if (pdata->notify_device)
15861593
bq->notify_psy = power_supply_get_by_name(pdata->notify_device);
@@ -1602,27 +1609,27 @@ static int bq2415x_probe(struct i2c_client *client,
16021609
ret = of_property_read_u32(np, "ti,current-limit",
16031610
&bq->init_data.current_limit);
16041611
if (ret)
1605-
return ret;
1612+
goto error_2;
16061613
ret = of_property_read_u32(np, "ti,weak-battery-voltage",
16071614
&bq->init_data.weak_battery_voltage);
16081615
if (ret)
1609-
return ret;
1616+
goto error_2;
16101617
ret = of_property_read_u32(np, "ti,battery-regulation-voltage",
16111618
&bq->init_data.battery_regulation_voltage);
16121619
if (ret)
1613-
return ret;
1620+
goto error_2;
16141621
ret = of_property_read_u32(np, "ti,charge-current",
16151622
&bq->init_data.charge_current);
16161623
if (ret)
1617-
return ret;
1624+
goto error_2;
16181625
ret = of_property_read_u32(np, "ti,termination-current",
16191626
&bq->init_data.termination_current);
16201627
if (ret)
1621-
return ret;
1628+
goto error_2;
16221629
ret = of_property_read_u32(np, "ti,resistor-sense",
16231630
&bq->init_data.resistor_sense);
16241631
if (ret)
1625-
return ret;
1632+
goto error_2;
16261633
} else {
16271634
memcpy(&bq->init_data, pdata, sizeof(bq->init_data));
16281635
}

0 commit comments

Comments
 (0)