Changeset c99d470 in mainline


Ignore:
Timestamp:
2012-09-23T16:27:53Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f3b97d1
Parents:
0d8322da (diff), 0a586f4c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:rtc-helenos.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/time/cmos-rtc/cmos-rtc.c

    r0d8322da rc99d470  
    9999static void rtc_register_write(rtc_t *rtc, int reg, int data);
    100100static time_t uptime_get(void);
     101static bool is_battery_ok(rtc_t *rtc);
    101102
    102103static ddf_dev_ops_t rtc_dev_ops;
     
    334335        }
    335336
     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
    336343        /* now read the registers */
    337344        do {
     
    436443
    437444        fibril_mutex_lock(&rtc->mutex);
     445
     446        if (!is_battery_ok(rtc)) {
     447                fibril_mutex_unlock(&rtc->mutex);
     448                return EIO;
     449        }
    438450
    439451        /* boottime must be recomputed */
     
    516528{
    517529        rtc_t *rtc = fun_rtc(fun);
    518         const bool batt_ok = rtc_register_read(rtc, RTC_STATUS_D) &
    519             RTC_D_BATTERY_OK;
     530
     531        fibril_mutex_lock(&rtc->mutex);
     532        const bool batt_ok = is_battery_ok(rtc);
     533        fibril_mutex_unlock(&rtc->mutex);
    520534
    521535        *status = batt_ok ? BATTERY_OK : BATTERY_LOW;
    522536
    523537        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 */
     547static bool
     548is_battery_ok(rtc_t *rtc)
     549{
     550        return rtc_register_read(rtc, RTC_STATUS_D) & RTC_D_BATTERY_OK;
    524551}
    525552
Note: See TracChangeset for help on using the changeset viewer.