Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 17 Sep 2002 14:25:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 17 Sep 2002 14:25:17 -0400 Received: from cpe-24-221-152-185.az.sprintbbd.net ([24.221.152.185]:13470 "EHLO Bill-The-Cat.bloom.county") by vger.kernel.org with ESMTP id ; Tue, 17 Sep 2002 14:24:58 -0400 Date: Tue, 17 Sep 2002 11:29:50 -0700 From: Tom Rini To: Linus Torvalds Cc: Kernel Mailing List Subject: [PATCH][RESEND] Cleanup (BIN|BCD)_TO_(BCD|BIN) usage/macros Message-ID: <20020917182950.GA726@opus.bloom.county> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 18665 Lines: 622 Right now there's a bit of a mess with all of the BIN_TO_BCD/BCD_TO_BIN macros in the kernel. It's defined in a half dozen places, and worse yet, not all places use them the same way. Most users do something like: if ( ... ) BIN_TO_BCD(x); But in a few places, it's used as: if ( ... ) y = BIN_TO_BCD(x); The following creates include/linux/bcd.h which has the 'normal' BIN_TO_BCD macros, as well as CONVERT_{BIN,BCD}_TO_{BCD,BIN}, which are for the second case. This patch removes all other defines, adds to for compatibility, and adds directly to anything which was implicitly including before. This was originally sent back on August 12th, without any comment. -- Tom Rini (TR1265) http://gate.crashing.org/~trini/ ===== arch/arm/kernel/time.c 1.8 vs edited ===== --- 1.8/arch/arm/kernel/time.c Sat Aug 3 06:39:48 2002 +++ edited/arch/arm/kernel/time.c Tue Sep 17 11:01:55 2002 @@ -47,14 +47,6 @@ /* change this if you have some constant time drift */ #define USECS_PER_JIFFY (1000000/HZ) -#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 - static int dummy_set_rtc(void) { return 0; ===== arch/cris/drivers/ds1302.c 1.3 vs edited ===== --- 1.3/arch/cris/drivers/ds1302.c Tue Feb 5 08:24:37 2002 +++ edited/arch/cris/drivers/ds1302.c Tue Sep 17 11:01:55 2002 @@ -97,6 +97,7 @@ #include #include #include +#include #include #include ===== arch/cris/kernel/time.c 1.6 vs edited ===== --- 1.6/arch/cris/kernel/time.c Sun Jun 16 17:39:47 2002 +++ edited/arch/cris/kernel/time.c Tue Sep 17 11:01:55 2002 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include ===== arch/m68k/sun3x/time.c 1.3 vs edited ===== --- 1.3/arch/m68k/sun3x/time.c Sun Feb 24 05:50:59 2002 +++ edited/arch/m68k/sun3x/time.c Tue Sep 17 11:01:55 2002 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -36,9 +37,6 @@ #define C_SIGN 0x20 #define C_CALIB 0x1f -#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) -#define BIN_TO_BCD(val) (((val/10) << 4) | (val % 10)) - int sun3x_hwclk(int set, struct rtc_time *t) { volatile struct mostek_dt *h = @@ -49,23 +47,23 @@ if(set) { h->csr |= C_WRITE; - h->sec = BIN_TO_BCD(t->tm_sec); - h->min = BIN_TO_BCD(t->tm_min); - h->hour = BIN_TO_BCD(t->tm_hour); - h->wday = BIN_TO_BCD(t->tm_wday); - h->mday = BIN_TO_BCD(t->tm_mday); - h->month = BIN_TO_BCD(t->tm_mon); - h->year = BIN_TO_BCD(t->tm_year); + h->sec = CONVERT_BIN_TO_BCD(t->tm_sec); + h->min = CONVERT_BIN_TO_BCD(t->tm_min); + h->hour = CONVERT_BIN_TO_BCD(t->tm_hour); + h->wday = CONVERT_BIN_TO_BCD(t->tm_wday); + h->mday = CONVERT_BIN_TO_BCD(t->tm_mday); + h->month = CONVERT_BIN_TO_BCD(t->tm_mon); + h->year = CONVERT_BIN_TO_BCD(t->tm_year); h->csr &= ~C_WRITE; } else { h->csr |= C_READ; - t->tm_sec = BCD_TO_BIN(h->sec); - t->tm_min = BCD_TO_BIN(h->min); - t->tm_hour = BCD_TO_BIN(h->hour); - t->tm_wday = BCD_TO_BIN(h->wday); - t->tm_mday = BCD_TO_BIN(h->mday); - t->tm_mon = BCD_TO_BIN(h->month); - t->tm_year = BCD_TO_BIN(h->year); + t->tm_sec = CONVERT_BCD_TO_BIN(h->sec); + t->tm_min = CONVERT_BCD_TO_BIN(h->min); + t->tm_hour = CONVERT_BCD_TO_BIN(h->hour); + t->tm_wday = CONVERT_BCD_TO_BIN(h->wday); + t->tm_mday = CONVERT_BCD_TO_BIN(h->mday); + t->tm_mon = CONVERT_BCD_TO_BIN(h->month); + t->tm_year = CONVERT_BCD_TO_BIN(h->year); h->csr &= ~C_READ; } ===== arch/mips/ddb5xxx/common/rtc_ds1386.c 1.1 vs edited ===== --- 1.1/arch/mips/ddb5xxx/common/rtc_ds1386.c Tue Feb 5 13:17:17 2002 +++ edited/arch/mips/ddb5xxx/common/rtc_ds1386.c Tue Sep 17 11:01:55 2002 @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -28,12 +29,6 @@ #define EPOCH 2000 -#undef BCD_TO_BIN -#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) - -#undef BIN_TO_BCD -#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10) - #define READ_RTC(x) *(volatile unsigned char*)(rtc_base+x) #define WRITE_RTC(x, y) *(volatile unsigned char*)(rtc_base+x) = y @@ -52,11 +47,11 @@ WRITE_RTC(0xB, byte); /* read time data */ - year = BCD_TO_BIN(READ_RTC(0xA)) + EPOCH; - month = BCD_TO_BIN(READ_RTC(0x9) & 0x1f); - day = BCD_TO_BIN(READ_RTC(0x8)); - minute = BCD_TO_BIN(READ_RTC(0x2)); - second = BCD_TO_BIN(READ_RTC(0x1)); + year = CONVERT_BCD_TO_BIN(READ_RTC(0xA)) + EPOCH; + month = CONVERT_BCD_TO_BIN(READ_RTC(0x9) & 0x1f); + day = CONVERT_BCD_TO_BIN(READ_RTC(0x8)); + minute = CONVERT_BCD_TO_BIN(READ_RTC(0x2)); + second = CONVERT_BCD_TO_BIN(READ_RTC(0x1)); /* hour is special - deal with it later */ temp = READ_RTC(0x4); @@ -68,11 +63,11 @@ /* calc hour */ if (temp & 0x40) { /* 12 hour format */ - hour = BCD_TO_BIN(temp & 0x1f); + hour = CONVERT_BCD_TO_BIN(temp & 0x1f); if (temp & 0x20) hour += 12; /* PM */ } else { /* 24 hour format */ - hour = BCD_TO_BIN(temp & 0x3f); + hour = CONVERT_BCD_TO_BIN(temp & 0x3f); } return mktime(year, month, day, hour, minute, second); @@ -95,19 +90,19 @@ to_tm(t, &tm); /* check each field one by one */ - year = BIN_TO_BCD(tm.tm_year - EPOCH); + year = CONVERT_BIN_TO_BCD(tm.tm_year - EPOCH); if (year != READ_RTC(0xA)) { WRITE_RTC(0xA, year); } temp = READ_RTC(0x9); - month = BIN_TO_BCD(tm.tm_mon); + month = CONVERT_BIN_TO_BCD(tm.tm_mon); if (month != (temp & 0x1f)) { WRITE_RTC( 0x9, (month & 0x1f) | (temp & ~0x1f) ); } - day = BIN_TO_BCD(tm.tm_mday); + day = CONVERT_BIN_TO_BCD(tm.tm_mday); if (day != READ_RTC(0x8)) { WRITE_RTC(0x8, day); } @@ -117,22 +112,22 @@ /* 12 hour format */ hour = 0x40; if (tm.tm_hour > 12) { - hour |= 0x20 | (BIN_TO_BCD(hour-12) & 0x1f); + hour |= 0x20 | (CONVERT_BIN_TO_BCD(hour-12) & 0x1f); } else { - hour |= BIN_TO_BCD(tm.tm_hour); + hour |= CONVERT_BIN_TO_BCD(tm.tm_hour); } } else { /* 24 hour format */ - hour = BIN_TO_BCD(tm.tm_hour) & 0x3f; + hour = CONVERT_BIN_TO_BCD(tm.tm_hour) & 0x3f; } if (hour != temp) WRITE_RTC(0x4, hour); - minute = BIN_TO_BCD(tm.tm_min); + minute = CONVERT_BIN_TO_BCD(tm.tm_min); if (minute != READ_RTC(0x2)) { WRITE_RTC(0x2, minute); } - second = BIN_TO_BCD(tm.tm_sec); + second = CONVERT_BIN_TO_BCD(tm.tm_sec); if (second != READ_RTC(0x1)) { WRITE_RTC(0x1, second); } ===== arch/mips64/sgi-ip27/ip27-rtc.c 1.4 vs edited ===== --- 1.4/arch/mips64/sgi-ip27/ip27-rtc.c Thu May 23 09:06:16 2002 +++ edited/arch/mips64/sgi-ip27/ip27-rtc.c Tue Sep 17 11:01:55 2002 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include ===== arch/mips64/sgi-ip27/ip27-timer.c 1.2 vs edited ===== --- 1.2/arch/mips64/sgi-ip27/ip27-timer.c Tue Feb 5 00:45:04 2002 +++ edited/arch/mips64/sgi-ip27/ip27-timer.c Tue Sep 17 11:01:55 2002 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include ===== arch/ppc/iSeries/mf.c 1.2 vs edited ===== --- 1.2/arch/ppc/iSeries/mf.c Sun Jun 2 23:49:59 2002 +++ edited/arch/ppc/iSeries/mf.c Tue Sep 17 11:01:55 2002 @@ -40,6 +40,7 @@ #include #include #include +#include /* ===== arch/ppc/kernel/todc_time.c 1.1 vs edited ===== --- 1.1/arch/ppc/kernel/todc_time.c Sun Feb 10 04:20:03 2002 +++ edited/arch/ppc/kernel/todc_time.c Tue Sep 17 11:01:55 2002 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include ===== arch/ppc/platforms/gemini_setup.c 1.11 vs edited ===== --- 1.11/arch/ppc/platforms/gemini_setup.c Mon May 27 08:05:50 2002 +++ edited/arch/ppc/platforms/gemini_setup.c Tue Sep 17 11:01:55 2002 @@ -27,6 +27,7 @@ #include #include #include +#include #include #include ===== arch/ppc/platforms/prep_time.c 1.6 vs edited ===== --- 1.6/arch/ppc/platforms/prep_time.c Sun Feb 10 04:41:25 2002 +++ edited/arch/ppc/platforms/prep_time.c Tue Sep 17 11:01:55 2002 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include ===== arch/ppc64/kernel/mf.c 1.2 vs edited ===== --- 1.2/arch/ppc64/kernel/mf.c Wed Apr 24 21:46:36 2002 +++ edited/arch/ppc64/kernel/mf.c Tue Sep 17 11:01:55 2002 @@ -40,6 +40,7 @@ #include #include #include +#include extern struct pci_dev * iSeries_vio_dev; ===== arch/sh/kernel/rtc.c 1.5 vs edited ===== --- 1.5/arch/sh/kernel/rtc.c Tue Feb 5 08:24:41 2002 +++ edited/arch/sh/kernel/rtc.c Tue Sep 17 11:01:55 2002 @@ -9,17 +9,10 @@ #include #include #include +#include #include #include - -#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 void sh_rtc_gettimeofday(struct timeval *tv) { ===== arch/sparc64/kernel/time.c 1.14 vs edited ===== --- 1.14/arch/sparc64/kernel/time.c Fri Sep 13 14:41:56 2002 +++ edited/arch/sparc64/kernel/time.c Tue Sep 17 11:01:56 2002 @@ -316,14 +316,6 @@ return (data1 == data2); /* Was the write blocked? */ } -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10) -#endif - /* Probe for the real time clock chip. */ static void __init set_system_time(void) { ===== drivers/scsi/sr_vendor.c 1.8 vs edited ===== --- 1.8/drivers/scsi/sr_vendor.c Wed Sep 4 14:24:17 2002 +++ edited/drivers/scsi/sr_vendor.c Tue Sep 17 11:01:57 2002 @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "scsi.h" @@ -147,8 +148,6 @@ /* This function gets called after a media change. Checks if the CD is multisession, asks for offset etc. */ -#define BCD_TO_BIN(x) ((((int)x & 0xf0) >> 4)*10 + ((int)x & 0x0f)) - int sr_cd_check(struct cdrom_device_info *cdi) { Scsi_CD *cd = cdi->handle; @@ -213,9 +212,9 @@ no_multi = 1; break; } - min = BCD_TO_BIN(buffer[15]); - sec = BCD_TO_BIN(buffer[16]); - frame = BCD_TO_BIN(buffer[17]); + min = CONVERT_BCD_TO_BIN(buffer[15]); + sec = CONVERT_BCD_TO_BIN(buffer[16]); + frame = CONVERT_BCD_TO_BIN(buffer[17]); sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame; break; } @@ -240,9 +239,9 @@ } if (rc != 0) break; - min = BCD_TO_BIN(buffer[1]); - sec = BCD_TO_BIN(buffer[2]); - frame = BCD_TO_BIN(buffer[3]); + min = CONVERT_BCD_TO_BIN(buffer[1]); + sec = CONVERT_BCD_TO_BIN(buffer[2]); + frame = CONVERT_BCD_TO_BIN(buffer[3]); sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame; if (sector) sector -= CD_MSF_OFFSET; ===== drivers/sgi/char/ds1286.c 1.4 vs edited ===== --- 1.4/drivers/sgi/char/ds1286.c Tue Feb 5 00:44:52 2002 +++ edited/drivers/sgi/char/ds1286.c Tue Sep 17 11:01:57 2002 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include ===== include/asm-cris/rtc.h 1.2 vs edited ===== --- 1.2/include/asm-cris/rtc.h Tue Feb 5 00:40:14 2002 +++ edited/include/asm-cris/rtc.h Tue Sep 17 11:01:57 2002 @@ -39,11 +39,6 @@ #define RTC_INIT() (-1) #endif -/* conversions to and from the stupid RTC internal format */ - -#define BCD_TO_BIN(x) x = (((x & 0xf0) >> 3) * 5 + (x & 0xf)) -#define BIN_TO_BCD(x) x = (x % 10) | ((x / 10) << 4) - /* * The struct used to pass data via the following ioctl. Similar to the * struct tm in , but it needs to be here so that the kernel ===== include/asm-mips/ds1286.h 1.1 vs edited ===== --- 1.1/include/asm-mips/ds1286.h Tue Feb 5 10:39:45 2002 +++ edited/include/asm-mips/ds1286.h Tue Sep 17 11:01:57 2002 @@ -57,15 +57,4 @@ #define RTC_IPSW 0x40 #define RTC_TE 0x80 -/* - * Conversion between binary and BCD. - */ -#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 /* _ASM_DS1286_h */ ===== include/asm-mips64/ds1286.h 1.2 vs edited ===== --- 1.2/include/asm-mips64/ds1286.h Tue Feb 5 00:45:05 2002 +++ edited/include/asm-mips64/ds1286.h Tue Sep 17 11:01:57 2002 @@ -56,15 +56,4 @@ #define RTC_IPSW 0x40 #define RTC_TE 0x80 -/* - * Conversion between binary and BCD. - */ -#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 /* _ASM_DS1286_h */ ===== include/asm-mips64/m48t35.h 1.1 vs edited ===== --- 1.1/include/asm-mips64/m48t35.h Tue Feb 5 10:39:55 2002 +++ edited/include/asm-mips64/m48t35.h Tue Sep 17 11:01:57 2002 @@ -21,12 +21,4 @@ #define M48T35_RTC_STOPPED 0x80 #define M48T35_RTC_READ 0x40 -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(x) ((x)=((x)&15) + ((x)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(x) ((x)=(((x)/10)<<4) + (x)%10) -#endif - #endif ===== include/asm-ppc/m48t35.h 1.3 vs edited ===== --- 1.3/include/asm-ppc/m48t35.h Tue Feb 5 00:54:05 2002 +++ edited/include/asm-ppc/m48t35.h Tue Sep 17 11:01:57 2002 @@ -76,14 +76,4 @@ #define M48T35_RTC_STOPPED 0x80 #define M48T35_RTC_READ 0x40 - -/* read/write conversions */ -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(x) ((x)=((x)&15) + ((x)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(x) ((x)=(((x)/10)<<4) + (x)%10) -#endif - #endif ===== include/asm-ppc/mk48t59.h 1.2 vs edited ===== --- 1.2/include/asm-ppc/mk48t59.h Tue Feb 5 00:40:23 2002 +++ edited/include/asm-ppc/mk48t59.h Tue Sep 17 11:01:57 2002 @@ -27,12 +27,4 @@ #define MK48T59_RTC_CONTROLB 0x1FF9 #define MK48T59_RTC_CB_STOP 0x80 -#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 /* _PPC_MK48T59_H */ ===== include/asm-ppc/nvram.h 1.2 vs edited ===== --- 1.2/include/asm-ppc/nvram.h Tue Feb 5 00:40:23 2002 +++ edited/include/asm-ppc/nvram.h Tue Sep 17 11:01:57 2002 @@ -26,14 +26,6 @@ #define MOTO_RTC_CONTROLA 0x1FF8 #define MOTO_RTC_CONTROLB 0x1FF9 -#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 - /* PowerMac specific nvram stuffs */ enum { ===== include/asm-ppc/todc.h 1.1 vs edited ===== --- 1.1/include/asm-ppc/todc.h Sun Feb 10 03:45:43 2002 +++ edited/include/asm-ppc/todc.h Tue Sep 17 11:01:57 2002 @@ -355,14 +355,6 @@ todc_info->flags = clock_type ##_FLAGS; \ } -#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 - extern todc_info_t *todc_info; unsigned char todc_direct_read_val(int addr); ===== include/asm-ppc64/nvram.h 1.2 vs edited ===== --- 1.2/include/asm-ppc64/nvram.h Fri Mar 15 19:14:30 2002 +++ edited/include/asm-ppc64/nvram.h Tue Sep 17 11:01:57 2002 @@ -28,12 +28,4 @@ #define MOTO_RTC_CONTROLA 0x1FF8 #define MOTO_RTC_CONTROLB 0x1FF9 -#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 /* _PPC64_NVRAM_H */ ===== include/linux/mc146818rtc.h 1.2 vs edited ===== --- 1.2/include/linux/mc146818rtc.h Tue Feb 5 00:45:03 2002 +++ edited/include/linux/mc146818rtc.h Tue Sep 17 11:01:57 2002 @@ -14,6 +14,7 @@ #include #include /* get the user-level API */ #include /* spinlock_t */ +#include /* (BIN|BCD)_TO_(BCD|BIN) */ #include /* register access macros */ extern spinlock_t rtc_lock; /* serialize CMOS RAM access */ @@ -86,16 +87,5 @@ #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 */ --- /dev/null 1969-12-31 17:00:00.000000000 -0700 +++ include/linux/bcd.h 2002-09-17 11:01:57.000000000 -0700 @@ -0,0 +1,28 @@ +/* + * include/linux/bcd.h: Macros to convert to/from Binary Coded Decimals. + * + * Originally in numerous files throughout the kernel. + * + * Author: Tom Rini + * trini@mvista.com + * Copyright 2002 MontaVista Software Inc. + * + * Please read the COPYING file for all license details. + */ + +#ifndef __LINUX_BCD_H__ +#define __LINUX_BCD_H__ + +/* + * Just convert the value, and don't change the original. + */ +#define CONVERT_BIN_TO_BCD(val) ((((val) / 10) << 4) + (val) % 10) +#define CONVERT_BCD_TO_BIN(val) (((val) & 15) + ((val) >> 4) * 10) + +/* + * Change the variable 'val' from one to the other. + */ +#define BIN_TO_BCD(val) ((val) = CONVERT_BIN_TO_BCD((val))) +#define BCD_TO_BIN(val) ((val) = CONVERT_BCD_TO_BIN((val))) + +#endif /* __LINUX_BCD_H__ */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/