| .. | .. |
|---|
| 172 | 172 | struct wake_lock wake_lock; |
|---|
| 173 | 173 | struct notifier_block fb_nb; |
|---|
| 174 | 174 | struct timer_list caltimer; |
|---|
| 175 | | - time_t rtc_base; |
|---|
| 175 | + time64_t rtc_base; |
|---|
| 176 | 176 | struct iio_channel *iio_chan; |
|---|
| 177 | 177 | struct notifier_block cable_cg_nb; |
|---|
| 178 | 178 | struct notifier_block cable_host_nb; |
|---|
| .. | .. |
|---|
| 303 | 303 | |
|---|
| 304 | 304 | static u64 get_boot_sec(void) |
|---|
| 305 | 305 | { |
|---|
| 306 | | - struct timespec ts; |
|---|
| 306 | + struct timespec64 ts; |
|---|
| 307 | 307 | |
|---|
| 308 | | - get_monotonic_boottime(&ts); |
|---|
| 308 | + ktime_get_boottime_ts64(&ts); |
|---|
| 309 | 309 | |
|---|
| 310 | 310 | return ts.tv_sec; |
|---|
| 311 | 311 | } |
|---|
| .. | .. |
|---|
| 327 | 327 | { |
|---|
| 328 | 328 | u8 i; |
|---|
| 329 | 329 | u16 d; |
|---|
| 330 | + |
|---|
| 331 | + if (size < 2) |
|---|
| 332 | + return 0; |
|---|
| 330 | 333 | |
|---|
| 331 | 334 | for (i = 0; i < size; i++) { |
|---|
| 332 | 335 | if (value < table[i]) |
|---|
| .. | .. |
|---|
| 1873 | 1876 | struct rk816_battery *di; |
|---|
| 1874 | 1877 | struct fb_event *evdata = data; |
|---|
| 1875 | 1878 | |
|---|
| 1879 | + if (event != FB_EVENT_BLANK) |
|---|
| 1880 | + return NOTIFY_DONE; |
|---|
| 1881 | + |
|---|
| 1876 | 1882 | di = container_of(nb, struct rk816_battery, fb_nb); |
|---|
| 1883 | + di->fb_blank = *(int *)evdata->data; |
|---|
| 1877 | 1884 | |
|---|
| 1878 | | - if (event == FB_EVENT_BLANK || event == FB_EARLY_EVENT_BLANK || |
|---|
| 1879 | | - event == FB_R_EARLY_EVENT_BLANK) |
|---|
| 1880 | | - di->fb_blank = *(int *)evdata->data; |
|---|
| 1881 | | - else |
|---|
| 1882 | | - di->fb_blank = 1; |
|---|
| 1883 | | - |
|---|
| 1884 | | - return 0; |
|---|
| 1885 | + return NOTIFY_OK; |
|---|
| 1885 | 1886 | } |
|---|
| 1886 | 1887 | |
|---|
| 1887 | 1888 | static int rk816_bat_register_fb_notify(struct rk816_battery *di) |
|---|
| .. | .. |
|---|
| 2967 | 2968 | FINISH_CHRG_CUR2 : FINISH_CHRG_CUR1; |
|---|
| 2968 | 2969 | finish_sec = base2sec(di->chrg_finish_base); |
|---|
| 2969 | 2970 | soc_sec = di->fcc * 3600 / 100 / DIV(finish_current); |
|---|
| 2971 | + if (soc_sec == 0) |
|---|
| 2972 | + soc_sec = 1; |
|---|
| 2970 | 2973 | plus_soc = finish_sec / DIV(soc_sec); |
|---|
| 2971 | 2974 | if (finish_sec > soc_sec) { |
|---|
| 2972 | 2975 | rest = finish_sec % soc_sec; |
|---|
| .. | .. |
|---|
| 4352 | 4355 | return 0; |
|---|
| 4353 | 4356 | } |
|---|
| 4354 | 4357 | |
|---|
| 4355 | | -static time_t rk816_get_rtc_sec(void) |
|---|
| 4358 | +static time64_t rk816_get_rtc_sec(void) |
|---|
| 4356 | 4359 | { |
|---|
| 4357 | 4360 | int err; |
|---|
| 4358 | 4361 | struct rtc_time tm; |
|---|
| 4359 | | - struct timespec tv = { .tv_nsec = NSEC_PER_SEC >> 1, }; |
|---|
| 4360 | 4362 | struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); |
|---|
| 4361 | | - time_t sec; |
|---|
| 4362 | 4363 | |
|---|
| 4363 | 4364 | err = rtc_read_time(rtc, &tm); |
|---|
| 4364 | 4365 | if (err) { |
|---|
| .. | .. |
|---|
| 4372 | 4373 | return 0; |
|---|
| 4373 | 4374 | } |
|---|
| 4374 | 4375 | |
|---|
| 4375 | | - rtc_tm_to_time(&tm, &tv.tv_sec); |
|---|
| 4376 | | - sec = tv.tv_sec; |
|---|
| 4377 | | - |
|---|
| 4378 | | - return sec; |
|---|
| 4376 | + return rtc_tm_to_time64(&tm); |
|---|
| 4379 | 4377 | } |
|---|
| 4380 | 4378 | |
|---|
| 4381 | 4379 | static int rk816_bat_rtc_sleep_sec(struct rk816_battery *di) |
|---|
| .. | .. |
|---|
| 4678 | 4676 | } |
|---|
| 4679 | 4677 | |
|---|
| 4680 | 4678 | pdata->ocv_size = length / sizeof(u32); |
|---|
| 4681 | | - if (pdata->ocv_size <= 0) { |
|---|
| 4679 | + if (pdata->ocv_size < 2) { |
|---|
| 4682 | 4680 | dev_err(dev, "invalid ocv table\n"); |
|---|
| 4683 | 4681 | return -EINVAL; |
|---|
| 4684 | 4682 | } |
|---|