A series of patches to use ARRAY_SIZE in `net' drivers
Subsystems (3)
PATCH 1/1 A series of patches to use ARRAY_SIZE in `net' drivers
Hi all,
Follows is a sereis of patches to use ARRAY_SIZE macro in drivers/net. Patches are sent separately according to their maintaners as replies to this thread.
apne.c | 2 +- arm/am79c961a.c | 2 +- atarilance.c | 2 +- cs89x0.c | 6 +++--- e1000/e1000_ethtool.c | 2 +- fec_8xx/fec_mii.c | 4 ++-- ibm_emac/ibm_emac_debug.c | 8 ++++---- irda/actisys-sir.c | 3 ++- ixgb/ixgb_param.c | 2 +- lp486e.c | 2 +- ne-h8300.c | 2 +- ne.c | 2 +- ne2.c | 2 +- ne2k-pci.c | 2 +- netxen/netxen_nic_hw.c | 2 +- pcmcia/axnet_cs.c | 2 +- pcmcia/pcnet_cs.c | 2 +- sk98lin/skgemib.c | 4 +++- sk98lin/skgesirq.c | 3 ++- skfp/smt.c | 3 ++- skfp/srf.c | 6 ++++-- wireless/airo.c | 4 ++-- wireless/hostap/hostap.h | 3 ++- wireless/ipw2100.c | 14 ++++++-------- wireless/prism54/oid_mgt.c | 4 +++- wireless/wavelan.p.h | 2 +- zorro8390.c | 2 +- 27 files changed, 50 insertions(+), 42 deletions(-)
Thanks,
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 e1000: Use ARRAY_SIZE macro when appropriate
Hi,
A patch to use ARRAY_SIZE macro already defined in kernel.h.
---
Patch is compile tested.
drivers/net/e1000/e1000_ethtool.c +1 -1
@@ -746,7 +746,7 @@ err_setup:uint32_t pat, value; \uint32_t test[] = \ {0x5A5A5A5A ,0xA5A5A5A5 ,0x00000000 ,0xFFFFFFFF }; \ -for (pat =0 ; pat <sizeof (test)/sizeof (test[0 ]); pat++) { \ +for (pat =0 ; pat <ARRAY_SIZE (test); pat++) { \E1000_WRITE_REG (&adapter->hw,R , (test[pat] &W )); \ value =E1000_READ_REG (&adapter->hw,R ); \if (value != (test[pat] &W &M )) { \
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/2 misc-net-drivers: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi,
A 2.6.20 patch to use ARRAY_SIZE macro already defined in kernel.h for some miscellaneous network drivers with no specific maintaners.
---
[PATCH 01/02] is compile tested.
[PATCH 02/02] isn't compile tested cause of missing hardware.
drivers/net/cs89x0.c +3 -3
@@ -806,7 +806,7 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular) i = cs8900_irq_map[0 ];#else /* Translate the IRQ using the IRQ mapping table. */ -if (i >=sizeof (cs8900_irq_map)/sizeof (cs8900_irq_map[0 ])) +if (i >=ARRAY_SIZE (cs8900_irq_map))printk ("\ncs89x0: invalid ISA interrupt number %d\n" , i);else i = cs8900_irq_map[i];
@@ -1248,11 +1248,11 @@ write_irq(struct net_device *dev, int chip_type, int irq)if (chip_type ==CS8900 ) {/* Search the mapping table for the corresponding IRQ pin. */ -for (i =0 ; i !=sizeof (cs8900_irq_map)/sizeof (cs8900_irq_map[0 ]); i++) +for (i =0 ; i !=ARRAY_SIZE (cs8900_irq_map); i++)if (cs8900_irq_map[i] == irq)break ;/* Not found */ -if (i ==sizeof (cs8900_irq_map)/sizeof (cs8900_irq_map[0 ])) +if (i ==ARRAY_SIZE (cs8900_irq_map)) i =3 ;writereg (dev,PP_CS8900_ISAINT , i); }else {
drivers/net/irda/actisys-sir.c +2 -1
@@ -43,6 +43,7 @@#include <linux/module.h> #include <linux/delay.h> #include <linux/init.h> +#include <linux/kernel.h> #include <net/irda/irda.h>
@@ -67,7 +68,7 @@ static int actisys_reset(struct sir_dev *);/* Note : the 220L doesn't support 38400, but we will fix that below */ static unsigned baud_rates[] = {9600 ,19200 ,57600 ,115200 ,38400 }; -#define MAX_SPEEDS (sizeof(baud_rates)/sizeof(baud_rates[0])) +#define MAX_SPEEDS ARRAY_SIZE(baud_rates)static struct dongle_driver act220l = { .owner =THIS_MODULE ,
drivers/net/lp486e.c +1 -1
@@ -515,7 +515,7 @@ CLEAR_INT(void) {outb (0 ,IOADDR +8 ); } -#define SIZE (x) (sizeof(x)/sizeof((x)[0])) +#define SIZE (x) ARRAY_SIZE(x)#if 0 /* selftest or dump */
drivers/net/ne.c +1 -1
@@ -379,7 +379,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) {E8390_RREAD+E8390_START, E8390_CMD}, }; -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (program_seq); i++)outb_p (program_seq[i].value, ioaddr + program_seq[i].offset); }
drivers/net/ne2.c +1 -1
@@ -432,7 +432,7 @@ static int __init ne2_probe1(struct net_device *dev, int slot) {E8390_RREAD+E8390_START, E8390_CMD}, }; -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (program_seq); i++)outb_p (program_seq[i].value, base_addr + program_seq[i].offset);
drivers/net/ne2k-pci.c +1 -1
@@ -309,7 +309,7 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev, {0x00, EN0_RSARHI}, {E8390_RREAD+E8390_START, E8390_CMD}, }; -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (program_seq); i++)outb (program_seq[i].value, ioaddr + program_seq[i].offset); }
drivers/net/netxen/netxen_nic_hw.c +1 -1
@@ -395,7 +395,7 @@ int netxen_is_flash_supported(struct netxen_adapter *adapter)/* if the flash size less than 4Mb, make huge war cry and die */ for (j =1 ; j <4 ; j++) { addr = j *NETXEN_NIC_WINDOW_MARGIN ; -for (i =0 ; i < (sizeof (locs) /sizeof (locs[0 ])); i++) { +for (i =0 ; i <ARRAY_SIZE (locs); i++) {if (netxen_rom_fast_read (adapter, locs[i], &val01) ==0 &&netxen_rom_fast_read (adapter, (addr + locs[i]), &val02) ==0 ) {
drivers/net/pcmcia/axnet_cs.c +1 -1
@@ -232,7 +232,7 @@ static int get_prom(struct pcmcia_device *link)axnet_reset_8390 (dev);mdelay (10 ); -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (program_seq); i++)outb_p (program_seq[i].value, ioaddr + program_seq[i].offset);for (i =0 ; i <6 ; i +=2 ) {
drivers/net/pcmcia/pcnet_cs.c +1 -1
@@ -375,7 +375,7 @@ static hw_info_t *get_prom(struct pcmcia_device *link)pcnet_reset_8390 (dev);mdelay (10 ); -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (program_seq); i++)outb_p (program_seq[i].value, ioaddr + program_seq[i].offset);for (i =0 ; i <32 ; i++)
drivers/net/sk98lin/skgemib.c +3 -1
@@ -22,6 +22,8 @@* ******************************************************************************/ +#include <linux/kernel.h> +/* * PRIVATE OID handler function prototypes */
@@ -82,7 +84,7 @@ PNMI_STATIC int DiagActions(SK_AC *pAC, SK_IOC IoC, int action, SK_U32 Id,/* defines *******************************************************************/ -#define ID_TABLE_SIZE (sizeof(IdTable)/sizeof(IdTable[0])) +#define ID_TABLE_SIZE ARRAY_SIZE(IdTable)/* global variables **********************************************************/
drivers/net/sk98lin/skgesirq.c +2 -1
@@ -51,6 +51,7 @@ static const char SysKonnectFileId[] ="@(#) $Id: skgesirq.c,v 1.92 2003/09/16 14:37:07 rschmidt Exp $ (C) Marvell." ;#endif +#include <linux/kernel.h> #include "h/skdrv1st.h" /* Driver Specific Definitions */ #ifndef SK_SLIM #include "h/skgepnmi.h" /* PNMI Definitions */
@@ -892,7 +893,7 @@ int Port) /* Which port should be checked */*/ RxCts =0 ; -for (i =0 ; i <sizeof (SkGeRxRegs)/sizeof (SkGeRxRegs[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (SkGeRxRegs); i++) { (void )SkXmMacStatistic (pAC, IoC, Port, SkGeRxRegs[i], &RxTmp);
drivers/net/skfp/smt.c +2 -1
@@ -14,6 +14,7 @@* ******************************************************************************/ +#include <linux/kernel.h> #include "h/types.h" #include "h/fddi.h" #include "h/smc.h"
@@ -1655,7 +1656,7 @@ static const struct smt_pdef { { SMT_P4053, 0, SWAP_SMT_P4053 } , } ; -#define N_SMT_PLEN (sizeof(smt_pdef)/sizeof(smt_pdef[0])) +#define N_SMT_PLEN ARRAY_SIZE(smt_pdef)int smt_check_para (struct s_smc *smc,struct smt_header *sm,const u_short list[])
drivers/net/skfp/srf.c +4 -2
@@ -19,6 +19,8 @@SRF state machine and frame generation */ +#include <linux/kernel.h> +#include "h/types.h" #include "h/fddi.h" #include "h/smc.h"
@@ -43,7 +45,7 @@ static void clear_reported(struct s_smc *smc);static void smt_send_srf (struct s_smc *smc);static struct s_srf_evc *smt_get_evc (struct s_smc *smc,int code,int index); -#define MAX_EVCS (sizeof(smc->evcs)/sizeof(smc->evcs[0])) +#define MAX_EVCS ARRAY_SIZE(smc->evcs)struct evc_init {u_char code ;
@@ -67,7 +69,7 @@ static const struct evc_init evc_inits[] = { { SMT_EVENT_PORT_PATH_CHANGE, INDEX_PORT,NUMPHYS,SMT_P4053 } , } ; -#define MAX_INIT_EVC (sizeof(evc_inits)/sizeof(evc_inits[0])) +#define MAX_INIT_EVC ARRAY_SIZE(evc_inits)void smt_init_evc (struct s_smc *smc) {
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 ipw2100: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in kernel.h.
---
Patch is compile tested.
drivers/net/wireless/ipw2100.c +6 -8
@@ -2888,7 +2888,7 @@ static int __ipw2100_tx_process(struct ipw2100_priv *priv)#ifdef CONFIG_IPW2100_DEBUG if (packet->info.c_struct.cmd->host_command_reg < -sizeof (command_types) /sizeof (*command_types)) +ARRAY_SIZE (command_types)) IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n", command_types[packet->info.c_struct.cmd-> host_command_reg],
@@ -3736,7 +3736,7 @@ static ssize_t show_registers(struct device *d, struct device_attribute *attr, out +=sprintf (out,"%30s [Address ] : Hex\n" ,"Register" ); -for (i =0 ; i < (sizeof (hw_data) /sizeof (*hw_data)); i++) { +for (i =0 ; i <ARRAY_SIZE (hw_data); i++) {read_register (dev, hw_data[i].addr, &val); out +=sprintf (out,"%30s [%08X] : %08X\n" , hw_data[i].name, hw_data[i].addr, val);
@@ -3757,7 +3757,7 @@ static ssize_t show_hardware(struct device *d, struct device_attribute *attr, out +=sprintf (out,"%30s [Address ] : Hex\n" ,"NIC entry" ); -for (i =0 ; i < (sizeof (nic_data) /sizeof (*nic_data)); i++) { +for (i =0 ; i <ARRAY_SIZE (nic_data); i++) {u8 tmp8;u16 tmp16;u32 tmp32;
@@ -3894,13 +3894,11 @@ static ssize_t show_ordinals(struct device *d, struct device_attribute *attr,if (priv->status &STATUS_RF_KILL_MASK )return 0 ; -if (loop >=sizeof (ord_data) /sizeof (*ord_data)) +if (loop >=ARRAY_SIZE (ord_data)) loop =0 ;/* sysfs provides us PAGE_SIZE buffer */ -while (len <PAGE_SIZE -128 && - loop < (sizeof (ord_data) /sizeof (*ord_data))) { - +while (len <PAGE_SIZE -128 && loop <ARRAY_SIZE (ord_data)) { val_len =sizeof (u32); if (ipw2100_get_ordinal(priv, ord_data[loop].index, &val,
@@ -6589,7 +6587,7 @@ static const long ipw2100_rates_11b[] = {11000000 }; -#define RATE_COUNT (sizeof(ipw2100_rates_11b) / sizeof(ipw2100_rates_11b[0])) +#define RATE_COUNT ARRAY_SIZE(ipw2100_rates_11b) static int ipw2100_wx_get_name(struct net_device *dev, struct iw_request_info *info,
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 2/2 misc-net-drivers: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi,
A 2.6.20 patch to use ARRAY_SIZE macro already defined in kernel.h for some miscellaneous network drivers with no specific maintaners.
---
Patch isn't compile-tested due to missing hardware.
drivers/net/apne.c +1 -1
@@ -247,7 +247,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr) {0x00, NE_EN0_RSARHI}, {E8390_RREAD+E8390_START, NE_CMD}, }; -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (program_seq); i++) {outb (program_seq[i].value, ioaddr + program_seq[i].offset); }
drivers/net/arm/am79c961a.c +1 -1
@@ -414,7 +414,7 @@ static void am79c961_setmulticastlist (struct net_device *dev)/* * Update the multicast hash table */ -for (i =0 ; i <sizeof (multi_hash) /sizeof (multi_hash[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (multi_hash); i++)write_rreg (dev->base_addr, i +LADRL , multi_hash[i]);/*
drivers/net/atarilance.c +1 -1
@@ -263,7 +263,7 @@ struct lance_addr {(highest byte stripped) */ }; -#define N_LANCE_ADDR (sizeof(lance_addr_list)/sizeof(*lance_addr_list)) +#define N_LANCE_ADDR ARRAY_SIZE(lance_addr_list)/* Definitions for the Lance */
drivers/net/fec_8xx/fec_mii.c +2 -2
@@ -310,12 +310,12 @@ int fec_mii_phy_id_detect(struct net_device *dev)return -1 ; } -for (i =0 , phy = phy_info; i <sizeof (phy_info) /sizeof (phy_info[0 ]); + for (i = 0, phy = phy_info; i < ARRAY_SIZE(phy_info)); i++, phy++)if (phy->id == (phy_hwid >>4 ) || phy->id ==0 )break ; -if (i >=sizeof (phy_info) /sizeof (phy_info[0 ])) { +if (i >=ARRAY_SIZE (phy_info)) { printk(KERN_ERR DRV_MODULE_NAME": %s PHY id 0x%08x is not supported!\n" , dev->name, phy_hwid);
drivers/net/ne-h8300.c +1 -1
@@ -259,7 +259,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) {E8390_RREAD+E8390_START, E8390_CMD}, }; -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (program_seq); i++)outb_p (program_seq[i].value, ioaddr + program_seq[i].offset); }
drivers/net/zorro8390.c +1 -1
@@ -191,7 +191,7 @@ static int __devinit zorro8390_init(struct net_device *dev, {0x00, NE_EN0_RSARHI}, {E8390_RREAD+E8390_START, NE_CMD}, }; -for (i =0 ; i <sizeof (program_seq)/sizeof (program_seq[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (program_seq); i++) {z_writeb (program_seq[i].value, ioaddr + program_seq[i].offset); } }
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 misc-wireless: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi,
A patch to use ARRAY_SIZE macro already defined in kernel.h for some miscellaneous wireless drivers with no specific maintaners.
---
Patch is compile tested.
drivers/net/wireless/airo.c +2 -2
@@ -1623,7 +1623,7 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,crypto_cipher_setkey (tfm, pkey,16 ); counter =0 ; -for (i =0 ; i < (sizeof (context->coeff)/sizeof (context->coeff[0 ])); ) { +for (i =0 ; i <ARRAY_SIZE (context->coeff); ) { aes_counter[15 ] = (u8)(counter >>0 ); aes_counter[14 ] = (u8)(counter >>8 ); aes_counter[13 ] = (u8)(counter >>16 );
@@ -1632,7 +1632,7 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen,memcpy (plain, aes_counter,16 );crypto_cipher_encrypt_one (tfm, plain, plain); cipher = plain; -for (j=0 ; (j<16 ) && (i< (sizeof (context->coeff)/sizeof (context->coeff[0 ]))); ) { +for (j =0 ; (j <16 ) && (i <ARRAY_SIZE (context->coeff)); ) { context->coeff[i++] =ntohl (*(u32 *)&cipher[j]); j +=4 ; }
drivers/net/wireless/prism54/oid_mgt.c +3 -1
@@ -16,6 +16,8 @@* */ +#include <linux/kernel.h> +#include "prismcompat.h" #include "islpci_dev.h" #include "islpci_mgt.h"
@@ -692,7 +694,7 @@ mgt_update_addr(islpci_private *priv)return ret; } -#define VEC_SIZE (a) (sizeof(a)/sizeof(a[0])) +#define VEC_SIZE (a) ARRAY_SIZE(a)int mgt_commit (islpci_private *priv)
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 hostap: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi,
A patch to use ARRAY_SIZE macro in the Host AP wireless driver.
---
Patch is compile tested.
drivers/net/wireless/hostap/hostap.h +2 -1
@@ -2,13 +2,14 @@#define HOSTAP_H #include <linux/ethtool.h> +#include <linux/kernel.h> #include "hostap_wlan.h" #include "hostap_ap.h" static const long freq_list[] = {2412 ,2417 ,2422 ,2427 ,2432 ,2437 ,2442 ,2447 ,2452 ,2457 ,2462 ,2467 ,2472 ,2484 }; -#define FREQ_COUNT (sizeof(freq_list) / sizeof(freq_list[0])) +#define FREQ_COUNT ARRAY_SIZE(freq_list)/* hostap.c */
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 ibm_emac: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi,
A patch to use ARRAY_SIZE macro already defined in kernel.h.
---
Patch isn't compile-tested cause I don't have the needed hardware.
drivers/net/ibm_emac/ibm_emac_debug.c +4 -4
@@ -132,7 +132,7 @@ void emac_dbg_register(int idx, struct ocp_enet_private *dev) {unsigned long flags; -if (idx >=sizeof (__emacs) /sizeof (__emacs[0 ])) { +if (idx >=ARRAY_SIZE (__emacs)) {printk (KERN_WARNING "invalid index %d when registering EMAC for debugging\n" , idx);
@@ -148,7 +148,7 @@ void mal_dbg_register(int idx, struct ibm_ocp_mal *mal) {unsigned long flags; -if (idx >=sizeof (__mals) /sizeof (__mals[0 ])) { +if (idx >=ARRAY_SIZE (__mals)) {printk (KERN_WARNING "invalid index %d when registering MAL for debugging\n" , idx);
@@ -167,11 +167,11 @@ void emac_dbg_dump_all(void)local_irq_save (flags); -for (i =0 ; i <sizeof (__mals) /sizeof (__mals[0 ]); ++i) +for (i =0 ; i <ARRAY_SIZE (__mals); ++i)if (__mals[i])emac_mal_dump (__mals[i]); -for (i =0 ; i <sizeof (__emacs) /sizeof (__emacs[0 ]); ++i) +for (i =0 ; i <ARRAY_SIZE (__emacs); ++i)if (__emacs[i])emac_mac_dump (i, __emacs[i]);
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 ixgb: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi,
A patch to use ARRAY_SIZE macro already defined in kernel.h.
---
drivers/net/ixgb/ixgb_param.c +1 -1
@@ -245,7 +245,7 @@ ixgb_validate_option(int *value, struct ixgb_option *opt)return -1 ; } -#define LIST_LEN (l) (sizeof(l) / sizeof(l[0])) +#define LIST_LEN (l) ARRAY_SIZE(l)/** * ixgb_check_options - Range Checking for Command Line Parameters
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 wavelan: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi,
A trivial patch to use ARRAY_SIZE macro.
---
drivers/net/wireless/wavelan.p.h +1 -1
@@ -450,7 +450,7 @@ static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12/#define WATCHDOG_JIFFIES (512*HZ/100)/* Macro to get the number of elements in an array */ -#define NELS (a) (sizeof(a) / sizeof(a[0])) +#define NELS (a) ARRAY_SIZE(a)/* ------------------------ PRIVATE IOCTL ------------------------ */
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Re: [PATCH 2.6.20] wavelan: Use ARRAY_SIZE macro when appropriate
Quoted 1 line · Ahmed S. Darwish
A trivial patch to use
ARRAY_SIZEmacro.
You're supposed to remove it ans use ARRAY_SIZE where old macro is used.
Quoted 8 lines
drivers/net/wireless/wavelan.p.h +1
-1@@ -450,7 +450,7 @@ static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12/#define WATCHDOG_JIFFIES (512*HZ/100)/* Macro to get the number of elements in an array */ -#define NELS (a) (sizeof(a) / sizeof(a[0])) +#define NELS (a) ARRAY_SIZE(a)
Re: [PATCH 2.6.20] ixgb: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishQuoted 1 line · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inkernel.h.
Remove it and use ARRAY_SIZE instead.
Quoted 8 lines
drivers/net/ixgb/ixgb_param.c +1
-1@@ -245,7 +245,7 @@ ixgb_validate_option(int *value, struct ixgb_option *opt)return -1 ; } -#define LIST_LEN (l) (sizeof(l) / sizeof(l[0])) +#define LIST_LEN (l) ARRAY_SIZE(l)
Re: [PATCH 2.6.20] ibm_emac: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishQuoted 1 line · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inkernel.h.
OK, but checks you're changing are strange. idx there is signed so
BUG_ON(idx < 0 || idx > ARRAY_SIZE());
should be more appropriate.
drivers/net/ibm_emac/ibm_emac_debug.c void emac_dbg_register(int idx, struct ocp_enet_private *dev) · line 135
Quoted 8 lines
drivers/net/ibm_emac/ibm_emac_debug.c +1
-1@@ -132,7 +132,7 @@ void emac_dbg_register(int idx, struct ocp_enet_private *dev) {unsigned long flags; -if (idx >=sizeof (__emacs) /sizeof (__emacs[0 ])) { +if (idx >=ARRAY_SIZE (__emacs)) {
no __vi, no cookie. :)
Quoted 12 lines
drivers/net/ibm_emac/ibm_emac_debug.c +1
-1printk (KERN_WARNING "invalid index %d when registering EMAC for debugging\n" , idx);@@ -148,7 +148,7 @@ void mal_dbg_register(int idx, struct ibm_ocp_mal *mal) {unsigned long flags; -if (idx >=sizeof (__mals) /sizeof (__mals[0 ])) { +if (idx >=ARRAY_SIZE (__mals)) {printk (KERN_WARNING "invalid index %d when registering MAL for debugging\n" , idx);
Re: [PATCH 2.6.20] ixgb: Use ARRAY_SIZE macro when appropriate
In reply to Alexey DobriyanQuoted 5 lines · Alexey Dobriyan
Quoted 1 line · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inkernel.h.Remove it and use
ARRAY_SIZEinstead.
Quoted 8 lines
drivers/net/ixgb/ixgb_param.c ixgb_validate_option(int *value, struct ixgb_option *opt) · line 248
Quoted 8 lines
drivers/net/ixgb/ixgb_param.c +1
-1@@ -245,7 +245,7 @@ ixgb_validate_option(int *value, struct ixgb_option *opt)return -1 ; } -#define LIST_LEN (l) (sizeof(l) / sizeof(l[0])) +#define LIST_LEN (l) ARRAY_SIZE(l)
yes, well spotted. Please change line 338 in this file to read:
.arg = { .l = { .nr = ARRAY_SIZE(fc_list),instead, so you can remove the LIST_LEN macro completely.
Thanks,
Auke
Re: [PATCH 2.6.20] ibm_emac: Use ARRAY_SIZE macro when appropriate
In reply to Alexey DobriyanQuoted 8 lines · Alexey Dobriyan
Quoted 1 line · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inkernel.h.OK, but checks you're changing are strange. idx there is signed so
BUG_ON(idx < 0 || idx > ARRAY_SIZE());should be more appropriate.
It's just a janitor patch. I don't like to mess with code logic in such kind of patches (to minimize errors and because I can't find time to understand all affected files since they are scattered allover the tree).
Thanks,
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Re: [PATCH 2.6.20] wavelan: Use ARRAY_SIZE macro when appropriate
In reply to Alexey DobriyanQuoted 5 lines · Alexey Dobriyan
Quoted 1 line · Ahmed S. Darwish
A trivial patch to use
ARRAY_SIZEmacro.You're supposed to remove it ans use
ARRAY_SIZEwhere old macro is used.
Quoted 8 lines
drivers/net/wireless/wavelan.p.h static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12/ · line 453
Quoted 8 lines
drivers/net/wireless/wavelan.p.h +1
-1@@ -450,7 +450,7 @@ static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12/#define WATCHDOG_JIFFIES (512*HZ/100)/* Macro to get the number of elements in an array */ -#define NELS (a) (sizeof(a) / sizeof(a[0])) +#define NELS (a) ARRAY_SIZE(a)
Ooh, how dumb the original patch is :). Thanks, here's the modified patch.
A patch to use ARRAY_SIZE macro when appropriate.
---
drivers/net/wireless/wavelan.c +7 -7
@@ -28,7 +28,7 @@*/ static u8 wv_irq_to_psa (int irq) { -if (irq <0 || irq >=NELS (irqvals)) +if (irq <0 || irq >=ARRAY_SIZE (irqvals))return 0 ;return irqvals[irq];
@@ -42,7 +42,7 @@ static int __init wv_psa_to_irq(u8 irqval) {int irq; -for (irq =0 ; irq <NELS (irqvals); irq++) +for (irq =0 ; irq <ARRAY_SIZE (irqvals); irq++)if (irqvals[irq] == irqval)return irq;
@@ -1695,7 +1695,7 @@ static int wv_frequency_list(unsigned long ioaddr, /* I/O port of the card *//* Look in the table if the frequency is allowed */ if (table[9 - (freq /16 )] & (1 << (freq %16 ))) {/* Compute approximate channel number */ -while ((c <NELS (channel_bands)) && +while ((c <ARRAY_SIZE (channel_bands)) && (((channel_bands[c] >>1 ) -24 ) < freq)) c++; list[i].i = c;/* Set the list index */
@@ -4269,7 +4269,7 @@ struct net_device * __init wavelan_probe(int unit)printk (KERN_DEBUG "%s: <-wavelan_probe()\n" , dev->name);#endif }else {/* Scan all possible addresses of the WaveLAN hardware. */ -for (i =0 ; i <NELS (iobase); i++) { +for (i =0 ; i <ARRAY_SIZE (iobase); i++) { dev->irq = def_irq;if (wavelan_config (dev, iobase[i]) ==0 ) {#ifdef DEBUG_CALLBACK_TRACE
@@ -4280,7 +4280,7 @@ struct net_device * __init wavelan_probe(int unit)break ; } } -if (i ==NELS (iobase)) +if (i ==ARRAY_SIZE (iobase)) r = -ENODEV ; }if (r)
@@ -4327,14 +4327,14 @@ int __init init_module(void)#endif /* Copy the basic set of address to be probed. */ -for (i =0 ; i <NELS (iobase); i++) +for (i =0 ; i <ARRAY_SIZE (iobase); i++) io[i] = iobase[i]; }/* Loop on all possible base addresses. */ i =-1 ; -while ((io[++i] !=0 ) && (i <NELS (io))) { +while ((io[++i] !=0 ) && (i <ARRAY_SIZE (io))) {struct net_device *dev =alloc_etherdev (sizeof (net_local));if (!dev)break ;
drivers/net/wireless/wavelan.p.h +0 -3
@@ -449,9 +449,6 @@ static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12//* Watchdog temporisation */ #define WATCHDOG_JIFFIES (512*HZ/100) -/* Macro to get the number of elements in an array */ -#define NELS (a) (sizeof(a) / sizeof(a[0])) -/* ------------------------ PRIVATE IOCTL ------------------------ */ #define SIOCSIPQTHR SIOCIWFIRSTPRIV/* Set quality threshold */
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Re: [PATCH 2.6.20] ixgb: Use ARRAY_SIZE macro when appropriate
In reply to Auke KokQuoted 13 lines · Auke Kok
Quoted 12 lines · Alexey Dobriyan
Quoted 1 line · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inkernel.h.Remove it and use
ARRAY_SIZEinstead.Quoted 7 lines
drivers/net/ixgb/ixgb_param.c +0
-0@@ -245,7 +245,7 @@ ixgb_validate_option(int *value, struct ixgb_option *opt)return -1 ; }
Quoted 8 lines
Quoted 2 lines
drivers/net/ixgb/ixgb_param.c ixgb_validate_option(int *value, struct ixgb_option · line 249
Quoted 2 lines
drivers/net/ixgb/ixgb_param.c +1
-1-#define LIST_LEN (l) (sizeof(l) / sizeof(l[0])) +#define LIST_LEN (l) ARRAY_SIZE(l)yes, well spotted. Please change line 338 in this file to read:
.arg = { .l = { .nr = ARRAY_SIZE(fc_list),instead, so you can remove the
LIST_LENmacro completely.
Thanks, Here's the new patch.
Use ARRAY_SIZE macro when appropriate.
---
drivers/net/ixgb/ixgb_param.c +1 -3
@@ -245,8 +245,6 @@ ixgb_validate_option(int *value, struct ixgb_option *opt)return -1 ; } -#define LIST_LEN (l) (sizeof(l) / sizeof(l[0])) -/** * ixgb_check_options - Range Checking for Command Line Parameters * @adapter: board private structure
@@ -335,7 +333,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) .name = "Flow Control", .err = "reading default settings from EEPROM", .def = ixgb_fc_tx_pause, - .arg = { .l = { .nr = LIST_LEN(fc_list), + .arg = { .l = { .nr = ARRAY_SIZE(fc_list), .p = fc_list }} };
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Auke Kok
Acked-byRe: [PATCH 2.6.20] ixgb: Use ARRAY_SIZE macro when appropriate
Quoted 19 lines · Ahmed S. Darwish
Quoted 18 lines · Auke Kok
Quoted 11 lines · Alexey Dobriyan
Quoted 1 line · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inkernel.h.Remove it and use
ARRAY_SIZEinstead.Quoted 7 lines
drivers/net/ixgb/ixgb_param.c +0
-0@@ -245,7 +245,7 @@ ixgb_validate_option(int *value, struct ixgb_option *opt)return -1 ; }Quoted 2 lines
drivers/net/ixgb/ixgb_param.c ixgb_validate_option(int *value, struct ixgb_option · line 249
Quoted 2 lines
drivers/net/ixgb/ixgb_param.c +1
-1-#define LIST_LEN (l) (sizeof(l) / sizeof(l[0])) +#define LIST_LEN (l) ARRAY_SIZE(l)yes, well spotted. Please change line 338 in this file to read:
.arg = { .l = { .nr = ARRAY_SIZE(fc_list),
Quoted 7 lines
Quoted 1 line
instead, so you can remove the
LIST_LENmacro completely.Thanks, Here's the new patch.
Use
ARRAY_SIZEmacro when appropriate.Signed-off-by Ahmed S. Darwish <[email protected]>
Cheers,
Auke
Quoted 24 lines
---
drivers/net/ixgb/ixgb_param.c +1
-3@@ -245,8 +245,6 @@ ixgb_validate_option(int *value, struct ixgb_option *opt)return -1 ; } -#define LIST_LEN (l) (sizeof(l) / sizeof(l[0])) -/** * ixgb_check_options - Range Checking for Command Line Parameters * @adapter: board private structure @@ -335,7 +333,7 @@ ixgb_check_options(struct ixgb_adapter *adapter) .name = "Flow Control", .err = "reading default settings from EEPROM", .def = ixgb_fc_tx_pause, - .arg = { .l = { .nr = LIST_LEN(fc_list), + .arg = { .l = { .nr = ARRAY_SIZE(fc_list), .p = fc_list }} };
Re: [PATCH 2.6.20] e1000: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishQuoted 5 lines · Ahmed S. Darwish
Hi,
A patch to use
ARRAY_SIZEmacro already defined inkernel.h.Signed-off-by Ahmed S. Darwish <[email protected]>
Cheers,
Auke
Quoted 17 lines
---
Patch is compile tested.drivers/net/e1000/e1000_ethtool.c +1
-1@@ -746,7 +746,7 @@ err_setup:uint32_t pat, value; \uint32_t test[] = \ {0x5A5A5A5A ,0xA5A5A5A5 ,0x00000000 ,0xFFFFFFFF }; \ -for (pat =0 ; pat <sizeof (test)/sizeof (test[0 ]); pat++) { \ +for (pat =0 ; pat <ARRAY_SIZE (test); pat++) { \E1000_WRITE_REG (&adapter->hw,R , (test[pat] &W )); \ value =E1000_READ_REG (&adapter->hw,R ); \if (value != (test[pat] &W &M )) { \