2009-05-03 Joel Sherrill <joel.sherrill@oarcorp.com>

* libchip/rtc/ds1375.c, libchip/rtc/mc146818a.c: Fix warnings. Reformat
	as needed.
This commit is contained in:
Joel Sherrill
2009-05-04 00:53:45 +00:00
parent 81fb3d3646
commit 9c2eacafea
3 changed files with 255 additions and 236 deletions

View File

@@ -1,3 +1,8 @@
2009-05-03 Joel Sherrill <joel.sherrill@oarcorp.com>
* libchip/rtc/ds1375.c, libchip/rtc/mc146818a.c: Fix warnings. Reformat
as needed.
2009-04-29 Chris Johns <chrisj@rtems.org>
* libchip/ide/ata.c: Remove a detection test that fails in qemu.

View File

@@ -82,7 +82,7 @@
STATIC uint8_t ds1375_bcd2bin(uint8_t x)
{
uint8_t h = x & 0xf0;
uint8_t h = x & 0xf0;
/* 8*hi + 2*hi + lo */
return ( h >> 1 ) + ( h >> 3 ) + ( x & 0xf );
@@ -90,7 +90,7 @@ uint8_t h = x & 0xf0;
STATIC uint8_t ds1375_bin2bcd(uint8_t x)
{
uint8_t h = x/10;
uint8_t h = x/10;
return ( h << 4 ) + ( x - ( ( h << 3 ) + ( h << 1 ) ) );
}
@@ -103,8 +103,6 @@ uint8_t h = x/10;
* starting at the seconds (for the 1375 both,
* _REG and _OFF happen to be identical).
*/
#define DS1375_SEC_REG 0x0
#define DS1375_SEC_OFF (DS1375_SEC_REG-DS1375_SEC_REG)
/* Extract seconds and convert to binary */
@@ -165,18 +163,26 @@ uint8_t h = x/10;
/* Access Primitives */
STATIC int
rd_bytes( int fd, uint32_t off, uint8_t *buf, int len )
STATIC int rd_bytes(
int fd,
uint32_t off,
uint8_t *buf,
int len
)
{
uint8_t ptr = off;
uint8_t ptr = off;
return 1 == write( fd, &ptr, 1 ) && len == read( fd, buf, len ) ? 0 : -1;
}
STATIC int
wr_bytes( int fd, uint32_t off, uint8_t *buf, int len )
STATIC int wr_bytes(
int fd,
uint32_t off,
uint8_t *buf,
int len
)
{
uint8_t d[ len + 1 ];
uint8_t d[ len + 1 ];
/* Must not break up writing of the register pointer and
* the data to-be-written into multiple write() calls
@@ -193,19 +199,21 @@ uint8_t d[ len + 1 ];
/* Helpers */
static int
getfd( int minor )
static int getfd(
int minor
)
{
return open( (const char *)RTC_Table[minor].ulCtrlPort1, O_RDWR );
}
/* Driver Access Functions */
STATIC void
ds1375_initialize( int minor )
STATIC void ds1375_initialize(
int minor
)
{
int fd;
uint8_t cr;
int fd;
uint8_t cr;
if ( ( fd = getfd( minor ) ) >= 0 ) {
if ( 0 == rd_bytes( fd, DS1375_CR_REG, &cr, 1 ) ) {
@@ -220,12 +228,14 @@ uint8_t cr;
}
STATIC int
ds1375_get_time( int minor, rtems_time_of_day *time )
STATIC int ds1375_get_time(
int minor,
rtems_time_of_day *time
)
{
int rval = -1;
int fd;
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
int rval = -1;
int fd;
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
if ( time && ( ( fd = getfd( minor ) ) >= 0 ) ) {
if ( 0 == rd_bytes( fd, DS1375_SEC_REG, buf, sizeof(buf) ) ) {
@@ -252,15 +262,18 @@ uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
return rval;
}
STATIC int
ds1375_set_time( int minor, rtems_time_of_day *time )
STATIC int ds1375_set_time(
int minor,
const rtems_time_of_day *time
)
{
int rval = -1;
int fd = -1;
time_t secs;
struct tm tm;
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
uint8_t cr = 0xff;
int rval = -1;
int fd = -1;
time_t secs;
struct tm tm;
uint8_t buf[DS1375_YR_REG + 1 - DS1375_SEC_REG];
uint8_t cr = 0xff;
/*
* The clock hardware maintains the day-of-week as a separate counter
* so we must compute it ourselves (rtems_time_of_day doesn't come
@@ -412,10 +425,11 @@ uint8_t v = value;
}
bool
rtc_ds1375_device_probe( int minor )
bool rtc_ds1375_device_probe(
int minor
)
{
int fd;
int fd;
if ( ( fd = getfd( minor ) ) < 0 ) {
STDIOSAFE( "ds1375_probe (open): %s\n", strerror( errno ) );

View File

@@ -135,7 +135,7 @@ int mc146818a_get_time(
*/
int mc146818a_set_time(
int minor,
rtems_time_of_day *time
const rtems_time_of_day *time
)
{
uint32_t mc146818a;