diff options
author | Tobias Klauser <tklauser@nuerscht.ch> | 2006-01-09 20:54:02 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-10 08:01:56 -0800 |
commit | fe971071a89c5c5184fc9f3482c7a8e997cf0520 (patch) | |
tree | 74a29e80d5636255f33c750482497a32d8d3491f /drivers/char | |
parent | 3c6bee1d4037a5c569f30d40bd852a57ba250912 (diff) |
[PATCH] drivers/char: Use ARRAY_SIZE macro
Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove
duplicates of ARRAY_SIZE.
Signed-off-by: Tobias Klauser <tklauser@nuerscht.ch>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/amiserial.c | 2 | ||||
-rw-r--r-- | drivers/char/cyclades.c | 2 | ||||
-rw-r--r-- | drivers/char/hvsi.c | 2 | ||||
-rw-r--r-- | drivers/char/istallion.c | 19 | ||||
-rw-r--r-- | drivers/char/moxa.c | 2 | ||||
-rw-r--r-- | drivers/char/mxser.c | 2 | ||||
-rw-r--r-- | drivers/char/nvram.c | 12 | ||||
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 4 | ||||
-rw-r--r-- | drivers/char/rio/rio_linux.c | 2 | ||||
-rw-r--r-- | drivers/char/riscom8.c | 8 | ||||
-rw-r--r-- | drivers/char/serial167.c | 2 | ||||
-rw-r--r-- | drivers/char/stallion.c | 15 | ||||
-rw-r--r-- | drivers/char/sx.c | 6 | ||||
-rw-r--r-- | drivers/char/synclink.c | 8 | ||||
-rw-r--r-- | drivers/char/synclinkmp.c | 4 | ||||
-rw-r--r-- | drivers/char/vme_scc.c | 4 | ||||
-rw-r--r-- | drivers/char/vr41xx_rtc.c | 2 |
17 files changed, 45 insertions, 51 deletions
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index a124f8c5d06..10c81ecdace 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c @@ -116,7 +116,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout); static struct serial_state rs_table[1]; -#define NR_PORTS (sizeof(rs_table)/sizeof(struct serial_state)) +#define NR_PORTS ARRAY_SIZE(rs_table) /* * tmp_buf is used as a temporary buffer by serial_write. We need to diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index c7f818cd7b0..c8e7daecad7 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -723,7 +723,7 @@ static unsigned int cy_isa_addresses[] = { 0xDE000, 0,0,0,0,0,0,0,0 }; -#define NR_ISA_ADDRS (sizeof(cy_isa_addresses)/sizeof(unsigned char*)) +#define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) #ifdef MODULE static long maddr[NR_CARDS] = { 0, }; diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c index a22aa940e01..a9522189fc9 100644 --- a/drivers/char/hvsi.c +++ b/drivers/char/hvsi.c @@ -197,7 +197,7 @@ static inline void print_state(struct hvsi_struct *hp) }; const char *name = state_names[hp->state]; - if (hp->state > (sizeof(state_names)/sizeof(char*))) + if (hp->state > ARRAY_SIZE(state_names)) name = "UNKNOWN"; pr_debug("hvsi%i: state = %s\n", hp->index, name); diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index ce3bc0d45f1..24435f8daa6 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c @@ -135,7 +135,7 @@ static stlconf_t stli_brdconf[] = { /*{ BRD_ECP, 0x2a0, 0, 0xcc000, 0, 0 },*/ }; -static int stli_nrbrds = sizeof(stli_brdconf) / sizeof(stlconf_t); +static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); /* * There is some experimental EISA board detection code in this driver. @@ -406,7 +406,7 @@ static unsigned long stli_eisamemprobeaddrs[] = { 0xff000000, 0xff010000, 0xff020000, 0xff030000, }; -static int stli_eisamempsize = sizeof(stli_eisamemprobeaddrs) / sizeof(unsigned long); +static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs); /* * Define the Stallion PCI vendor and device IDs. @@ -899,15 +899,13 @@ static void stli_argbrds(void) { stlconf_t conf; stlibrd_t *brdp; - int nrargs, i; + int i; #ifdef DEBUG printk("stli_argbrds()\n"); #endif - nrargs = sizeof(stli_brdsp) / sizeof(char **); - - for (i = stli_nrbrds; (i < nrargs); i++) { + for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { memset(&conf, 0, sizeof(conf)); if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) continue; @@ -967,7 +965,7 @@ static unsigned long stli_atol(char *str) static int stli_parsebrd(stlconf_t *confp, char **argp) { char *sp; - int nrbrdnames, i; + int i; #ifdef DEBUG printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp); @@ -979,14 +977,13 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); - nrbrdnames = sizeof(stli_brdstr) / sizeof(stlibrdtype_t); - for (i = 0; (i < nrbrdnames); i++) { + for (i = 0; i < ARRAY_SIZE(stli_brdstr); i++) { if (strcmp(stli_brdstr[i].name, argp[0]) == 0) break; } - if (i >= nrbrdnames) { + if (i == ARRAY_SIZE(stli_brdstr)) { printk("STALLION: unknown board name, %s?\n", argp[0]); - return(0); + return 0; } confp->brdtype = stli_brdstr[i].type; diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 79e490ef2cf..46a3a8ccd65 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c @@ -448,7 +448,7 @@ static int __init moxa_init(void) #ifdef CONFIG_PCI { struct pci_dev *p = NULL; - int n = (sizeof(moxa_pcibrds) / sizeof(moxa_pcibrds[0])) - 1; + int n = ARRAY_SIZE(moxa_pcibrds) - 1; i = 0; while (i < n) { while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL) diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 26448f17680..51bb2a3cf8b 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -813,7 +813,7 @@ static int mxser_init(void) /* start finding PCI board here */ #ifdef CONFIG_PCI - n = (sizeof(mxser_pcibrds) / sizeof(mxser_pcibrds[0])) - 1; + n = ARRAY_SIZE(mxser_pcibrds) - 1; index = 0; b = 0; while (b < n) { diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 1af733d0732..3556ccd7757 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c @@ -557,13 +557,13 @@ pc_proc_infos(unsigned char *nvram, char *buffer, int *len, (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0); PRINT_PROC("Floppy 0 type : "); type = nvram[2] >> 4; - if (type < sizeof (floppy_types) / sizeof (*floppy_types)) + if (type < ARRAY_SIZE(floppy_types)) PRINT_PROC("%s\n", floppy_types[type]); else PRINT_PROC("%d (unknown)\n", type); PRINT_PROC("Floppy 1 type : "); type = nvram[2] & 0x0f; - if (type < sizeof (floppy_types) / sizeof (*floppy_types)) + if (type < ARRAY_SIZE(floppy_types)) PRINT_PROC("%s\n", floppy_types[type]); else PRINT_PROC("%d (unknown)\n", type); @@ -843,8 +843,6 @@ static char *colors[] = { "2", "4", "16", "256", "65536", "??", "??", "??" }; -#define fieldsize(a) (sizeof(a)/sizeof(*a)) - static int atari_proc_infos(unsigned char *nvram, char *buffer, int *len, off_t *begin, off_t offset, int size) @@ -856,7 +854,7 @@ atari_proc_infos(unsigned char *nvram, char *buffer, int *len, PRINT_PROC("Checksum status : %svalid\n", checksum ? "" : "not "); PRINT_PROC("Boot preference : "); - for (i = fieldsize(boot_prefs) - 1; i >= 0; --i) { + for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) { if (nvram[1] == boot_prefs[i].val) { PRINT_PROC("%s\n", boot_prefs[i].name); break; @@ -878,12 +876,12 @@ atari_proc_infos(unsigned char *nvram, char *buffer, int *len, return 1; PRINT_PROC("OS language : "); - if (nvram[6] < fieldsize(languages)) + if (nvram[6] < ARRAY_SIZE(languages)) PRINT_PROC("%s\n", languages[nvram[6]]); else PRINT_PROC("%u (undefined)\n", nvram[6]); PRINT_PROC("Keyboard language: "); - if (nvram[7] < fieldsize(languages)) + if (nvram[7] < ARRAY_SIZE(languages)) PRINT_PROC("%s\n", languages[nvram[7]]); else PRINT_PROC("%u (undefined)\n", nvram[7]); diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index cf45b100eff..9fb10c9fec8 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -4005,7 +4005,7 @@ BOOLEAN register_test(MGSLPC_INFO *info) { static unsigned char patterns[] = { 0x00, 0xff, 0xaa, 0x55, 0x69, 0x96, 0x0f }; - static unsigned int count = sizeof(patterns) / sizeof(patterns[0]); + static unsigned int count = ARRAY_SIZE(patterns); unsigned int i; BOOLEAN rc = TRUE; unsigned long flags; @@ -4016,7 +4016,7 @@ BOOLEAN register_test(MGSLPC_INFO *info) for (i = 0; i < count; i++) { write_reg(info, XAD1, patterns[i]); write_reg(info, XAD2, patterns[(i + 1) % count]); - if ((read_reg(info, XAD1) != patterns[i]) || + if ((read_reg(info, XAD1) != patterns[i]) || (read_reg(info, XAD2) != patterns[(i + 1) % count])) { rc = FALSE; break; diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index 2611b15b6bd..7085a38532b 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -211,7 +211,7 @@ static int rio_poll = 1; or less.... */ static int rio_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000}; -#define NR_RIO_ADDRS (sizeof(rio_probe_addrs)/sizeof (int)) +#define NR_RIO_ADDRS ARRAY_SIZE(rio_probe_addrs) /* Set the mask to all-ones. This alas, only supports 32 interrupts. diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c index 55a3a0188ed..5dae3252162 100644 --- a/drivers/char/riscom8.c +++ b/drivers/char/riscom8.c @@ -107,15 +107,15 @@ static struct riscom_port rc_port[RC_NBOARD * RC_NPORT]; /* RISCom/8 I/O ports addresses (without address translation) */ static unsigned short rc_ioport[] = { -#if 1 +#if 1 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, -#else +#else 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, 0x10, 0x11, 0x12, 0x18, 0x28, 0x31, 0x32, 0x39, 0x3a, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x6b, 0x70, 0x71, 0x78, 0x7a, 0x7b, 0x7f, 0x100, 0x101 -#endif +#endif }; -#define RC_NIOPORT (sizeof(rc_ioport) / sizeof(rc_ioport[0])) +#define RC_NIOPORT ARRAY_SIZE(rc_ioport) static inline int rc_paranoia_check(struct riscom_port const * port, diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c index c2deac968bd..a580748b92a 100644 --- a/drivers/char/serial167.c +++ b/drivers/char/serial167.c @@ -117,7 +117,7 @@ struct cyclades_port cy_port[] = { {-1 }, /* ttyS2 */ {-1 }, /* ttyS3 */ }; -#define NR_PORTS (sizeof(cy_port)/sizeof(struct cyclades_port)) +#define NR_PORTS ARRAY_SIZE(cy_port) /* * tmp_buf is used as a temporary buffer by serial_write. We need to diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 95af2a94159..acef2abf3f0 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c @@ -103,7 +103,7 @@ static stlconf_t stl_brdconf[] = { /*{ BRD_EASYIO, 0x2a0, 0, 0, 10, 0 },*/ }; -static int stl_nrbrds = sizeof(stl_brdconf) / sizeof(stlconf_t); +static int stl_nrbrds = ARRAY_SIZE(stl_brdconf); /*****************************************************************************/ @@ -424,7 +424,7 @@ static stlpcibrd_t stl_pcibrds[] = { { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, BRD_ECHPCI }, }; -static int stl_nrpcibrds = sizeof(stl_pcibrds) / sizeof(stlpcibrd_t); +static int stl_nrpcibrds = ARRAY_SIZE(stl_pcibrds); #endif @@ -704,7 +704,7 @@ static unsigned int sc26198_baudtable[] = { 230400, 460800, 921600 }; -#define SC26198_NRBAUDS (sizeof(sc26198_baudtable) / sizeof(unsigned int)) +#define SC26198_NRBAUDS ARRAY_SIZE(sc26198_baudtable) /*****************************************************************************/ @@ -901,7 +901,7 @@ static unsigned long stl_atol(char *str) static int stl_parsebrd(stlconf_t *confp, char **argp) { char *sp; - int nrbrdnames, i; + int i; #ifdef DEBUG printk("stl_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp); @@ -913,14 +913,13 @@ static int stl_parsebrd(stlconf_t *confp, char **argp) for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); - nrbrdnames = sizeof(stl_brdstr) / sizeof(stlbrdtype_t); - for (i = 0; (i < nrbrdnames); i++) { + for (i = 0; i < ARRAY_SIZE(stl_brdstr); i++) { if (strcmp(stl_brdstr[i].name, argp[0]) == 0) break; } - if (i >= nrbrdnames) { + if (i == ARRAY_SIZE(stl_brdstr)) { printk("STALLION: unknown board name, %s?\n", argp[0]); - return(0); + return 0; } confp->brdtype = stl_brdstr[i].type; diff --git a/drivers/char/sx.c b/drivers/char/sx.c index 3ad758a9a1d..564f31778eb 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -345,9 +345,9 @@ static int si_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000, 0xc8000, 0xd8000, 0xe8000, 0xa0000}; static int si1_probe_addrs[]= { 0xd0000}; -#define NR_SX_ADDRS (sizeof(sx_probe_addrs)/sizeof (int)) -#define NR_SI_ADDRS (sizeof(si_probe_addrs)/sizeof (int)) -#define NR_SI1_ADDRS (sizeof(si1_probe_addrs)/sizeof (int)) +#define NR_SX_ADDRS ARRAY_SIZE(sx_probe_addrs) +#define NR_SI_ADDRS ARRAY_SIZE(si_probe_addrs) +#define NR_SI1_ADDRS ARRAY_SIZE(si1_probe_addrs) /* Set the mask to all-ones. This alas, only supports 32 interrupts. diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 62aa0e534a6..789572fc002 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -7058,7 +7058,7 @@ static BOOLEAN mgsl_register_test( struct mgsl_struct *info ) { static unsigned short BitPatterns[] = { 0x0000, 0xffff, 0xaaaa, 0x5555, 0x1234, 0x6969, 0x9696, 0x0f0f }; - static unsigned int Patterncount = sizeof(BitPatterns)/sizeof(unsigned short); + static unsigned int Patterncount = ARRAY_SIZE(BitPatterns); unsigned int i; BOOLEAN rc = TRUE; unsigned long flags; @@ -7501,9 +7501,9 @@ static int mgsl_adapter_test( struct mgsl_struct *info ) */ static BOOLEAN mgsl_memory_test( struct mgsl_struct *info ) { - static unsigned long BitPatterns[] = { 0x0, 0x55555555, 0xaaaaaaaa, - 0x66666666, 0x99999999, 0xffffffff, 0x12345678 }; - unsigned long Patterncount = sizeof(BitPatterns)/sizeof(unsigned long); + static unsigned long BitPatterns[] = + { 0x0, 0x55555555, 0xaaaaaaaa, 0x66666666, 0x99999999, 0xffffffff, 0x12345678 }; + unsigned long Patterncount = ARRAY_SIZE(BitPatterns); unsigned long i; unsigned long TestLimit = SHARED_MEM_ADDRESS_SIZE/sizeof(unsigned long); unsigned long * TestAddr; diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index ee5a40be9f9..a9467e7d374 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -5104,7 +5104,7 @@ void tx_load_dma_buffer(SLMP_INFO *info, const char *buf, unsigned int count) int register_test(SLMP_INFO *info) { static unsigned char testval[] = {0x00, 0xff, 0xaa, 0x55, 0x69, 0x96}; - static unsigned int count = sizeof(testval)/sizeof(unsigned char); + static unsigned int count = ARRAY_SIZE(testval); unsigned int i; int rc = TRUE; unsigned long flags; @@ -5422,7 +5422,7 @@ int memory_test(SLMP_INFO *info) { static unsigned long testval[] = { 0x0, 0x55555555, 0xaaaaaaaa, 0x66666666, 0x99999999, 0xffffffff, 0x12345678 }; - unsigned long count = sizeof(testval)/sizeof(unsigned long); + unsigned long count = ARRAY_SIZE(testval); unsigned long i; unsigned long limit = SCA_MEM_SIZE/sizeof(unsigned long); unsigned long * addr = (unsigned long *)info->memory_base; diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index 19ba83635dd..33e71e23b21 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c @@ -875,13 +875,13 @@ static int scc_open (struct tty_struct * tty, struct file * filp) local_irq_save(flags); #if defined(CONFIG_MVME147_SCC) || defined(CONFIG_MVME162_SCC) if (MACH_IS_MVME147 || MACH_IS_MVME16x) { - for (i=0; i<sizeof(mvme_init_tab)/sizeof(*mvme_init_tab); ++i) + for (i = 0; i < ARRAY_SIZE(mvme_init_tab); ++i) SCCwrite(mvme_init_tab[i].reg, mvme_init_tab[i].val); } #endif #if defined(CONFIG_BVME6000_SCC) if (MACH_IS_BVME6000) { - for (i=0; i<sizeof(bvme_init_tab)/sizeof(*bvme_init_tab); ++i) + for (i = 0; i < ARRAY_SIZE(bvme_init_tab); ++i) SCCwrite(bvme_init_tab[i].reg, bvme_init_tab[i].val); } #endif diff --git a/drivers/char/vr41xx_rtc.c b/drivers/char/vr41xx_rtc.c index 435b30748e2..05a3e3743c1 100644 --- a/drivers/char/vr41xx_rtc.c +++ b/drivers/char/vr41xx_rtc.c @@ -127,7 +127,7 @@ struct resource rtc_resource[2] = { .flags = IORESOURCE_MEM, }, }; -#define RTC_NUM_RESOURCES sizeof(rtc_resource) / sizeof(struct resource) +#define RTC_NUM_RESOURCES ARRAY_SIZE(rtc_resource) static inline unsigned long read_elapsed_second(void) { |