Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbXBWIOq (ORCPT ); Fri, 23 Feb 2007 03:14:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752166AbXBWIOq (ORCPT ); Fri, 23 Feb 2007 03:14:46 -0500 Received: from ug-out-1314.google.com ([66.249.92.170]:45286 "EHLO ug-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752169AbXBWIOo (ORCPT ); Fri, 23 Feb 2007 03:14:44 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=BpSofm1TU2Ptojiqmfeg/h9If03IJIHB0MGVi52ZyIEJxQ0L9gc/RjPxVdGQDu1dvlicyX/GGtGjyYvX3Gs3VqX7cFnEHnktqy3NvVYLfMgJP4QpmDkyLJpcikfTZcVURE9pVYv7HQqnw8Ig+aYNPjy9JTTqzJoou3/8hSEjSbg= Message-ID: <3b44d3fb0702230014x4ee4a1dewdc624c54b3635e15@mail.gmail.com> Date: Fri, 23 Feb 2007 13:44:41 +0530 From: "Milind Choudhary" To: kernel-janitors@lists.osdl.org Subject: [KJ][RFC][PATCH] BIT macro cleanup Cc: linux-kernel@vger.kernel.org, dmitry.torokhov@gmail.com, linux-input@atrey.karlin.mff.cuni.cz, linux-joystick@atrey.karlin.mff.cuni.cz In-Reply-To: <3b44d3fb0702222056k1d2a9b57q69a3555a09a9058e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <3b44d3fb0702222056k1d2a9b57q69a3555a09a9058e@mail.gmail.com> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 17635 Lines: 490 Hi all working towards the cleanup of BIT macro, I've added one to & cleaned some obvious users. include/linux/input.h also has a BIT macro which does a wrap so currently i've done something like +#undef BIT #define BIT(nr) (1UL << ((nr) % BITS_PER_LONG)) Is it advisible to move this macro to bitops.h with some other name +#define BITWRAP(nr) (1UL << ((nr) % BITS_PER_LONG)) & make the whole input subsystem use it The change is huge, more than 125 files using input.h & almost all use the BIT macro. discussion on KJ http://lists.osdl.org/pipermail/kernel-janitors/2007-February/008442.html Signed-off-by: Milind Arun Choudhary --- arch/ppc/platforms/chestnut.c | 1 drivers/edac/edac_mc.h | 2 - drivers/i2c/busses/i2c-pxa.c | 55 ++++++++++++++-------------- drivers/net/eth16i.c | 1 drivers/net/meth.h | 3 - drivers/net/s2io.h | 1 drivers/net/wireless/hostap/hostap_common.h | 3 - drivers/scsi/nsp32.h | 4 -- drivers/scsi/pcmcia/nsp_cs.h | 1 drivers/serial/amba-pl011.c | 37 ++++++++---------- drivers/video/cyber2000fb.c | 44 +++++++++++----------- fs/select.c | 1 include/asm-mips/ip32/crime.h | 3 - include/asm-mips/ip32/mace.h | 3 - include/linux/bitops.h | 4 ++ include/linux/input.h | 4 +- include/video/sstfb.h | 1 include/video/tdfx.h | 3 - 18 files changed, 76 insertions(+), 95 deletions(-) diff --git a/arch/ppc/platforms/chestnut.c b/arch/ppc/platforms/chestnut.c index a764ae7..248bfdd 100644 --- a/arch/ppc/platforms/chestnut.c +++ b/arch/ppc/platforms/chestnut.c @@ -48,7 +48,6 @@ extern void gen550_progress(char *, unsigned short); extern void gen550_init(int, struct uart_port *); extern void mv64360_pcibios_fixup(mv64x60_handle_t *bh); -#define BIT(x) (1<> (loc)) #define vBIT(val, loc, sz) (((u64)val) << (64-loc-sz)) #define INV(d) ((d&0xff)<<24) | (((d>>8)&0xff)<<16) | (((d>>16)&0xff)<<8)| ((d>>24)&0xff) diff --git a/drivers/net/wireless/hostap/hostap_common.h b/drivers/net/wireless/hostap/hostap_common.h index 0162400..429c9dd 100644 --- a/drivers/net/wireless/hostap/hostap_common.h +++ b/drivers/net/wireless/hostap/hostap_common.h @@ -3,8 +3,7 @@ #include #include - -#define BIT(x) (1 << (x)) +#include #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h index a976e81..9779c5a 100644 --- a/drivers/scsi/nsp32.h +++ b/drivers/scsi/nsp32.h @@ -68,10 +68,6 @@ static char * nsp32_model[] = { typedef u32 u32_le; typedef u16 u16_le; -/* - * MACRO - */ -#define BIT(x) (1UL << (x)) /* * BASIC Definitions diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index 9102cbd..0a3e2d1 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -26,7 +26,6 @@ /************************************ * Some useful macros... */ -#define BIT(x) (1L << (x)) /* SCSI initiator must be ID 7 */ #define NSP_INITIATOR_ID 7 diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 44639e7..dfff378 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -53,6 +53,9 @@ #include #include +#define SETBITS(data,mask) (data |= mask) +#define CLRBITS(data,mask) (data &= ~mask) + #define UART_NR 14 #define SERIAL_AMBA_MAJOR 204 @@ -262,15 +265,11 @@ static unsigned int pl01x_get_mctrl(struct uart_port *port) unsigned int result = 0; unsigned int status = readw(uap->port.membase + UART01x_FR); -#define BIT(uartbit, tiocmbit) \ - if (status & uartbit) \ - result |= tiocmbit + result |= (status & UART01x_FR_DCD) ? TIOCM_CAR : 0 ; + result |= (status & UART01x_FR_DSR) ? TIOCM_DSR : 0 ; + result |= (status & UART01x_FR_CTS) ? TIOCM_CTS : 0 ; + result |= (status & UART011_FR_RI) ? TIOCM_RNG : 0 ; - BIT(UART01x_FR_DCD, TIOCM_CAR); - BIT(UART01x_FR_DSR, TIOCM_DSR); - BIT(UART01x_FR_CTS, TIOCM_CTS); - BIT(UART011_FR_RI, TIOCM_RNG); -#undef BIT return result; } @@ -281,18 +280,16 @@ static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl) cr = readw(uap->port.membase + UART011_CR); -#define BIT(tiocmbit, uartbit) \ - if (mctrl & tiocmbit) \ - cr |= uartbit; \ - else \ - cr &= ~uartbit - - BIT(TIOCM_RTS, UART011_CR_RTS); - BIT(TIOCM_DTR, UART011_CR_DTR); - BIT(TIOCM_OUT1, UART011_CR_OUT1); - BIT(TIOCM_OUT2, UART011_CR_OUT2); - BIT(TIOCM_LOOP, UART011_CR_LBE); -#undef BIT + (mctrl & TIOCM_RTS) ? + SETBITS(cr, UART011_CR_DTR) : CLRBITS(cr, UART011_CR_DTR); + (mctrl & TIOCM_DTR) ? + SETBITS(cr, UART011_CR_DTR) : CLRBITS(cr, UART011_CR_DTR); + (mctrl & TIOCM_OUT1) ? + SETBITS(cr, UART011_CR_OUT1) : CLRBITS(cr, UART011_CR_OUT1); + (mctrl & TIOCM_OUT2) ? + SETBITS(cr, UART011_CR_OUT2) : CLRBITS(cr, UART011_CR_OUT2); + (mctrl & TIOCM_LOOP) ? + SETBITS(cr, UART011_CR_LBE) : CLRBITS(cr, UART011_CR_LBE); writew(cr, uap->port.membase + UART011_CR); } diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c index 7a6eeda..f21b20f 100644 --- a/drivers/video/cyber2000fb.c +++ b/drivers/video/cyber2000fb.c @@ -550,7 +550,7 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, { u_int Htotal, Hblankend, Hsyncend; u_int Vtotal, Vdispend, Vblankstart, Vblankend, Vsyncstart, Vsyncend; -#define BIT(v,b1,m,b2) (((v >> b1) & m) << b2) +#define BITMASK(v,b1,m,b2) (((v >> b1) & m) << b2) hw->crtc[13] = hw->pitch; hw->crtc[17] = 0xe3; @@ -570,13 +570,13 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, Hblankend = (Htotal - 4*8) >> 3; - hw->crtc[3] = BIT(Hblankend, 0, 0x1f, 0) | - BIT(1, 0, 0x01, 7); + hw->crtc[3] = BITMASK(Hblankend, 0, 0x1f, 0) | + BITMASK(1, 0, 0x01, 7); Hsyncend = (var->xres + var->right_margin + var->hsync_len) >> 3; - hw->crtc[5] = BIT(Hsyncend, 0, 0x1f, 0) | - BIT(Hblankend, 5, 0x01, 7); + hw->crtc[5] = BITMASK(Hsyncend, 0, 0x1f, 0) | + BITMASK(Hblankend, 5, 0x01, 7); Vdispend = var->yres - 1; Vsyncstart = var->yres + var->lower_margin; @@ -591,20 +591,20 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, Vblankend = Vtotal - 10; hw->crtc[6] = Vtotal; - hw->crtc[7] = BIT(Vtotal, 8, 0x01, 0) | - BIT(Vdispend, 8, 0x01, 1) | - BIT(Vsyncstart, 8, 0x01, 2) | - BIT(Vblankstart,8, 0x01, 3) | - BIT(1, 0, 0x01, 4) | - BIT(Vtotal, 9, 0x01, 5) | - BIT(Vdispend, 9, 0x01, 6) | - BIT(Vsyncstart, 9, 0x01, 7); - hw->crtc[9] = BIT(0, 0, 0x1f, 0) | - BIT(Vblankstart,9, 0x01, 5) | - BIT(1, 0, 0x01, 6); + hw->crtc[7] = BITMASK(Vtotal, 8, 0x01, 0) | + BITMASK(Vdispend, 8, 0x01, 1) | + BITMASK(Vsyncstart, 8, 0x01, 2) | + BITMASK(Vblankstart,8, 0x01, 3) | + BITMASK(1, 0, 0x01, 4) | + BITMASK(Vtotal, 9, 0x01, 5) | + BITMASK(Vdispend, 9, 0x01, 6) | + BITMASK(Vsyncstart, 9, 0x01, 7); + hw->crtc[9] = BITMASK(0, 0, 0x1f, 0) | + BITMASK(Vblankstart,9, 0x01, 5) | + BITMASK(1, 0, 0x01, 6); hw->crtc[10] = Vsyncstart; - hw->crtc[11] = BIT(Vsyncend, 0, 0x0f, 0) | - BIT(1, 0, 0x01, 7); + hw->crtc[11] = BITMASK(Vsyncend, 0, 0x0f, 0) | + BITMASK(1, 0, 0x01, 7); hw->crtc[12] = Vdispend; hw->crtc[15] = Vblankstart; hw->crtc[16] = Vblankend; @@ -616,10 +616,10 @@ cyber2000fb_decode_crtc(struct par_info *hw, struct cfb_info *cfb, * 4=LINECOMP:10 5-IVIDEO 6=FIXCNT */ hw->crtc_ofl = - BIT(Vtotal, 10, 0x01, 0) | - BIT(Vdispend, 10, 0x01, 1) | - BIT(Vsyncstart, 10, 0x01, 2) | - BIT(Vblankstart,10, 0x01, 3) | + BITMASK(Vtotal, 10, 0x01, 0) | + BITMASK(Vdispend, 10, 0x01, 1) | + BITMASK(Vsyncstart, 10, 0x01, 2) | + BITMASK(Vblankstart,10, 0x01, 3) | EXT_CRT_VRTOFL_LINECOMP10; /* woody: set the interlaced bit... */ diff --git a/fs/select.c b/fs/select.c index fe0893a..4bbe8ed 100644 --- a/fs/select.c +++ b/fs/select.c @@ -180,7 +180,6 @@ get_max: return max; } -#define BIT(i) (1UL << ((i)&(__NFDBITS-1))) #define MEM(i,m) ((m)+(unsigned)(i)/__NFDBITS) #define ISSET(i,m) (((i)&*(m)) != 0) #define SET(i,m) (*(m) |= (i)) diff --git a/include/asm-mips/ip32/crime.h b/include/asm-mips/ip32/crime.h index a13702f..7c36b0e 100644 --- a/include/asm-mips/ip32/crime.h +++ b/include/asm-mips/ip32/crime.h @@ -17,9 +17,6 @@ */ #define CRIME_BASE 0x14000000 /* physical */ -#undef BIT -#define BIT(x) (1UL << (x)) - struct sgi_crime { volatile unsigned long id; #define CRIME_ID_MASK 0xff diff --git a/include/asm-mips/ip32/mace.h b/include/asm-mips/ip32/mace.h index 990082c..d08d7c6 100644 --- a/include/asm-mips/ip32/mace.h +++ b/include/asm-mips/ip32/mace.h @@ -17,9 +17,6 @@ */ #define MACE_BASE 0x1f000000 /* physical */ -#undef BIT -#define BIT(x) (1UL << (x)) - /* * PCI interface */ diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 638165f..33ad687 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -8,6 +8,10 @@ */ #include +#define BIT(nr) (1UL << (nr)) +#define LLBIT(nr) (1ULL << (nr)) +#define BITWRAP(nr) (1UL << ((nr) % BITS_PER_LONG)) + static __inline__ int get_bitmask_order(unsigned int count) { int order; diff --git a/include/linux/input.h b/include/linux/input.h index bde65c8..e4203d1 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -908,9 +908,11 @@ struct ff_effect { #include #include #include +//#include #define NBITS(x) (((x)/BITS_PER_LONG)+1) -#define BIT(x) (1UL<<((x)%BITS_PER_LONG)) +#undef BIT +#define BIT(nr) (1UL << ((nr) % BITS_PER_LONG)) #define LONG(x) ((x)/BITS_PER_LONG) #define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \ diff --git a/include/video/sstfb.h b/include/video/sstfb.h index baa163f..b52f073 100644 --- a/include/video/sstfb.h +++ b/include/video/sstfb.h @@ -68,7 +68,6 @@ # define print_var(X,Y...) #endif -#define BIT(x) (1ul<<(x)) #define POW2(x) (1ul<<(x)) /* diff --git a/include/video/tdfx.h b/include/video/tdfx.h index c1cc94b..ac6d0f1 100644 --- a/include/video/tdfx.h +++ b/include/video/tdfx.h @@ -77,9 +77,6 @@ #define COMMAND_3D (0x00200000 + 0x120) -/* register bitfields (not all, only as needed) */ - -#define BIT(x) (1UL << (x)) /* COMMAND_2D reg. values */ #define TDFX_ROP_COPY 0xcc // src Milind Arun Choudhary - 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/