Ignore:
Timestamp:
2012-04-04T18:33:56Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1abd6e
Parents:
8354ca6
Message:

rtc: add the remote_clock_time_set implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_clock_dev.c

    r8354ca6 raeb49e9  
    4242static void remote_clock_time_get(ddf_fun_t *, void *, ipc_callid_t,
    4343    ipc_call_t *);
    44 /*
    4544static void remote_clock_time_set(ddf_fun_t *, void *, ipc_callid_t,
    4645    ipc_call_t *);
    47 */
    4846
    4947/** Remote clock interface operations */
    5048static remote_iface_func_ptr_t remote_clock_dev_iface_ops[] = {
    5149        &remote_clock_time_get,
    52         /* XXX &remote_clock_time_set, */
     50        &remote_clock_time_set,
    5351};
    5452
     
    105103}
    106104
    107 /* TODO: remote_clock_time_set() */
     105/** Process the write request from the remote client
     106 *
     107 * @param fun   The function to which the data are written
     108 * @param ops   The local ops structure
     109 */
     110static void remote_clock_time_set(ddf_fun_t *fun, void *ops,
     111    ipc_callid_t callid, ipc_call_t *call)
     112{
     113        clock_dev_ops_t *clock_dev_ops = (clock_dev_ops_t *) ops;
     114        int          rc;
     115        struct tm    t;
     116        ipc_callid_t cid;
     117        size_t       len;
     118
     119        if (!async_data_write_receive(&cid, &len)) {
     120                /* TODO: Handle protocol error */
     121                async_answer_0(callid, EINVAL);
     122                return;
     123        }
     124
     125        if (!clock_dev_ops->time_set) {
     126                /* The driver does not support the time_set() functionality */
     127                async_data_write_finalize(cid, NULL, 0);
     128                async_answer_0(callid, ENOTSUP);
     129                return;
     130        }
     131
     132        async_data_write_finalize(cid, &t, sizeof(struct tm));
     133
     134        rc = (*clock_dev_ops->time_set)(fun, &t);
     135        if (rc < 0) {
     136                /* Some error occurred */
     137                async_answer_0(callid, rc);
     138                return;
     139        }
     140
     141        async_answer_1(callid, EOK, rc);
     142}
    108143
    109144/**
Note: See TracChangeset for help on using the changeset viewer.