From a427c4297921818127f256849f475a00c9d383fe Mon Sep 17 00:00:00 2001 From: Jianhong Chen Date: Tue, 13 Jun 2017 15:17:39 +0800 Subject: [PATCH] power: rk818-battery: add notify to broadcast battery temperature Change-Id: I2ee392f1885e87b0398eaff5ab7d0a0c89527e93 Signed-off-by: Jianhong Chen --- drivers/power/rk818_battery.c | 18 ++++++++++++++++++ drivers/power/rk818_battery.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/power/rk818_battery.c b/drivers/power/rk818_battery.c index 3957843af38d..f2a07fd05841 100644 --- a/drivers/power/rk818_battery.c +++ b/drivers/power/rk818_battery.c @@ -2511,6 +2511,23 @@ static int rk818_bat_get_ntc_res(struct rk818_battery *di) return val; } +static BLOCKING_NOTIFIER_HEAD(rk818_bat_notifier_chain); + +int rk818_bat_temp_notifier_register(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&rk818_bat_notifier_chain, nb); +} + +int rk818_bat_temp_notifier_unregister(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&rk818_bat_notifier_chain, nb); +} + +static void rk818_bat_temp_notifier_callback(int temp) +{ + blocking_notifier_call_chain(&rk818_bat_notifier_chain, temp, NULL); +} + static void rk818_bat_update_temperature(struct rk818_battery *di) { u32 ntc_size, *ntc_table; @@ -2532,6 +2549,7 @@ static void rk818_bat_update_temperature(struct rk818_battery *di) break; } di->temperature = (i + di->pdata->ntc_degree_from) * 10; + rk818_bat_temp_notifier_callback(di->temperature / 10); } } } diff --git a/drivers/power/rk818_battery.h b/drivers/power/rk818_battery.h index 267c20aa0845..a1deaf34e73e 100644 --- a/drivers/power/rk818_battery.h +++ b/drivers/power/rk818_battery.h @@ -158,5 +158,7 @@ static const u16 chrg_cur_input_array[] = { }; void kernel_power_off(void); +int rk818_bat_temp_notifier_register(struct notifier_block *nb); +int rk818_bat_temp_notifier_unregister(struct notifier_block *nb); #endif -- 2.34.1