Changeset 60af6fc2 in mainline


Ignore:
Timestamp:
2012-08-20T21:38:24Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c9abf50
Parents:
6f445a67
Message:

rtc: move boottime into the rtc structure

File:
1 edited

Legend:

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

    r6f445a67 r60af6fc2  
    7171        /** true if device is removed */
    7272        bool removed;
     73        /** time at which the system booted */
     74        time_t boottime;
    7375} rtc_t;
    7476
     
    9496
    9597static ddf_dev_ops_t rtc_dev_ops;
    96 static time_t boottime = 0;
    9798
    9899/** The RTC device driver's standard operations */
     
    298299        rtc_t *rtc = fun_rtc(fun);
    299300
    300         if (boottime != 0) {
     301        fibril_mutex_lock(&rtc->mutex);
     302
     303        if (rtc->boottime != 0) {
    301304                /* There is no need to read the current time from the
    302305                 * device because it has already been cached.
    303306                 */
    304307
    305                 time_t cur_time = boottime + uptime_get();
     308                time_t cur_time = rtc->boottime + uptime_get();
     309
     310                fibril_mutex_unlock(&rtc->mutex);
     311
    306312                return localtime2tm(cur_time, t);
    307313        }
     
    372378        }
    373379
    374         fibril_mutex_unlock(&rtc->mutex);
    375 
    376380        /* Try to normalize the content of the tm structure */
    377381        time_t r = mktime(t);
    378382
    379         boottime = r - uptime_get();
     383        rtc->boottime = r - uptime_get();
     384
     385        fibril_mutex_unlock(&rtc->mutex);
    380386
    381387        return r < 0 ? EINVAL : EOK;
     
    410416        }
    411417
     418        fibril_mutex_lock(&rtc->mutex);
     419
    412420        /* boottime must be recomputed */
    413         boottime = 0;
    414 
    415         fibril_mutex_lock(&rtc->mutex);
     421        rtc->boottime = 0;
    416422
    417423        /* Detect the RTC epoch */
Note: See TracChangeset for help on using the changeset viewer.