Changeset 9673fd3 in mainline for uspace/drv/time/cmos-rtc/cmos-rtc.c


Ignore:
Timestamp:
2012-08-23T11:50:07Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ae827d0
Parents:
2e6293b
Message:

rtc: add support to offline/online operations

File:
1 edited

Legend:

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

    r2e6293b r9673fd3  
    7171        /** true if device is removed */
    7272        bool removed;
     73        /** number of connected clients */
     74        int clients_connected;
    7375        /** time at which the system booted */
    7476        time_t boottime;
     
    189191
    190192        rtc->boottime = 0;
     193        rtc->clients_connected = 0;
    191194
    192195        hw_resource_list_t hw_resources;
     
    565568
    566569        fibril_mutex_lock(&rtc->mutex);
     570        if (rtc->clients_connected > 0) {
     571                fibril_mutex_unlock(&rtc->mutex);
     572                return EBUSY;
     573        }
    567574
    568575        rtc->removed = true;
     
    619626        if (rtc->removed)
    620627                rc = ENXIO;
    621         else
     628        else {
    622629                rc = EOK;
     630                rtc->clients_connected++;
     631        }
    623632
    624633        fibril_mutex_unlock(&rtc->mutex);
     
    633642rtc_close(ddf_fun_t *fun)
    634643{
     644        rtc_t *rtc = fun_rtc(fun);
     645
     646        fibril_mutex_lock(&rtc->mutex);
     647
     648        rtc->clients_connected--;
     649        assert(rtc->clients_connected >= 0);
     650
     651        fibril_mutex_unlock(&rtc->mutex);
    635652}
    636653
Note: See TracChangeset for help on using the changeset viewer.