A series of patches to use ARRAY_SIZE macro under arch/
Subsystems (5)
PATCH 1/1 A series of patches to use ARRAY_SIZE macro under arch/
Hi, all
A series of patches to use ARRAY_SIZE macro under the `arch' subtree. Each architecture has its own mail/patch as a reply to this thread. Those patches are not compile-tested as I don't have needed machines but I tried hard to make sure that they are hopefully correct. Patches can be applied cleanly on 2.6.20.
arm/kernel/ecard.c | 2 +- arm26/kernel/ecard.c | 2 +- avr32/kernel/setup.c | 4 ++-- cris/arch-v10/drivers/axisflashmap.c | 3 +-- cris/mm/tlb.c | 3 ++- m68k/kernel/ptrace.c | 4 ++-- m68k/kernel/traps.c | 2 +- m68knommu/kernel/ptrace.c | 4 ++-- m68knommu/kernel/traps.c | 2 +- mips/arc/identify.c | 2 +- mips/jmr3927/rbhma3100/setup.c | 2 +- mips/mips-boards/atlas/atlas_int.c | 5 +++-- mips/mips-boards/malta/malta_int.c | 5 +++-- mips/pci/fixup-vr4133.c | 3 ++- powerpc/lib/rheap.c | 3 ++- powerpc/xmon/ppc-opc.c | 7 +++---- powerpc/xmon/spu-opc.c | 4 ++-- ppc/lib/rheap.c | 3 ++- ppc/syslib/m8xx_setup.c | 2 +- ppc/xmon/ppc-opc.c | 7 +++---- v850/kernel/anna.c | 2 +- v850/kernel/as85ep1.c | 2 +- v850/kernel/fpga85e2c.c | 2 +- v850/kernel/gbus_int.c | 6 +++--- v850/kernel/ma.c | 2 +- v850/kernel/me2.c | 2 +- v850/kernel/rte_cb.c | 4 ++-- v850/kernel/rte_mb_a_pci.c | 3 +-- v850/kernel/rte_me2_cb.c | 3 +-- v850/kernel/teg.c | 2 +- 30 files changed, 49 insertions(+), 48 deletions(-)
Thanks,
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 arch CRIS: user ARRAY_SIZE macro when appropriate
Hi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked since I have no CRIS machine at hand.
arch/cris/arch-v10/drivers/axisflashmap.c +1 -2
@@ -359,8 +359,7 @@ static struct mtd_info *flash_probe(void)* So we use the MTD concatenation layer instead of further * complicating the probing procedure. */ - mtd_cse =mtd_concat_create (mtds, -sizeof (mtds) /sizeof (mtds[0 ]), + mtd_cse =mtd_concat_create (mtds,ARRAY_SIZE (mtds),"cse0+cse1" );#else printk(KERN_ERR "%s and %s: Cannot concatenate due to kernel "
arch/cris/mm/tlb.c +2 -1
@@ -8,6 +8,7 @@*/ #include <linux/init.h> +#include <linux/kernel.h> #include <asm/tlb.h> #define D (x)
@@ -100,7 +101,7 @@ tlb_init(void)/* clear the page_id map */ -for (i =1 ; i <sizeof (page_id_map) /sizeof (page_id_map[0 ]); i++) +for (i =1 ; i <ARRAY_SIZE (page_id_map); i++) page_id_map[i] =NULL ;/* invalidate the entire TLB */
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 arch AVR32: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi Haavard,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked cause I have no AVR32 machine at hand. Thanks,
arch/avr32/kernel/setup.c +2 -2
@@ -16,6 +16,7 @@#include <linux/module.h> #include <linux/root_dev.h> #include <linux/cpu.h> +#include <linux/kernel.h> #include <asm/sections.h> #include <asm/processor.h>
@@ -174,8 +175,7 @@ static int __init parse_tag_mem_range(struct tag *tag,* Copy the data so the bootmem init code doesn't need to care * about it. */ -if (mem_range_next_free >= - (sizeof (mem_range_cache) /sizeof (mem_range_cache[0 ]))) +if (mem_range_next_free >=ARRAY_SIZE (mem_range_cache))panic ("Physical memory map too complex!\n" ); new = &mem_range_cache[mem_range_next_free++];
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Re: [PATCH 2.6.20] arch AVR32: Use ARRAY_SIZE macro when appropriate
Quoted 5 lines · On Mon, 5 Feb 2007 04:41:27 +0200 "Ahmed S. Darwish" <[email protected]>…
Hi Haavard,
A patch to use
ARRAY_SIZEmacro already defined inlinux/kernel.hSigned-off-by Ahmed S. Darwish <[email protected]>
I'll queue this up for the next merge. Thanks.
Haavard
PATCH 1/1 arch M68KNOMMU: user ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked cause I have no M68KNOMMU board at hand. Thanks,
arch/m68knommu/kernel/ptrace.c +2 -2
@@ -62,7 +62,7 @@ static inline long get_reg(struct task_struct *task, int regno)if (regno ==PT_USP ) addr = &task->thread.usp; -else if (regno <sizeof (regoff)/sizeof (regoff[0 ])) +else if (regno <ARRAY_SIZE (regoff)) addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);else return 0 ;
@@ -79,7 +79,7 @@ static inline int put_reg(struct task_struct *task, int regno,if (regno ==PT_USP ) addr = &task->thread.usp; -else if (regno <sizeof (regoff)/sizeof (regoff[0 ])) +else if (regno <ARRAY_SIZE (regoff)) addr = (unsigned long *) (task->thread.esp0 + regoff[regno]);else return -1 ;
arch/m68knommu/kernel/traps.c +1 -1
@@ -158,7 +158,7 @@ void show_stack(struct task_struct *task, unsigned long *stack)void bad_super_trap (struct frame *fp) {console_verbose (); -if (fp->ptregs.vector <4 *sizeof (vec_names)/sizeof (vec_names[0 ])) +if (fp->ptregs.vector <4 *ARRAY_SIZE (vec_names))printk (KERN_WARNING "*** %s *** FORMAT=%X\n" , vec_names[(fp->ptregs.vector) >>2 ], fp->ptregs.format);
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Re: [PATCH 2.6.20] arch M68KNOMMU: user ARRAY_SIZE macro when appropriate
Hi Ahmed,
Quoted 5 lines · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inlinux/kernel.hSigned-off-by Ahmed S. Darwish <[email protected]>---
Patch isn't compile checked cause I have no M68KNOMMU board at hand.
Compiled and tested on m68knommu, no problems.
Regards
Greg
Quoted 36 lines
arch/m68knommu/kernel/ptrace.c +2
-2@@ -62,7 +62,7 @@ static inline long get_reg(struct task_struct *task, int regno)if (regno ==PT_USP ) addr = &task->thread.usp; -else if (regno <sizeof (regoff)/sizeof (regoff[0 ])) +else if (regno <ARRAY_SIZE (regoff)) addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);else return 0 ;@@ -79,7 +79,7 @@ static inline int put_reg(struct task_struct *task, int regno,if (regno ==PT_USP ) addr = &task->thread.usp; -else if (regno <sizeof (regoff)/sizeof (regoff[0 ])) +else if (regno <ARRAY_SIZE (regoff)) addr = (unsigned long *) (task->thread.esp0 + regoff[regno]);else return -1 ;arch/m68knommu/kernel/traps.c +1
-1@@ -158,7 +158,7 @@ void show_stack(struct task_struct *task, unsigned long *stack)void bad_super_trap (struct frame *fp) {console_verbose (); -if (fp->ptregs.vector <4 *sizeof (vec_names)/sizeof (vec_names[0 ])) +if (fp->ptregs.vector <4 *ARRAY_SIZE (vec_names))printk (KERN_WARNING "*** %s *** FORMAT=%X\n" , vec_names[(fp->ptregs.vector) >>2 ], fp->ptregs.format);
Signature · 5 lines
------------------------------------------------------------------------ Greg Ungerer -- Chief Software Dude EMAIL: [email protected] SnapGear -- a Secure Computing Company PHONE: +61 7 3435 2888 825 Stanley St, FAX: +61 7 3891 3630 Woolloongabba, QLD, 4102, Australia WEB: http://www.SnapGear.com
PATCH 1/1 arch MIPS: user ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked cause I have no MIPS board at hand. Thanks,
arch/mips/jmr3927/rbhma3100/setup.c +1 -1
@@ -434,7 +434,7 @@ void __init tx3927_setup(void)/* DMA */ tx3927_dmaptr->mcr =0 ; -for (i =0 ; i <sizeof (tx3927_dmaptr->ch) /sizeof (tx3927_dmaptr->ch[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (tx3927_dmaptr->ch); i++) {/* reset channel */ tx3927_dmaptr->ch[i].ccr =TX3927_DMA_CCR_CHRST ; tx3927_dmaptr->ch[i].ccr =0 ;
arch/mips/arc/identify.c +1 -1
@@ -77,7 +77,7 @@ static struct smatch * __init string_to_mach(const char *s) {int i; -for (i =0 ; i < (sizeof (mach_table) /sizeof (mach_table[0 ])); i++) { +for (i =0 ; i <ARRAY_SIZE (mach_table); i++) {if (!strcmp (s, mach_table[i].arcname))return &mach_table[i]; }
arch/mips/mips-boards/atlas/atlas_int.c +3 -2
@@ -32,6 +32,7 @@#include <linux/slab.h> #include <linux/interrupt.h> #include <linux/kernel_stat.h> +#include <linux/kernel.h> #include <asm/gdb-stub.h> #include <asm/io.h>
@@ -220,7 +221,7 @@ msc_irqmap_t __initdata msc_irqmap[] = { {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0}, {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0}, }; -int __initdata msc_nr_irqs =sizeof (msc_irqmap) /sizeof (*msc_irqmap); +int __initdata msc_nr_irqs =ARRAY_SIZE (msc_irqmap);msc_irqmap_t __initdata msc_eicirqmap[] = { {MSC01E_INT_SW0, MSC01_IRQ_LEVEL, 0},
@@ -231,7 +232,7 @@ msc_irqmap_t __initdata msc_eicirqmap[] = { {MSC01E_INT_PERFCTR, MSC01_IRQ_LEVEL, 0}, {MSC01E_INT_CPUCTR, MSC01_IRQ_LEVEL, 0} }; -int __initdata msc_nr_eicirqs =sizeof (msc_eicirqmap) /sizeof (*msc_eicirqmap); +int __initdata msc_nr_eicirqs =ARRAY_SIZE (msc_eicirqmap);void __init arch_init_irq (void ) {
arch/mips/mips-boards/malta/malta_int.c +3 -2
@@ -27,6 +27,7 @@#include <linux/slab.h> #include <linux/interrupt.h> #include <linux/kernel_stat.h> +#include <linux/kernel.h> #include <linux/random.h> #include <asm/i8259.h>
@@ -289,7 +290,7 @@ msc_irqmap_t __initdata msc_irqmap[] = { {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0}, {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0}, }; -int __initdata msc_nr_irqs =sizeof (msc_irqmap)/sizeof (msc_irqmap_t); +int __initdata msc_nr_irqs =ARRAY_SIZE (msc_irqmap);msc_irqmap_t __initdata msc_eicirqmap[] = { {MSC01E_INT_SW0, MSC01_IRQ_LEVEL, 0},
@@ -303,7 +304,7 @@ msc_irqmap_t __initdata msc_eicirqmap[] = { {MSC01E_INT_PERFCTR, MSC01_IRQ_LEVEL, 0}, {MSC01E_INT_CPUCTR, MSC01_IRQ_LEVEL, 0} }; -int __initdata msc_nr_eicirqs =sizeof (msc_eicirqmap)/sizeof (msc_irqmap_t); +int __initdata msc_nr_eicirqs =ARRAY_SIZE (msc_eicirqmap);void __init arch_init_irq (void ) {
arch/mips/pci/fixup-vr4133.c +2 -1
@@ -17,6 +17,7 @@*/ #include <linux/init.h> #include <linux/pci.h> +#include <linux/kernel.h> #include <asm/io.h> #include <asm/vr41xx/cmbvr4133.h>
@@ -142,7 +143,7 @@ int rockhopper_get_irq(struct pci_dev *dev, u8 pin, u8 slot)if (bus ==NULL )return -1 ; -for (i =0 ; i <sizeof (int_map) /sizeof (int_map[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (int_map); i++) {if (int_map[i].bus == bus->number && int_map[i].slot == slot) {int line;for (line =0 ; line <4 ; line++)
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Ralf Baechle
AppliedRe: [PATCH 2.6.20] arch MIPS: user ARRAY_SIZE macro when appropriate
Quoted 1 line · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inlinux/kernel.h
Thanks, applied.
Ralf
PATCH 1/1 arch V850: user ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked cause I have no V850 board at hand. Thanks,
arch/v850/kernel/anna.c +1 -1
@@ -114,7 +114,7 @@ static struct v850e_intc_irq_init irq_inits[] = { { "ST", IRQ_INTST(0), IRQ_INTST_NUM, 3, 5 }, { 0 } }; -#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1) +#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS ];
arch/v850/kernel/as85ep1.c +1 -1
@@ -142,7 +142,7 @@ static struct v850e_intc_irq_init irq_inits[] = { { "ST", IRQ_INTST(0), IRQ_INTST_NUM, 3, 5 }, { 0 } }; -#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1) +#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS ];
arch/v850/kernel/fpga85e2c.c +1 -1
@@ -138,7 +138,7 @@ struct v850e_intc_irq_init irq_inits[] = { { "RPU", IRQ_RPU(0), IRQ_RPU_NUM, 1, 6 }, { 0 } }; -#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1) +#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS ];
arch/v850/kernel/gbus_int.c +3 -3
@@ -16,6 +16,7 @@#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/signal.h> +#include <linux/kernel.h> #include <asm/machdep.h>
@@ -36,7 +37,7 @@ struct used_gint { { 1, GBUS_INT_PRIORITY_HIGH }, { 3, GBUS_INT_PRIORITY_LOW } }; -#define NUM_USED_GINTS (sizeof used_gint / sizeof used_gint[0]) +#define NUM_USED_GINTS ARRAY_SIZE(used_gint)/* A table of which GINT is used by each GBUS interrupts (they are assigned based on priority). */
@@ -231,8 +232,7 @@ struct gbus_int_irq_init gbus_irq_inits[] __initdata = { { "GBUS_INT", IRQ_GBUS_INT(0), IRQ_GBUS_INT_NUM, 1, 6}, { 0 } }; -#define NUM_GBUS_IRQ_INITS \ - ((sizeof gbus_irq_inits / sizeof gbus_irq_inits[0]) - 1) +#define NUM_GBUS_IRQ_INITS (ARRAY_SIZE(gbus_irq_inits) - 1)static struct hw_interrupt_type gbus_hw_itypes[NUM_GBUS_IRQ_INITS ];
arch/v850/kernel/ma.c +1 -1
@@ -43,7 +43,7 @@ static struct v850e_intc_irq_init irq_inits[] = { { "ST", IRQ_INTST(0), IRQ_INTST_NUM, 4, 5 }, { 0 } }; -#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1) +#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS ];
arch/v850/kernel/me2.c +1 -1
@@ -44,7 +44,7 @@ static struct v850e_intc_irq_init irq_inits[] = { { "UBTITO", IRQ_INTUBTITO(0), IRQ_INTUBTITO_NUM, 5, 4 }, { 0 } }; -#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1) +#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS ];
arch/v850/kernel/rte_cb.c +2 -2
@@ -15,6 +15,7 @@#include <linux/irq.h> #include <linux/fs.h> #include <linux/module.h> +#include <linux/kernel.h> #include <asm/machdep.h> #include <asm/v850e_uart.h>
@@ -176,8 +177,7 @@ static struct gbus_int_irq_init gbus_irq_inits[] = {#endif { 0 } }; -#define NUM_GBUS_IRQ_INITS \ - ((sizeof gbus_irq_inits / sizeof gbus_irq_inits[0]) - 1) +#define NUM_GBUS_IRQ_INITS (ARRAY_SIZE(gbus_irq_inits) - 1)static struct hw_interrupt_type gbus_hw_itypes[NUM_GBUS_IRQ_INITS ];
arch/v850/kernel/rte_mb_a_pci.c +1 -2
@@ -70,8 +70,7 @@ static struct mb_pci_dev_irq mb_pci_dev_irqs[] = {/* PCI slot 2 */ { 9, IRQ_MB_A_PCI2(0), 1 } }; -#define NUM_MB_PCI_DEV_IRQS \ - (sizeof mb_pci_dev_irqs / sizeof mb_pci_dev_irqs[0]) +#define NUM_MB_PCI_DEV_IRQS ARRAY_SIZE(mb_pci_dev_irqs)/* PCI configuration primitives. */
arch/v850/kernel/rte_me2_cb.c +1 -2
@@ -170,8 +170,7 @@ static struct cb_pic_irq_init cb_pic_irq_inits[] = { { "CB_EXTTM2", IRQ_CB_EXTTM2, 1, 1, 6 }, { 0 } }; -#define NUM_CB_PIC_IRQ_INITS \ - ((sizeof cb_pic_irq_inits / sizeof cb_pic_irq_inits[0]) - 1) +#define NUM_CB_PIC_IRQ_INITS (ARRAY_SIZE(cb_pic_irq_inits) - 1)static struct hw_interrupt_type cb_pic_hw_itypes[NUM_CB_PIC_IRQ_INITS ];static unsigned char cb_pic_active_irqs =0 ;
arch/v850/kernel/teg.c +1 -1
@@ -43,7 +43,7 @@ static struct v850e_intc_irq_init irq_inits[] = { { "ST", IRQ_INTST(0), IRQ_INTST_NUM, 1, 5 }, { 0 } }; -#define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1) +#define NUM_IRQ_INITS (ARRAY_SIZE(irq_inits) - 1)static struct hw_interrupt_type hw_itypes[NUM_IRQ_INITS ];
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 arch PowerPC: user ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked cause I have no PowerPC machine at hand. Thanks,
arch/powerpc/lib/rheap.c +2 -1
@@ -14,6 +14,7 @@*/ #include <linux/types.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <linux/mm.h> #include <linux/slab.h>
@@ -670,7 +671,7 @@ void rh_dump(rh_info_t * info)int maxnr;int i, nr; - maxnr =sizeof (st) /sizeof (st[0 ]); + maxnr =ARRAY_SIZE (st); printk(KERN_INFO "info @0x%p (%d slots empty / %d max)\n",
arch/powerpc/xmon/ppc-opc.c +3 -4
@@ -21,6 +21,7 @@02110-1301, USA. */ #include <linux/stddef.h> +#include <linux/kernel.h> #include "nonstdio.h" #include "ppc.h"
@@ -4932,8 +4933,7 @@ const struct powerpc_opcode powerpc_opcodes[] = { }; -const int powerpc_num_opcodes = -sizeof (powerpc_opcodes) /sizeof (powerpc_opcodes[0 ]); +const int powerpc_num_opcodes =ARRAY_SIZE (powerpc_opcodes);/* The macro table. This is only used by the assembler. */
@@ -4989,5 +4989,4 @@ const struct powerpc_macro powerpc_macros[] = { { "clrlslwi.",4, PPCCOM, "rlwinm. %0,%1,%3,(%2)-(%3),31-(%3)" }, }; -const int powerpc_num_macros = -sizeof (powerpc_macros) /sizeof (powerpc_macros[0 ]); +const int powerpc_num_macros =ARRAY_SIZE (powerpc_macros);
arch/powerpc/xmon/spu-opc.c +2 -2
@@ -18,6 +18,7 @@with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <linux/kernel.h> #include "spu.h" /* This file holds the Spu opcode table */
@@ -40,5 +41,4 @@ const struct spu_opcode spu_opcodes[] = {#undef APUOPFB }; -const int spu_num_opcodes = -sizeof (spu_opcodes) /sizeof (spu_opcodes[0 ]); +const int spu_num_opcodes =ARRAY_SIZE (spu_opcodes);
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 arch PPC: user ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked cause I have no PowerPC machine at hand. Thanks,
arch/ppc/lib/rheap.c +2 -1
@@ -14,6 +14,7 @@*/ #include <linux/types.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <linux/mm.h> #include <linux/slab.h>
@@ -654,7 +655,7 @@ void rh_dump(rh_info_t * info)int maxnr;int i, nr; - maxnr =sizeof (st) /sizeof (st[0 ]); + maxnr =ARRAY_SIZE (st); printk(KERN_INFO "info @0x%p (%d slots empty / %d max)\n",
arch/ppc/syslib/m8xx_setup.c +1 -1
@@ -77,7 +77,7 @@ static struct mtd_partition mpc8xxads_partitions[] = { } }; -#define mpc8xxads_part_num (sizeof (mpc8xxads_partitions) / sizeof (mpc8xxads_partitions[0])) +#define mpc8xxads_part_num ARRAY_SIZE(mpc8xxads_partitions)#endif
arch/ppc/xmon/ppc-opc.c +3 -4
@@ -19,6 +19,7 @@ along with this file; see the file COPYING. If not, write to the FreeSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <linux/posix_types.h> +#include <linux/kernel.h> #include "ansidecl.h" #include "ppc.h"
@@ -2669,8 +2670,7 @@ const struct powerpc_opcode powerpc_opcodes[] = { }; -const int powerpc_num_opcodes = -sizeof (powerpc_opcodes) /sizeof (powerpc_opcodes[0 ]); +const int powerpc_num_opcodes =ARRAY_SIZE (powerpc_opcodes);/* The macro table. This is only used by the assembler. */
@@ -2717,5 +2717,4 @@ const struct powerpc_macro powerpc_macros[] = { }; -const int powerpc_num_macros = -sizeof (powerpc_macros) /sizeof (powerpc_macros[0 ]); +const int powerpc_num_macros =ARRAY_SIZE (powerpc_macros);
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
PATCH 1/1 arch M68K: user ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked since I have no m68k machine at hand.
arch/m68k/kernel/ptrace.c +2 -2
@@ -76,7 +76,7 @@ static inline long get_reg(struct task_struct *task, int regno)if (regno ==PT_USP ) addr = &task->thread.usp; -else if (regno <sizeof (regoff)/sizeof (regoff[0 ])) +else if (regno <ARRAY_SIZE (regoff)) addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);else return 0 ;
@@ -93,7 +93,7 @@ static inline int put_reg(struct task_struct *task, int regno,if (regno ==PT_USP ) addr = &task->thread.usp; -else if (regno <sizeof (regoff)/sizeof (regoff[0 ])) +else if (regno <ARRAY_SIZE (regoff)) addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);else return -1 ;
arch/m68k/kernel/traps.c +1 -1
@@ -1011,7 +1011,7 @@ EXPORT_SYMBOL(dump_stack);void bad_super_trap (struct frame *fp) {console_verbose (); -if (fp->ptregs.vector <4 *sizeof (vec_names)/sizeof (vec_names[0 ])) +if (fp->ptregs.vector <4 *ARRAY_SIZE (vec_names))printk ("*** %s *** FORMAT=%X\n" , vec_names[(fp->ptregs.vector) >>2 ], fp->ptregs.format);
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Re: [PATCH 2.6.20] arch M68K: user ARRAY_SIZE macro when appropriate
Quoted 5 lines · Ahmed S. Darwish
A patch to use
ARRAY_SIZEmacro already defined inlinux/kernel.hSigned-off-by Ahmed S. Darwish <[email protected]>---
Patch isn't compile checked since I have no m68k machine at hand.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 1/1 arch ARM: Use ARRAY_SIZE macro when appropriate
In reply to Ahmed S. DarwishHi all,
A patch to use ARRAY_SIZE macro already defined in linux/kernel.h
---
Patch isn't compile checked cause I have no ARM machine at hand. Thanks,
arch/arm/kernel/ecard.c +1 -1
@@ -1009,7 +1009,7 @@ ecard_probe(int slot, card_type_t type) ec->fiqmask =4 ; } -for (i =0 ; i <sizeof (blacklist) /sizeof (*blacklist); i++) +for (i =0 ; i <ARRAY_SIZE (blacklist); i++)if (blacklist[i].manufacturer == ec->cid.manufacturer && blacklist[i].product == ec->cid.product) { ec->card_desc = blacklist[i].type;
arch/arm26/kernel/ecard.c +1 -1
@@ -665,7 +665,7 @@ ecard_probe(int slot, card_type_t type) ec->fiqmask =4 ; } -for (i =0 ; i <sizeof (blacklist) /sizeof (*blacklist); i++) +for (i =0 ; i <ARRAY_SIZE (blacklist); i++)if (blacklist[i].manufacturer == ec->cid.manufacturer && blacklist[i].product == ec->cid.product) { ec->card_desc = blacklist[i].type;
Signature · 2 lines
Ahmed S. Darwish http://darwish-07.blogspot.com
Re: [PATCH 2.6.20] arch ARM: Use ARRAY_SIZE macro when appropriate
Quoted 3 lines · Ahmed S. Darwish
Hi all,
A patch to use
ARRAY_SIZEmacro already defined inlinux/kernel.h
Looks good. I can only speak for arm26 though, however trivial this is.
Quoted 3 lines
---
Patch isn't compile checked cause I have no ARM machine at hand. Thanks,
arch/arm/kernel/ecard.c +1 -1
@@ -1009,7 +1009,7 @@ ecard_probe(int slot, card_type_t type) ec->fiqmask =4 ; } -for (i =0 ; i <sizeof (blacklist) /sizeof (*blacklist); i++) +for (i =0 ; i <ARRAY_SIZE (blacklist); i++)if (blacklist[i].manufacturer == ec->cid.manufacturer && blacklist[i].product == ec->cid.product) { ec->card_desc = blacklist[i].type;
arch/arm26/kernel/ecard.c +1 -1
@@ -665,7 +665,7 @@ ecard_probe(int slot, card_type_t type) ec->fiqmask =4 ; } -for (i =0 ; i <sizeof (blacklist) /sizeof (*blacklist); i++) +for (i =0 ; i <ARRAY_SIZE (blacklist); i++)if (blacklist[i].manufacturer == ec->cid.manufacturer && blacklist[i].product == ec->cid.product) { ec->card_desc = blacklist[i].type;