Changeset d371a97 in rtems for c/src/libchip/rtc


Ignore:
Timestamp:
Nov 21, 2007, 6:23:12 AM (12 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, 4.9, master
Children:
5a8e5df7
Parents:
d2ff24c2
Message:

2007-11-20 Till Straumann <strauman@…>

  • libchip/rtc/ds1375.c, libchip/rtc/ds1375-rtc.h: Avoid using 'stdio' before the system is up and fully initialized.
Location:
c/src/libchip/rtc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/libchip/rtc/ds1375-rtc.h

    rd2ff24c2 rd371a97  
    7272 * the registered device name of the raw i2c device (created with mknod).
    7373 * E.g., "/dev/i2c.ds1375-raw"
     74 *
     75 * NOTE: The i2c bus driver must already be up and 'i2cname' already
     76 *       be available when this ENTRY is registered or initialized.
     77 *
     78 *       If you want to allow applications to add the RTC driver to
     79 *       the configuration table then the i2c subsystem must be
     80 *       initialized by the BSP from the predriver_hook.
    7481 */
    7582#define DS1375_RTC_TBL_ENTRY(i2cname) \
  • c/src/libchip/rtc/ds1375.c

    rd2ff24c2 rd371a97  
    5555
    5656#include <sys/fcntl.h>
     57#include <sys/errno.h>
    5758#include <stdio.h>
    5859#include <inttypes.h>
     
    6162#define STATIC static
    6263#undef  DEBUG
     64
     65/* The RTC driver routines are possibly called during
     66 * system initialization -- that would be prior to opening
     67 * the console. At this point it is not safe to use stdio
     68 * (printf, perror etc.).
     69 * Our file descriptors may even be 0..2
     70 */
     71#define STDIOSAFE(fmt,args...)          \
     72        do {                                \
     73                if ( _System_state_Is_up( _System_state_Get() ) ) { \
     74                        fprintf(stderr,fmt,args);   \
     75                } else {                        \
     76                        printk(fmt,args);           \
     77                }                               \
     78        } while (0)
     79 
    6380
    6481STATIC uint8_t ds1375_bcd2bin(uint8_t x)
     
    400417
    401418        if ( ( fd = getfd( minor ) ) < 0 ) {
    402                 perror("ds1375_probe (open)");
     419                STDIOSAFE( "ds1375_probe (open): %s\n", strerror( errno ) );
    403420                return FALSE;
    404421        }
     
    406423        /* Try to set file pointer */
    407424        if ( 0 != wr_bytes( fd, DS1375_SEC_REG, 0, 0 ) ) {
    408                 perror( "ds1375_probe (wr_bytes)" );
     425                STDIOSAFE( "ds1375_probe (wr_bytes): %s\n", strerror( errno ) );
    409426                close( fd );
    410427                return FALSE;
     
    412429
    413430        if ( close( fd ) ) {
    414                 perror( "ds1375_probe (close)" );
     431                STDIOSAFE( "ds1375_probe (close): %s\n", strerror( errno ) );
    415432                return FALSE;
    416433        }
Note: See TracChangeset for help on using the changeset viewer.