Changeset 850235d in mainline for uspace/drv/time/cmos-rtc/cmos-rtc.c


Ignore:
Timestamp:
2013-03-10T14:56:21Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
05bab88
Parents:
ea906c29 (diff), 2277e03 (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 mainline changes

File:
1 edited

Legend:

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

    rea906c29 r850235d  
    4040#include <as.h>
    4141#include <sysinfo.h>
    42 #include <libarch/ddi.h>
    4342#include <libarch/barrier.h>
    4443#include <stdio.h>
     
    10099static time_t uptime_get(void);
    101100static bool is_battery_ok(rtc_t *rtc);
     101static int  rtc_fun_online(ddf_fun_t *fun);
     102static int  rtc_fun_offline(ddf_fun_t *fun);
    102103
    103104static ddf_dev_ops_t rtc_dev_ops;
     
    107108        .dev_add = rtc_dev_add,
    108109        .dev_remove = rtc_dev_remove,
     110        .fun_online = rtc_fun_online,
     111        .fun_offline = rtc_fun_offline,
    109112};
    110113
     
    406409        /* Try to normalize the content of the tm structure */
    407410        time_t r = mktime(t);
    408 
    409         rtc->boottime = r - uptime_get();
     411        int result;
     412
     413        if (r < 0)
     414                result = EINVAL;
     415        else {
     416                rtc->boottime = r - uptime_get();
     417                result = EOK;
     418        }
    410419
    411420        fibril_mutex_unlock(&rtc->mutex);
    412421
    413         return r < 0 ? EINVAL : EOK;
     422        return result;
    414423}
    415424
     
    638647        fibril_mutex_unlock(&rtc->mutex);
    639648
     649        rc = rtc_fun_offline(rtc->fun);
     650        if (rc != EOK) {
     651                ddf_msg(LVL_ERROR, "Failed to offline function");
     652                return rc;
     653        }
     654
    640655        rc = ddf_fun_unbind(rtc->fun);
    641656        if (rc != EOK) {
     
    726741}
    727742
     743static int
     744rtc_fun_online(ddf_fun_t *fun)
     745{
     746        int rc;
     747
     748        ddf_msg(LVL_DEBUG, "rtc_fun_online()");
     749
     750        rc = ddf_fun_online(fun);
     751        if (rc == EOK)
     752                ddf_fun_add_to_category(fun, "clock");
     753
     754        return rc;
     755}
     756
     757static int
     758rtc_fun_offline(ddf_fun_t *fun)
     759{
     760        ddf_msg(LVL_DEBUG, "rtc_fun_offline()");
     761        return ddf_fun_offline(fun);
     762}
     763
    728764int
    729765main(int argc, char **argv)
Note: See TracChangeset for help on using the changeset viewer.