From 1543e317f1da31b75942316931e8f491a8920811 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Thu, 04 Jan 2024 10:08:02 +0000
Subject: [PATCH] disable FB
---
kernel/drivers/power/supply/rk816_battery.c | 34 ++++++++++++++++------------------
1 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/kernel/drivers/power/supply/rk816_battery.c b/kernel/drivers/power/supply/rk816_battery.c
index 0a5abc3..1e4f6cd 100644
--- a/kernel/drivers/power/supply/rk816_battery.c
+++ b/kernel/drivers/power/supply/rk816_battery.c
@@ -172,7 +172,7 @@
struct wake_lock wake_lock;
struct notifier_block fb_nb;
struct timer_list caltimer;
- time_t rtc_base;
+ time64_t rtc_base;
struct iio_channel *iio_chan;
struct notifier_block cable_cg_nb;
struct notifier_block cable_host_nb;
@@ -303,9 +303,9 @@
static u64 get_boot_sec(void)
{
- struct timespec ts;
+ struct timespec64 ts;
- get_monotonic_boottime(&ts);
+ ktime_get_boottime_ts64(&ts);
return ts.tv_sec;
}
@@ -327,6 +327,9 @@
{
u8 i;
u16 d;
+
+ if (size < 2)
+ return 0;
for (i = 0; i < size; i++) {
if (value < table[i])
@@ -1873,15 +1876,13 @@
struct rk816_battery *di;
struct fb_event *evdata = data;
+ if (event != FB_EVENT_BLANK)
+ return NOTIFY_DONE;
+
di = container_of(nb, struct rk816_battery, fb_nb);
+ di->fb_blank = *(int *)evdata->data;
- if (event == FB_EVENT_BLANK || event == FB_EARLY_EVENT_BLANK ||
- event == FB_R_EARLY_EVENT_BLANK)
- di->fb_blank = *(int *)evdata->data;
- else
- di->fb_blank = 1;
-
- return 0;
+ return NOTIFY_OK;
}
static int rk816_bat_register_fb_notify(struct rk816_battery *di)
@@ -2967,6 +2968,8 @@
FINISH_CHRG_CUR2 : FINISH_CHRG_CUR1;
finish_sec = base2sec(di->chrg_finish_base);
soc_sec = di->fcc * 3600 / 100 / DIV(finish_current);
+ if (soc_sec == 0)
+ soc_sec = 1;
plus_soc = finish_sec / DIV(soc_sec);
if (finish_sec > soc_sec) {
rest = finish_sec % soc_sec;
@@ -4352,13 +4355,11 @@
return 0;
}
-static time_t rk816_get_rtc_sec(void)
+static time64_t rk816_get_rtc_sec(void)
{
int err;
struct rtc_time tm;
- struct timespec tv = { .tv_nsec = NSEC_PER_SEC >> 1, };
struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
- time_t sec;
err = rtc_read_time(rtc, &tm);
if (err) {
@@ -4372,10 +4373,7 @@
return 0;
}
- rtc_tm_to_time(&tm, &tv.tv_sec);
- sec = tv.tv_sec;
-
- return sec;
+ return rtc_tm_to_time64(&tm);
}
static int rk816_bat_rtc_sleep_sec(struct rk816_battery *di)
@@ -4678,7 +4676,7 @@
}
pdata->ocv_size = length / sizeof(u32);
- if (pdata->ocv_size <= 0) {
+ if (pdata->ocv_size < 2) {
dev_err(dev, "invalid ocv table\n");
return -EINVAL;
}
--
Gitblit v1.6.2