diff options
author | Albin Tonnerre <albin.tonnerre@free-electrons.com> | 2009-08-13 15:31:12 +0200 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-08-25 12:57:55 +0200 |
commit | 885fc78c28fbe773bcb4edc9dd0fdac05ebb5b38 (patch) | |
tree | 22c3dda04cb043c48f10917778f73992332f97d9 | |
parent | e84aba135ed7145299304ef550e92f08b2c99d7a (diff) |
Switch from per-driver to common definition of bin2bcd and bcd2bin
Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com>
Acked-by: Stefan Roese <sr@denx.de>
-rw-r--r-- | drivers/rtc/ds12887.c | 12 | ||||
-rw-r--r-- | drivers/rtc/ds1306.c | 18 | ||||
-rw-r--r-- | drivers/rtc/ds1307.c | 13 | ||||
-rw-r--r-- | drivers/rtc/ds1337.c | 13 | ||||
-rw-r--r-- | drivers/rtc/ds1556.c | 12 | ||||
-rw-r--r-- | drivers/rtc/ds164x.c | 12 | ||||
-rw-r--r-- | drivers/rtc/ds174x.c | 12 | ||||
-rw-r--r-- | drivers/rtc/ds3231.c | 12 | ||||
-rw-r--r-- | drivers/rtc/isl1208.c | 12 | ||||
-rw-r--r-- | drivers/rtc/m41t11.c | 11 | ||||
-rw-r--r-- | drivers/rtc/m41t60.c | 10 | ||||
-rw-r--r-- | drivers/rtc/m41t62.c | 1 | ||||
-rw-r--r-- | drivers/rtc/m48t35ax.c | 12 | ||||
-rw-r--r-- | drivers/rtc/max6900.c | 10 | ||||
-rw-r--r-- | drivers/rtc/mc146818.c | 12 | ||||
-rw-r--r-- | drivers/rtc/mk48t59.c | 10 | ||||
-rw-r--r-- | drivers/rtc/pcf8563.c | 12 | ||||
-rw-r--r-- | drivers/rtc/rs5c372.c | 14 | ||||
-rw-r--r-- | drivers/rtc/rtc4543.c | 1 | ||||
-rw-r--r-- | drivers/rtc/rx8025.c | 12 | ||||
-rw-r--r-- | drivers/rtc/s3c24x0_rtc.c | 10 | ||||
-rw-r--r-- | drivers/rtc/s3c44b0_rtc.c | 1 | ||||
-rw-r--r-- | drivers/rtc/x1205.c | 1 | ||||
-rw-r--r-- | include/rtc.h | 5 |
24 files changed, 5 insertions, 233 deletions
diff --git a/drivers/rtc/ds12887.c b/drivers/rtc/ds12887.c index 25ca1333e23..486105f5edb 100644 --- a/drivers/rtc/ds12887.c +++ b/drivers/rtc/ds12887.c @@ -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; diff --git a/drivers/rtc/ds1306.c b/drivers/rtc/ds1306.c index 75f88a9a529..288c5f8c4ac 100644 --- a/drivers/rtc/ds1306.c +++ b/drivers/rtc/ds1306.c @@ -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 diff --git a/drivers/rtc/ds1307.c b/drivers/rtc/ds1307.c index 0650d915abb..079aa99e8b9 100644 --- a/drivers/rtc/ds1307.c +++ b/drivers/rtc/ds1307.c @@ -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 diff --git a/drivers/rtc/ds1337.c b/drivers/rtc/ds1337.c index 58e3966ec7b..a71ab5daa3f 100644 --- a/drivers/rtc/ds1337.c +++ b/drivers/rtc/ds1337.c @@ -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 diff --git a/drivers/rtc/ds1556.c b/drivers/rtc/ds1556.c index 763d22a03b1..25a0b64934b 100644 --- a/drivers/rtc/ds1556.c +++ b/drivers/rtc/ds1556.c @@ -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 diff --git a/drivers/rtc/ds164x.c b/drivers/rtc/ds164x.c index 1e96679de24..9f306d19615 100644 --- a/drivers/rtc/ds164x.c +++ b/drivers/rtc/ds164x.c @@ -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 diff --git a/drivers/rtc/ds174x.c b/drivers/rtc/ds174x.c index 738d1185c21..5a55dc8b7ad 100644 --- a/drivers/rtc/ds174x.c +++ b/drivers/rtc/ds174x.c @@ -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 diff --git a/drivers/rtc/ds3231.c b/drivers/rtc/ds3231.c index ef033588a9b..134a0e4fc22 100644 --- a/drivers/rtc/ds3231.c +++ b/drivers/rtc/ds3231.c @@ -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 diff --git a/drivers/rtc/isl1208.c b/drivers/rtc/isl1208.c index 71f63d5fa00..07591b7dba7 100644 --- a/drivers/rtc/isl1208.c +++ b/drivers/rtc/isl1208.c @@ -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)); -} diff --git a/drivers/rtc/m41t11.c b/drivers/rtc/m41t11.c index 3a77c1b6387..e0c27e18509 100644 --- a/drivers/rtc/m41t11.c +++ b/drivers/rtc/m41t11.c @@ -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 diff --git a/drivers/rtc/m41t60.c b/drivers/rtc/m41t60.c index e34a5f47831..632fe4b1455 100644 --- a/drivers/rtc/m41t60.c +++ b/drivers/rtc/m41t60.c @@ -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. diff --git a/drivers/rtc/m41t62.c b/drivers/rtc/m41t62.c index 3d7bb46b0e6..62c24469396 100644 --- a/drivers/rtc/m41t62.c +++ b/drivers/rtc/m41t62.c @@ -31,7 +31,6 @@ #include <command.h> #include <rtc.h> #include <i2c.h> -#include <bcd.h> #if defined(CONFIG_CMD_DATE) diff --git a/drivers/rtc/m48t35ax.c b/drivers/rtc/m48t35ax.c index 1482edd607f..29b36c171c0 100644 --- a/drivers/rtc/m48t35ax.c +++ b/drivers/rtc/m48t35ax.c @@ -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 diff --git a/drivers/rtc/max6900.c b/drivers/rtc/max6900.c index 7c99c5e5b1c..74637d1988d 100644 --- a/drivers/rtc/max6900.c +++ b/drivers/rtc/max6900.c @@ -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) diff --git a/drivers/rtc/mc146818.c b/drivers/rtc/mc146818.c index 38484ce26cf..d68b438efbc 100644 --- a/drivers/rtc/mc146818.c +++ b/drivers/rtc/mc146818.c @@ -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 diff --git a/drivers/rtc/mk48t59.c b/drivers/rtc/mk48t59.c index dabf3222b84..b1768821182 100644 --- a/drivers/rtc/mk48t59.c +++ b/drivers/rtc/mk48t59.c @@ -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) diff --git a/drivers/rtc/pcf8563.c b/drivers/rtc/pcf8563.c index cd9fb65c3a4..339e5f60801 100644 --- a/drivers/rtc/pcf8563.c +++ b/drivers/rtc/pcf8563.c @@ -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 diff --git a/drivers/rtc/rs5c372.c b/drivers/rtc/rs5c372.c index d6cd7c825df..90bbb4efa3c 100644 --- a/drivers/rtc/rs5c372.c +++ b/drivers/rtc/rs5c372.c @@ -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 diff --git a/drivers/rtc/rtc4543.c b/drivers/rtc/rtc4543.c index b60e37d5be7..046aa67d9aa 100644 --- a/drivers/rtc/rtc4543.c +++ b/drivers/rtc/rtc4543.c @@ -25,7 +25,6 @@ #include <common.h> #include <command.h> #include <config.h> -#include <bcd.h> #include <rtc.h> #include <tws.h> diff --git a/drivers/rtc/rx8025.c b/drivers/rtc/rx8025.c index da87394a085..64eb1cda105 100644 --- a/drivers/rtc/rx8025.c +++ b/drivers/rtc/rx8025.c @@ -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 */ diff --git a/drivers/rtc/s3c24x0_rtc.c b/drivers/rtc/s3c24x0_rtc.c index 0d3372faca2..e10db9acb86 100644 --- a/drivers/rtc/s3c24x0_rtc.c +++ b/drivers/rtc/s3c24x0_rtc.c @@ -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) diff --git a/drivers/rtc/s3c44b0_rtc.c b/drivers/rtc/s3c44b0_rtc.c index a027fb1263b..d087d8adbd4 100644 --- a/drivers/rtc/s3c44b0_rtc.c +++ b/drivers/rtc/s3c44b0_rtc.c @@ -32,7 +32,6 @@ #include <command.h> #include <asm/hardware.h> #include <rtc.h> -#include <bcd.h> int rtc_get (struct rtc_time* tm) { diff --git a/drivers/rtc/x1205.c b/drivers/rtc/x1205.c index ceba7c34aca..7adf3770d51 100644 --- a/drivers/rtc/x1205.c +++ b/drivers/rtc/x1205.c @@ -38,7 +38,6 @@ #include <command.h> #include <rtc.h> #include <i2c.h> -#include <bcd.h> #if defined(CONFIG_CMD_DATE) diff --git a/include/rtc.h b/include/rtc.h index 785fbe38079..772a5488419 100644 --- a/include/rtc.h +++ b/include/rtc.h @@ -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 |