Changeset f30ee571 in mainline


Ignore:
Timestamp:
2012-04-03T09:15:30Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3b79ba5
Parents:
010341d
Message:

rtc: add the rtc_update_in_progress() function

File:
1 edited

Legend:

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

    r010341d rf30ee571  
    3838#include <errno.h>
    3939#include <ddi.h>
     40#include <libarch/ddi.h>
    4041#include <stdio.h>
    4142#include <ddf/driver.h>
     
    4546#include <device/hw_res.h>
    4647#include <devman.h>
     48
     49#include "cmos-regs.h"
    4750
    4851#define NAME "cmos-rtc"
     
    7679static int  rtc_open(ddf_fun_t *fun);
    7780static void rtc_close(ddf_fun_t *fun);
     81static bool rtc_update_in_progress(rtc_t *rtc);
    7882
    7983
     
    218222}
    219223
     224/** Check if an update is in progress
     225 *
     226 * @param rtc  The rtc device
     227 *
     228 * @return  true if an update is in progress, false otherwise
     229 */
     230static bool
     231rtc_update_in_progress(rtc_t *rtc)
     232{
     233        pio_write_8(rtc->port, RTC_UPDATE);
     234        return pio_read_8(rtc->port + 1) & RTC_MASK_UPDATE;
     235}
     236
    220237/** Read the current time from the CMOS
    221238 *
     
    228245rtc_time_get(ddf_fun_t *fun, struct tm *t)
    229246{
     247        rtc_t *rtc = RTC_FROM_FNODE(fun);
     248
     249        fibril_mutex_lock(&rtc->mutex);
     250
     251        while (rtc_update_in_progress(rtc));
     252
     253        fibril_mutex_unlock(&rtc->mutex);
    230254        return EOK;
    231255}
Note: See TracChangeset for help on using the changeset viewer.