Replace BCD2BIN and BIN2BCD macros with inline functions
Subsystems (2)
PATCH 1/2 Replace BCD2BIN and BIN2BCD macros with inline functions
In the process, also remove backward-compatiblity macros BIN_TO_BCD and BCD_TO_BIN and update the sole board using them to use the new bin2bcd and bcd2bin instead
--- board/rsdproto/rsdproto.c | 17 ++++++++--------- drivers/rtc/m41t62.c | 24 ++++++++++++------------ drivers/rtc/rtc4543.c | 28 ++++++++++++++-------------- drivers/rtc/s3c44b0_rtc.c | 42 +++++++++++++++++++++--------------------- drivers/rtc/x1205.c | 28 ++++++++++++++-------------- include/bcd.h | 19 ++++++++++++------- include/linux/mc146818rtc.h | 12 ------------ 7 files changed, 81 insertions(+), 89 deletions(-)
board/rsdproto/rsdproto.c +8 -9
@@ -26,6 +26,7 @@#include <ioports.h> #include <mpc8260.h> #include <i2c.h> +#include <bcd.h> /* define to initialise the SDRAM on the local bus */ #undef INIT_LOCAL_BUS_SDRAM
@@ -208,16 +209,14 @@ void read_RS5C372_time (struct tm *timedate) {unsigned char buffer[8 ]; -#define BCD_TO_BIN (val) ((val)=((val)&15) + ((val)>>4)*10) -if (!i2c_read (RS5C372_PPC_I2C_ADR ,0 ,1 , buffer,sizeof (buffer))) { - timedate->tm_sec =BCD_TO_BIN (buffer[0 ]); - timedate->tm_min =BCD_TO_BIN (buffer[1 ]); - timedate->tm_hour =BCD_TO_BIN (buffer[2 ]); - timedate->tm_wday =BCD_TO_BIN (buffer[3 ]); - timedate->tm_mday =BCD_TO_BIN (buffer[4 ]); - timedate->tm_mon =BCD_TO_BIN (buffer[5 ]); - timedate->tm_year =BCD_TO_BIN (buffer[6 ]) +2000 ; + timedate->tm_sec =bcd2bin (buffer[0 ]); + timedate->tm_min =bcd2bin (buffer[1 ]); + timedate->tm_hour =bcd2bin (buffer[2 ]); + timedate->tm_wday =bcd2bin (buffer[3 ]); + timedate->tm_mday =bcd2bin (buffer[4 ]); + timedate->tm_mon =bcd2bin (buffer[5 ]); + timedate->tm_year =bcd2bin (buffer[6 ]) +2000 ; }else {/*printf("i2c error %02x\n", rc); */ memset (timedate,0 ,sizeof (struct tm ));
drivers/rtc/m41t62.c +12 -12
@@ -76,16 +76,16 @@ int rtc_get(struct rtc_time *tm) buf[0 ], buf[1 ], buf[2 ], buf[3 ], buf[4], buf[5], buf[6], buf[7]); - tm->tm_sec =BCD2BIN (buf[M41T62_REG_SEC ] &0x7f ); - tm->tm_min =BCD2BIN (buf[M41T62_REG_MIN ] &0x7f ); - tm->tm_hour =BCD2BIN (buf[M41T62_REG_HOUR ] &0x3f ); - tm->tm_mday =BCD2BIN (buf[M41T62_REG_DAY ] &0x3f ); + tm->tm_sec =bcd2bin (buf[M41T62_REG_SEC ] &0x7f ); + tm->tm_min =bcd2bin (buf[M41T62_REG_MIN ] &0x7f ); + tm->tm_hour =bcd2bin (buf[M41T62_REG_HOUR ] &0x3f ); + tm->tm_mday =bcd2bin (buf[M41T62_REG_DAY ] &0x3f ); tm->tm_wday = buf[M41T62_REG_WDAY ] &0x07 ; - tm->tm_mon =BCD2BIN (buf[M41T62_REG_MON ] &0x1f ); + tm->tm_mon =bcd2bin (buf[M41T62_REG_MON ] &0x1f );/* assume 20YY not 19YY, and ignore the Century Bit */ /* U-Boot needs to add 1900 here */ - tm->tm_year =BCD2BIN (buf[M41T62_REG_YEAR ]) +100 +1900 ; + tm->tm_year =bcd2bin (buf[M41T62_REG_YEAR ]) +100 +1900 ; debug("%s: tm is secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -109,19 +109,19 @@ int rtc_set(struct rtc_time *tm)/* Merge time-data and register flags into buf[0..7] */ buf[M41T62_REG_SSEC ] =0 ; buf[M41T62_REG_SEC ] = -BIN2BCD (tm->tm_sec) | (buf[M41T62_REG_SEC ] & ~0x7f ); +bin2bcd (tm->tm_sec) | (buf[M41T62_REG_SEC ] & ~0x7f ); buf[M41T62_REG_MIN ] = -BIN2BCD (tm->tm_min) | (buf[M41T62_REG_MIN ] & ~0x7f ); +bin2bcd (tm->tm_min) | (buf[M41T62_REG_MIN ] & ~0x7f ); buf[M41T62_REG_HOUR ] = -BIN2BCD (tm->tm_hour) | (buf[M41T62_REG_HOUR ] & ~0x3f ) ; +bin2bcd (tm->tm_hour) | (buf[M41T62_REG_HOUR ] & ~0x3f ) ; buf[M41T62_REG_WDAY ] = (tm->tm_wday &0x07 ) | (buf[M41T62_REG_WDAY ] & ~0x07 ); buf[M41T62_REG_DAY ] = -BIN2BCD (tm->tm_mday) | (buf[M41T62_REG_DAY ] & ~0x3f ); +bin2bcd (tm->tm_mday) | (buf[M41T62_REG_DAY ] & ~0x3f ); buf[M41T62_REG_MON ] = -BIN2BCD (tm->tm_mon) | (buf[M41T62_REG_MON ] & ~0x1f ); +bin2bcd (tm->tm_mon) | (buf[M41T62_REG_MON ] & ~0x1f );/* assume 20YY not 19YY */ - buf[M41T62_REG_YEAR ] =BIN2BCD (tm->tm_year %100 ); + buf[M41T62_REG_YEAR ] =bin2bcd (tm->tm_year %100 );if (i2c_write (CONFIG_SYS_I2C_RTC_ADDR ,0 ,1 , buf,M41T62_DATETIME_REG_SIZE )) {printf ("I2C write failed in %s()\n" , __func__);
drivers/rtc/rtc4543.c +14 -14
@@ -49,13 +49,13 @@ int rtc_get(struct rtc_time *tm)/* Read 52 bits into our buffer */ tws_read (buffer,52 ); - tm->tm_sec =BCD2BIN ( buffer[0 ] &0x7F ); - tm->tm_min =BCD2BIN ( buffer[1 ] &0x7F ); - tm->tm_hour =BCD2BIN ( buffer[2 ] &0x3F ); - tm->tm_wday =BCD2BIN ( buffer[3 ] &0x07 ); - tm->tm_mday =BCD2BIN ((buffer[3 ] &0xF0 ) >>4 | (buffer[4 ] &0x0F ) <<4 ); - tm->tm_mon =BCD2BIN ((buffer[4 ] &0x30 ) >>4 | (buffer[5 ] &0x0F ) <<4 ); - tm->tm_year =BCD2BIN ((buffer[5 ] &0xF0 ) >>4 | (buffer[6 ] &0x0F ) <<4 ) +2000 ; + tm->tm_sec =bcd2bin ( buffer[0 ] &0x7F ); + tm->tm_min =bcd2bin ( buffer[1 ] &0x7F ); + tm->tm_hour =bcd2bin ( buffer[2 ] &0x3F ); + tm->tm_wday =bcd2bin ( buffer[3 ] &0x07 ); + tm->tm_mday =bcd2bin ((buffer[3 ] &0xF0 ) >>4 | (buffer[4 ] &0x0F ) <<4 ); + tm->tm_mon =bcd2bin ((buffer[4 ] &0x30 ) >>4 | (buffer[5 ] &0x0F ) <<4 ); + tm->tm_year =bcd2bin ((buffer[5 ] &0xF0 ) >>4 | (buffer[6 ] &0x0F ) <<4 ) +2000 ; tm->tm_yday =0 ; tm->tm_isdst =0 ;
@@ -81,17 +81,17 @@ int rtc_set(struct rtc_time *tm) tm->tm_hour, tm->tm_min, tm->tm_sec);memset (buffer,0 ,7 ); - buffer[0 ] =BIN2BCD (tm->tm_sec); - buffer[1 ] =BIN2BCD (tm->tm_min); - buffer[2 ] =BIN2BCD (tm->tm_hour); - buffer[3 ] =BIN2BCD (tm->tm_wday); - tmp =BIN2BCD (tm->tm_mday); + buffer[0 ] =bin2bcd (tm->tm_sec); + buffer[1 ] =bin2bcd (tm->tm_min); + buffer[2 ] =bin2bcd (tm->tm_hour); + buffer[3 ] =bin2bcd (tm->tm_wday); + tmp =bin2bcd (tm->tm_mday); buffer[3 ] |= (tmp &0x0F ) <<4 ; buffer[4 ] = (tmp &0xF0 ) >>4 ; - tmp =BIN2BCD (tm->tm_mon); + tmp =bin2bcd (tm->tm_mon); buffer[4 ] |= (tmp &0x0F ) <<4 ; buffer[5 ] = (tmp &0xF0 ) >>4 ; - tmp =BIN2BCD (tm->tm_year %100 ); + tmp =bin2bcd (tm->tm_year %100 ); buffer[5 ] |= (tmp &0x0F ) <<4 ; buffer[6 ] = (tmp &0xF0 ) >>4 ;
drivers/rtc/s3c44b0_rtc.c +21 -21
58 lines not on this page · raw message
drivers/rtc/x1205.c +14 -14
@@ -116,13 +116,13 @@ int rtc_get(struct rtc_time *tm) buf[0 ], buf[1 ], buf[2 ], buf[3 ], buf[4], buf[5], buf[6], buf[7]); - tm->tm_sec =BCD2BIN (buf[CCR_SEC ]); - tm->tm_min =BCD2BIN (buf[CCR_MIN ]); - tm->tm_hour =BCD2BIN (buf[CCR_HOUR ] &0x3F );/* hr is 0-23 */ - tm->tm_mday =BCD2BIN (buf[CCR_MDAY ]); - tm->tm_mon =BCD2BIN (buf[CCR_MONTH ]);/* mon is 0-11 */ - tm->tm_year =BCD2BIN (buf[CCR_YEAR ]) - + (BCD2BIN (buf[CCR_Y2K ]) *100 ); + tm->tm_sec =bcd2bin (buf[CCR_SEC ]); + tm->tm_min =bcd2bin (buf[CCR_MIN ]); + tm->tm_hour =bcd2bin (buf[CCR_HOUR ] &0x3F );/* hr is 0-23 */ + tm->tm_mday =bcd2bin (buf[CCR_MDAY ]); + tm->tm_mon =bcd2bin (buf[CCR_MONTH ]);/* mon is 0-11 */ + tm->tm_year =bcd2bin (buf[CCR_YEAR ]) + + (bcd2bin (buf[CCR_Y2K ]) *100 ); tm->tm_wday = buf[CCR_WDAY ]; debug("%s: tm is secs=%d, mins=%d, hours=%d, "
@@ -143,21 +143,21 @@ int rtc_set(struct rtc_time *tm) tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_wday, tm->tm_hour, tm->tm_min, tm->tm_sec); - buf[CCR_SEC ] =BIN2BCD (tm->tm_sec); - buf[CCR_MIN ] =BIN2BCD (tm->tm_min); + buf[CCR_SEC ] =bin2bcd (tm->tm_sec); + buf[CCR_MIN ] =bin2bcd (tm->tm_min);/* set hour and 24hr bit */ - buf[CCR_HOUR ] =BIN2BCD (tm->tm_hour) |X1205_HR_MIL ; + buf[CCR_HOUR ] =bin2bcd (tm->tm_hour) |X1205_HR_MIL ; - buf[CCR_MDAY ] =BIN2BCD (tm->tm_mday); + buf[CCR_MDAY ] =bin2bcd (tm->tm_mday);/* month, 1 - 12 */ - buf[CCR_MONTH ] =BIN2BCD (tm->tm_mon); + buf[CCR_MONTH ] =bin2bcd (tm->tm_mon);/* year, since the rtc epoch*/ - buf[CCR_YEAR ] =BIN2BCD (tm->tm_year %100 ); + buf[CCR_YEAR ] =bin2bcd (tm->tm_year %100 ); buf[CCR_WDAY ] = tm->tm_wday &0x07 ; - buf[CCR_Y2K ] =BIN2BCD (tm->tm_year /100 ); + buf[CCR_Y2K ] =bin2bcd (tm->tm_year /100 );/* this sequence is required to unlock the chip */ rtc_write (X1205_REG_SR ,X1205_SR_WEL );
include/bcd.h +12 -7
@@ -3,18 +3,23 @@* at your option. */ -/* macros to translate to/from binary and binary-coded decimal (frequently -* found in RTC chips). +/* inline functions to translate to/from binary and binary-coded decimal +* (frequently found in RTC chips). */ #ifndef _BCD_H#define _BCD_H -#define BCD2BIN (val) (((val) & 0x0f) + ((val)>>4)*10) -#define BIN2BCD (val) ((((val)/10)<<4) + (val)%10) +#include <linux/types.h> -/* backwards compat */ -#define BCD_TO_BIN (val) ((val)=BCD2BIN(val)) -#define BIN_TO_BCD (val) ((val)=BIN2BCD(val)) +static inline unsigned int bcd2bin (u8 val) +{ +return ((val) &0x0f ) + ((val) >>4 ) *10 ; +} + +static inline u8 bin2bcd (unsigned int val) +{ +return (((val /10 ) <<4 ) | (val %10 )); +}#endif /* _BCD_H */
include/linux/mc146818rtc.h +0 -12
@@ -83,16 +83,4 @@#define RTC_VALID RTC_REG_D# define RTC_VRT 0x80/* valid RAM and time */ /**********************************************************************/ - -/* example: !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) -* determines if the following two #defines are needed -*/ -#ifndef BCD_TO_BIN -#define BCD_TO_BIN (val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD (val) ((val)=(((val)/10)<<4) + (val)%10) -#endif -#endif /* _MC146818RTC_H */
Signature · 1 line
1.6.0.4
PATCH 2/2 Switch from per-driver to common definition of bin2bcd and bcd2bin
--- drivers/rtc/ds12887.c | 12 ------------ drivers/rtc/ds1306.c | 18 ------------------ drivers/rtc/ds1307.c | 13 ------------- drivers/rtc/ds1337.c | 13 ------------- drivers/rtc/ds1556.c | 12 ------------ drivers/rtc/ds164x.c | 12 ------------ drivers/rtc/ds174x.c | 12 ------------ drivers/rtc/ds3231.c | 12 ------------ drivers/rtc/isl1208.c | 12 ------------ drivers/rtc/m41t11.c | 11 ----------- drivers/rtc/m41t60.c | 10 ---------- drivers/rtc/m41t62.c | 1 - drivers/rtc/m48t35ax.c | 12 ------------ drivers/rtc/max6900.c | 10 ---------- drivers/rtc/mc146818.c | 12 ------------ drivers/rtc/mk48t59.c | 10 ---------- drivers/rtc/pcf8563.c | 12 ------------ drivers/rtc/rs5c372.c | 14 -------------- drivers/rtc/rtc4543.c | 1 - drivers/rtc/rx8025.c | 12 ------------ drivers/rtc/s3c24x0_rtc.c | 10 ---------- drivers/rtc/s3c44b0_rtc.c | 1 - drivers/rtc/x1205.c | 1 - include/rtc.h | 5 +++++ 24 files changed, 5 insertions(+), 233 deletions(-)
drivers/rtc/ds12887.c +0 -12
@@ -76,18 +76,6 @@ static void rtc_write (uchar reg, uchar val)# error Board specific rtc access functions should be supplied#endif -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} - -/* ------------------------------------------------------------------------- */ -int rtc_get (struct rtc_time *tmp) {uchar sec, min, hour, mday, wday, mon, year;
drivers/rtc/ds1306.c +0 -18
@@ -62,9 +62,6 @@#define RTC_USER_RAM_BASE 0x20 -static unsigned int bin2bcd (unsigned int n); -static unsigned char bcd2bin (unsigned char c); -/* ************************************************************************* */ #ifdef CONFIG_SXNI855T /* !!! SHOULD BE CHANGED TO NEW CODE !!! */
@@ -459,19 +456,4 @@ static void rtc_write (unsigned char reg, unsigned char val)#endif /* end of code exclusion (see #ifdef CONFIG_SXNI855T above) */ -/* ------------------------------------------------------------------------- */ - -static unsigned char bcd2bin (unsigned char n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -/* ------------------------------------------------------------------------- */ - -static unsigned int bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -/* ------------------------------------------------------------------------- */ -#endif
drivers/rtc/ds1307.c +0 -13
@@ -76,8 +76,6 @@static uchar rtc_read (uchar reg);static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);/* * Get the current time from the RTC
@@ -195,15 +193,4 @@ static void rtc_write (uchar reg, uchar val) {i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR , reg, val); } - -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/ds1337.c +0 -13
@@ -77,9 +77,6 @@static uchar rtc_read (uchar reg);static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c); -/* * Get the current time from the RTC
@@ -191,14 +188,4 @@ static void rtc_write (uchar reg, uchar val) i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val); } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/ds1556.c +0 -12
@@ -40,8 +40,6 @@static uchar rtc_read (unsigned int addr );static void rtc_write (unsigned int addr,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);#define RTC_BASE ( CONFIG_SYS_NVRAM_SIZE + CONFIG_SYS_NVRAM_BASE_ADDR )
@@ -195,14 +193,4 @@ static void rtc_write( unsigned int addr, uchar val ) *(volatile unsigned char*)(addr) = val; } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/ds164x.c +0 -12
@@ -41,8 +41,6 @@static uchar rtc_read (unsigned int addr );static void rtc_write (unsigned int addr,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);#define RTC_EPOCH 2000/* century */
@@ -191,14 +189,4 @@ static void rtc_write( unsigned int addr, uchar val ) *(volatile unsigned char*)(addr) = val; } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/ds174x.c +0 -12
@@ -37,8 +37,6 @@static uchar rtc_read (unsigned int addr );static void rtc_write (unsigned int addr,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);#define RTC_BASE ( CONFIG_SYS_NVRAM_SIZE + CONFIG_SYS_NVRAM_BASE_ADDR )
@@ -192,14 +190,4 @@ static void rtc_write( unsigned int addr, uchar val ) out8( addr, val ); } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/ds3231.c +0 -12
@@ -79,8 +79,6 @@static uchar rtc_read (uchar reg);static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);/*
@@ -186,14 +184,4 @@ static void rtc_write (uchar reg, uchar val) i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val); } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/isl1208.c +0 -12
@@ -66,8 +66,6 @@static uchar rtc_read (uchar reg);static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);/* * Get the current time from the RTC
@@ -160,13 +158,3 @@ static void rtc_write (uchar reg, uchar val) {i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR , reg, val); } - -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -}
drivers/rtc/m41t11.c +0 -11
@@ -45,17 +45,6 @@#if defined(CONFIG_SYS_I2C_RTC_ADDR ) && defined(CONFIG_CMD_DATE ) -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} - -/* ------------------------------------------------------------------------- */ /* these are simple defines for the chip local to here so they aren't too
drivers/rtc/m41t60.c +0 -10
@@ -36,16 +36,6 @@#if defined(CONFIG_SYS_I2C_RTC_ADDR ) && defined(CONFIG_CMD_DATE ) -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -/* * Convert between century and "century bits" (CB1 and CB0). These routines * assume years are in the range 1900 - 2299.
drivers/rtc/m41t62.c +0 -1
@@ -31,7 +31,6 @@#include <command.h> #include <rtc.h> #include <i2c.h> -#include <bcd.h> #if defined(CONFIG_CMD_DATE )
drivers/rtc/m48t35ax.c +0 -12
@@ -37,8 +37,6 @@static uchar rtc_read (uchar reg);static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);/* ------------------------------------------------------------------------- */
@@ -157,14 +155,4 @@ static void rtc_write (uchar reg, uchar val) ((CONFIG_SYS_NVRAM_BASE_ADDR + CONFIG_SYS_NVRAM_SIZE - 8) + reg) = val; } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/max6900.c +0 -10
@@ -51,16 +51,6 @@ static void rtc_write (uchar reg, uchar val)udelay (2500 ); } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -/* ------------------------------------------------------------------------- */ int rtc_get (struct rtc_time *tmp)
drivers/rtc/mc146818.c +0 -12
@@ -35,8 +35,6 @@static uchar rtc_read (uchar reg);static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);#define RTC_PORT_MC146818 CONFIG_SYS_ISA_IO_BASE_ADDRESS + 0x70#define RTC_SECONDS 0x00
@@ -168,14 +166,4 @@ static void rtc_write (uchar reg, uchar val) }#endif -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/mk48t59.c +0 -10
@@ -97,16 +97,6 @@ static void rtc_write (short reg, uchar val)# error Board specific rtc access functions should be supplied#endif -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -/* ------------------------------------------------------------------------- */ void *nvram_read (void *dest,const short src,size_t count)
drivers/rtc/pcf8563.c +0 -12
@@ -36,8 +36,6 @@static uchar rtc_read (uchar reg);static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);/* ------------------------------------------------------------------------- */
@@ -137,14 +135,4 @@ static void rtc_write (uchar reg, uchar val) i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val); } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif
drivers/rtc/rs5c372.c +0 -14
@@ -67,9 +67,6 @@ static unsigned int rtc_debug = DEBUG;#define HOURS_24 (n) bcd2bin((n) & 0x3F) -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c); -static int setup_done =0 ; static int
@@ -291,15 +288,4 @@ rtc_reset (void) return; } -static unsigned int -bcd2bin (unsigned char n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char -bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -}#endif
drivers/rtc/rtc4543.c +0 -1
@@ -25,7 +25,6 @@#include <common.h> #include <command.h> #include <config.h> -#include <bcd.h> #include <rtc.h> #include <tws.h>
drivers/rtc/rx8025.c +0 -12
@@ -90,8 +90,6 @@#define rtc_read (reg) buf[((reg) + 1) & 0xf]static void rtc_write (uchar reg,uchar val); -static uchar bin2bcd (unsigned int n); -static unsigned bcd2bin (uchar c);/* * Get the current time from the RTC
@@ -226,14 +224,4 @@ static void rtc_write (uchar reg, uchar val) } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -#endif /* CONFIG_RTC_RX8025 && CONFIG_CMD_DATE */
drivers/rtc/s3c24x0_rtc.c +0 -10
@@ -58,16 +58,6 @@ static inline void SetRTC_Access(RTC_ACCESS a) } } -static unsigned bcd2bin (uchar n) -{ -return ((((n >>4 ) &0x0F ) *10 ) + (n &0x0F )); -} - -static unsigned char bin2bcd (unsigned int n) -{ -return (((n /10 ) <<4 ) | (n %10 )); -} -/* ------------------------------------------------------------------------- */ int rtc_get (struct rtc_time *tmp)
drivers/rtc/s3c44b0_rtc.c +0 -1
@@ -32,7 +32,6 @@#include <command.h> #include <asm/hardware.h> #include <rtc.h> -#include <bcd.h> int rtc_get (struct rtc_time * tm) {
drivers/rtc/x1205.c +0 -1
@@ -38,7 +38,6 @@#include <command.h> #include <rtc.h> #include <i2c.h> -#include <bcd.h> #if defined(CONFIG_CMD_DATE )
include/rtc.h +5 -0
@@ -27,6 +27,11 @@#ifndef _RTC_H_#define _RTC_H_ +/* bcd<->bin functions are needed by almost all the RTC drivers, let's include +* it there instead of in evey single driver */ + +#include <bcd.h> +/* * The struct used to pass data from the generic interface code to * the hardware dependend low-level code ande vice versa. Identical
Signature · 1 line
1.6.0.4
PATCH 2/2 Switch from per-driver to common definition of bin2bcd and bcd2bin
Quoted 1 line · On Thursday 13 August 2009 15:31:12 Albin Tonnerre wrote:
Signed-off-by Albin Tonnerre <[email protected]>
Thanks.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
Wolfgang Denk
AppliedPATCH 2/2 Switch from per-driver to common definition of bin2bcd and bcd2bin
In reply to Albin TonnerreDear Albin Tonnerre,
Quoted 20 lines · In message <1250170272-25909-2-git-send-email-albin.tonnerre@free-electrons.com…
Signed-off-by Albin Tonnerre <[email protected]>--- drivers/rtc/ds12887.c | 12 ------------ drivers/rtc/ds1306.c | 18 ------------------ drivers/rtc/ds1307.c | 13 ------------- drivers/rtc/ds1337.c | 13 ------------- drivers/rtc/ds1556.c | 12 ------------ drivers/rtc/ds164x.c | 12 ------------ drivers/rtc/ds174x.c | 12 ------------ drivers/rtc/ds3231.c | 12 ------------ drivers/rtc/isl1208.c | 12 ------------ drivers/rtc/m41t11.c | 11 ----------- drivers/rtc/m41t60.c | 10 ---------- drivers/rtc/m41t62.c | 1 - drivers/rtc/m48t35ax.c | 12 ------------ drivers/rtc/max6900.c | 10 ---------- drivers/rtc/mc146818.c | 12 ------------ drivers/rtc/mk48t59.c | 10 ---------- drivers/rtc/pcf8563.c | 12 ------------
Quoted 8 lines
drivers/rtc/rs5c372.c | 14 -------------- drivers/rtc/rtc4543.c | 1 - drivers/rtc/rx8025.c | 12 ------------ drivers/rtc/s3c24x0_rtc.c | 10 ---------- drivers/rtc/s3c44b0_rtc.c | 1 - drivers/rtc/x1205.c | 1 - include/rtc.h | 5 +++++ 24 files changed, 5 insertions(+), 233 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de What is tolerance? -- it is the consequence of humanity. We are all formed of frailty and error; let us pardon reciprocally each other's folly -- that is the first law of nature. - Voltaire
PATCH 1/2 Replace BCD2BIN and BIN2BCD macros with inline functions
In reply to Albin TonnerreQuoted 5 lines · On Thursday 13 August 2009 15:31:11 Albin Tonnerre wrote:
In the process, also remove backward-compatiblity macros
BIN_TO_BCDandBCD_TO_BINand update the sole board using them to use the new bin2bcd and bcd2bin insteadSigned-off-by Albin Tonnerre <[email protected]>
Thanks.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH 1/2 Replace BCD2BIN and BIN2BCD macros with inline functions
In reply to Albin TonnerreQuoted 5 lines · Albin Tonnerre
In the process, also remove backward-compatiblity macros
BIN_TO_BCDandBCD_TO_BINand update the sole board using them to use the new bin2bcd and bcd2bin insteadSigned-off-by Albin Tonnerre <[email protected]>
Being (somewhat) responsible for one of the rtc drivers, all I can say is thanks Albin!
Cheers
Detlev
Signature · 6 lines
Insider comment on Microsoft releasing Linux Hyper-V driver code under GPLv2:
"It looks like hell just froze over."
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.deWolfgang Denk
AppliedPATCH 1/2 Replace BCD2BIN and BIN2BCD macros with inline functions
In reply to Albin TonnerreDear Albin Tonnerre,
Quoted 5 lines · In message <1250170272-25909-1-git-send-email-albin.tonnerre@free-electrons.com…
In the process, also remove backward-compatiblity macros
BIN_TO_BCDandBCD_TO_BINand update the sole board using them to use the new bin2bcd and bcd2bin insteadSigned-off-by Albin Tonnerre <[email protected]>
Quoted 9 lines
--- board/rsdproto/rsdproto.c | 17 ++++++++--------- drivers/rtc/m41t62.c | 24 ++++++++++++------------ drivers/rtc/rtc4543.c | 28 ++++++++++++++-------------- drivers/rtc/s3c44b0_rtc.c | 42 +++++++++++++++++++++--------------------- drivers/rtc/x1205.c | 28 ++++++++++++++-------------- include/bcd.h | 19 ++++++++++++------- include/linux/mc146818rtc.h | 12 ------------ 7 files changed, 81 insertions(+), 89 deletions(-)
Applied to "next", thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Any sufficiently advanced technology is indistinguishable from magic.
Clarke's Third Law - _Profiles of the Future_ (1962; rev. 1973)
``Hazards of Prophecy: The Failure of Imagination''PATCH 1/2 Replace BCD2BIN and BIN2BCD macros with inline functions
Hi Wolfgang,
Quoted 18 lines · Wolfgang Denk
Dear Albin Tonnerre,
Quoted 5 lines · In message <1250170272-25909-1-git-send-email-albin.tonnerre@free-electrons.com…
In the process, also remove backward-compatiblity macros
BIN_TO_BCDandBCD_TO_BINand update the sole board using them to use the new bin2bcd and bcd2bin insteadSigned-off-by Albin Tonnerre <[email protected]>Quoted 9 lines
--- board/rsdproto/rsdproto.c | 17 ++++++++--------- drivers/rtc/m41t62.c | 24 ++++++++++++------------ drivers/rtc/rtc4543.c | 28 ++++++++++++++-------------- drivers/rtc/s3c44b0_rtc.c | 42 +++++++++++++++++++++--------------------- drivers/rtc/x1205.c | 28 ++++++++++++++-------------- include/bcd.h | 19 ++++++++++++------- include/linux/mc146818rtc.h | 12 ------------ 7 files changed, 81 insertions(+), 89 deletions(-)
Quoted 1 line
Applied to "next", thanks.
I can't find this commit (neither can I find the two other RTC-related patches) in the "next" branch when cloning the git repository, is that expected?
Regards,
Signature · 11 lines
Albin Tonnerre, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: Digital signature Url : http://lists.denx.de/pipermail/u-boot/attachments/20090824/8a9e96d3/attachment.pgp
PATCH 1/2 Replace BCD2BIN and BIN2BCD macros with inline functions
Dear Albin Tonnerre,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Applied to "next", thanks.
I can't find this commit (neither can I find the two other RTC-related patches) in the "next" branch when cloning the git repository, is that expected?
well, see for example here:
http://git.denx.de/?p=u-boot.git;a=commit;h=4bb2660bd9dd688ac40751384a95838055ed6e08
http://git.denx.de/?p=u-boot.git;a=commit;h=be29bebcfa7331923bb00e85ca5d8befb9ab621d
What exactly is that's missing for you?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Far back in the mists of ancient time, in the great and glorious days of the former Galactic Empire, life was wild, rich and largely tax free. - Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
PATCH 1/2 Replace BCD2BIN and BIN2BCD macros with inline functions
Quoted 9 lines · Wolfgang Denk
Dear Albin Tonnerre,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Applied to "next", thanks.
I can't find this commit (neither can I find the two other RTC-related patches) in the "next" branch when cloning the git repository, is that expected?
Quoted 6 lines
well, see for example here:
http://git.denx.de/?p=u-boot.git;a=commit;h=4bb2660bd9dd688ac40751384a95838055ed6e08
http://git.denx.de/?p=u-boot.git;a=commit;h=be29bebcfa7331923bb00e85ca5d8befb9ab621dWhat exactly is that's missing for you?
Well, until just now those very commits simply weren't part of the history when cloning the repository. Anyway, fixed now.
Thanks.
Regards,
Signature · 11 lines
Albin Tonnerre, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: Digital signature Url : http://lists.denx.de/pipermail/u-boot/attachments/20090824/5be326c7/attachment.pgp