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


Ignore:
Timestamp:
2012-11-21T23:26:22Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0f2c80a
Parents:
bebf97d (diff), 1f7753a (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:

Mainline changes.

File:
1 edited

Legend:

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

    rbebf97d rc739102  
    9999static time_t uptime_get(void);
    100100static 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);
    101103
    102104static ddf_dev_ops_t rtc_dev_ops;
     
    106108        .dev_add = rtc_dev_add,
    107109        .dev_remove = rtc_dev_remove,
     110        .fun_online = rtc_fun_online,
     111        .fun_offline = rtc_fun_offline,
    108112};
    109113
     
    405409        /* Try to normalize the content of the tm structure */
    406410        time_t r = mktime(t);
    407 
    408         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        }
    409419
    410420        fibril_mutex_unlock(&rtc->mutex);
    411421
    412         return r < 0 ? EINVAL : EOK;
     422        return result;
    413423}
    414424
     
    637647        fibril_mutex_unlock(&rtc->mutex);
    638648
     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
    639655        rc = ddf_fun_unbind(rtc->fun);
    640656        if (rc != EOK) {
     
    725741}
    726742
     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
    727764int
    728765main(int argc, char **argv)
Note: See TracChangeset for help on using the changeset viewer.