summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJianhong Chen <chenjh@rock-chips.com>2017-06-13 15:17:39 +0800
committerHuang, Tao <huangtao@rock-chips.com>2017-06-21 14:07:01 +0800
commita427c4297921818127f256849f475a00c9d383fe (patch)
tree8ffcd0d8339189947e559c87380da4c145768ced /drivers
parent610e4df92cf963cf895f6e72ab1655e8f29f3b2c (diff)
power: rk818-battery: add notify to broadcast battery temperature
Change-Id: I2ee392f1885e87b0398eaff5ab7d0a0c89527e93 Signed-off-by: Jianhong Chen <chenjh@rock-chips.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/rk818_battery.c18
-rw-r--r--drivers/power/rk818_battery.h2
2 files changed, 20 insertions, 0 deletions
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