power: rk818-battery: add notify to broadcast battery temperature
authorJianhong Chen <chenjh@rock-chips.com>
Tue, 13 Jun 2017 07:17:39 +0000 (15:17 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 21 Jun 2017 06:07:01 +0000 (14:07 +0800)
Change-Id: I2ee392f1885e87b0398eaff5ab7d0a0c89527e93
Signed-off-by: Jianhong Chen <chenjh@rock-chips.com>
drivers/power/rk818_battery.c
drivers/power/rk818_battery.h

index 3957843af38dc6851cb317ed839805ce36545ad9..f2a07fd05841b164ed6c2e1063fa911fbb5fbf3e 100644 (file)
@@ -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);
                }
        }
 }
index 267c20aa0845fb4da9b00df2d51eff450e9da41b..a1deaf34e73e6d37016502ff6e50d6763c93f6c2 100644 (file)
@@ -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