Changes in uspace/drv/time/cmos-rtc/cmos-rtc.c [0a586f4c:289fa65] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/cmos-rtc/cmos-rtc.c
r0a586f4c r289fa65 99 99 static void rtc_register_write(rtc_t *rtc, int reg, int data); 100 100 static time_t uptime_get(void); 101 static bool is_battery_ok(rtc_t *rtc);102 101 103 102 static ddf_dev_ops_t rtc_dev_ops; … … 335 334 } 336 335 337 /* Check if the RTC battery is OK */338 if (!is_battery_ok(rtc)) {339 fibril_mutex_unlock(&rtc->mutex);340 return EIO;341 }342 343 336 /* now read the registers */ 344 337 do { … … 443 436 444 437 fibril_mutex_lock(&rtc->mutex); 445 446 if (!is_battery_ok(rtc)) {447 fibril_mutex_unlock(&rtc->mutex);448 return EIO;449 }450 438 451 439 /* boottime must be recomputed */ … … 528 516 { 529 517 rtc_t *rtc = fun_rtc(fun); 530 531 fibril_mutex_lock(&rtc->mutex); 532 const bool batt_ok = is_battery_ok(rtc); 533 fibril_mutex_unlock(&rtc->mutex); 518 const bool batt_ok = rtc_register_read(rtc, RTC_STATUS_D) & 519 RTC_D_BATTERY_OK; 534 520 535 521 *status = batt_ok ? BATTERY_OK : BATTERY_LOW; 536 522 537 523 return EOK; 538 }539 540 /** Check if the battery is working properly or not.541 * The caller already holds the rtc->mutex lock.542 *543 * @param rtc The RTC instance.544 *545 * @return true if the battery is ok, false otherwise.546 */547 static bool548 is_battery_ok(rtc_t *rtc)549 {550 return rtc_register_read(rtc, RTC_STATUS_D) & RTC_D_BATTERY_OK;551 524 } 552 525
Note:
See TracChangeset
for help on using the changeset viewer.