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


Ignore:
Timestamp:
2012-04-04T20:22:20Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2a4c22d
Parents:
f87ea202
Message:

rtc: Add an option to the default handler to get the status of the clock's battery

File:
1 edited

Legend:

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

    rf87ea202 rd8a4e79  
    4646#include <device/hw_res.h>
    4747#include <devman.h>
     48#include <ipc/clock_ctl.h>
    4849
    4950#include "cmos-regs.h"
     
    8283static int  rtc_register_read(rtc_t *rtc, int reg);
    8384static int  bcd2dec(int bcd);
     85static void rtc_default_handler(ddf_fun_t *fun,
     86    ipc_callid_t callid, ipc_call_t *call);
    8487
    8588
     
    114117
    115118        rtc_dev_ops.interfaces[CLOCK_DEV_IFACE] = &rtc_clock_dev_ops;
    116         rtc_dev_ops.default_handler = NULL; /* XXX */
     119        rtc_dev_ops.default_handler = &rtc_default_handler;
    117120}
    118121
     
    387390}
    388391
     392/** Default handler for client requests not handled
     393 *  by the standard interface
     394 */
     395static void
     396rtc_default_handler(ddf_fun_t *fun, ipc_callid_t callid, ipc_call_t *call)
     397{
     398        sysarg_t method = IPC_GET_IMETHOD(*call);
     399        rtc_t *rtc = RTC_FROM_FNODE(fun);
     400        bool batt_ok;
     401
     402        switch (method) {
     403        case CLOCK_GET_BATTERY_STATUS:
     404                batt_ok = !(rtc_register_read(rtc, RTC_STATUS_D) &
     405                    RTC_BATTERY_OK);
     406                async_answer_1(callid, EOK, batt_ok);
     407                break;
     408        default:
     409                async_answer_0(callid, ENOTSUP);
     410        }
     411}
     412
    389413/** Open the device
    390414 *
Note: See TracChangeset for help on using the changeset viewer.