[PATCH 2.6.20 1/2] OSS: Use ARRAY_SIZE macro when appropriate

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ahmed S. Darwish
Date: Tuesday, February 6, 2007 - 9:05 am

Hi all,

A patch to use ARRAY_SIZE macro already defined in kernel.h

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
---
[PATCH 1/2] compile-tested
[PATCH 2/2] couldn't be compile-tested (orphaned hardware ?)

diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c
index cc282a0..e1fbcca 100644
--- a/sound/oss/es1371.c
+++ b/sound/oss/es1371.c
@@ -131,6 +131,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/mutex.h>
 #include <linux/mm.h>
+#include <linux/kernel.h>
 
 #include <asm/io.h>
 #include <asm/page.h>
@@ -2998,7 +2999,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
 	set_fs(KERNEL_DS);
 	val = SOUND_MASK_LINE;
 	mixdev_ioctl(s->codec, SOUND_MIXER_WRITE_RECSRC, (unsigned long)&val);
-	for (i = 0; i < sizeof(initvol)/sizeof(initvol[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(initvol); i++) {
 		val = initvol[i].vol;
 		mixdev_ioctl(s->codec, initvol[i].mixch, (unsigned long)&val);
 	}
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index a89108c..b92c8cd 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -32,6 +32,7 @@
 #include <linux/ctype.h>
 #include <linux/stddef.h>
 #include <linux/kmod.h>
+#include <linux/kernel.h>
 #include <asm/dma.h>
 #include <asm/io.h>
 #include <linux/wait.h>
@@ -557,7 +558,7 @@ static int __init oss_init(void)
 	/* Protecting the innocent */
 	sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
 
-	for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
+	for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
 		device_create(sound_class, NULL,
 			      MKDEV(SOUND_MAJOR, dev_list[i].minor),
 			      "%s", dev_list[i].name);
@@ -581,7 +582,7 @@ static void __exit oss_cleanup(void)
 {
 	int i, j;
 
-	for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
+	for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
 		device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor));
 		if (!dev_list[i].num)
 			continue;

-- 
Ahmed S. Darwish
http://darwish-07.blogspot.com
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00] A series of patches to use ARRAY_SIZE macro, Ahmed S. Darwish, (Tue Feb 6, 9:02 am)
[PATCH 2.6.20] DVB: Use ARRAY_SIZE macro when appropriate, Ahmed S. Darwish, (Tue Feb 6, 9:03 am)
[PATCH 2.6.20] KVM: Use ARRAY_SIZE macro when appropriate, Ahmed S. Darwish, (Tue Feb 6, 9:03 am)
[PATCH 2.6.20 1/2] OSS: Use ARRAY_SIZE macro when appropriate, Ahmed S. Darwish, (Tue Feb 6, 9:05 am)
[PATCH 2.6.20] atm: Use ARRAY_SIZE macro when appropriate, Ahmed S. Darwish, (Tue Feb 6, 9:06 am)
[PATCH 2.6.20] w1: Use ARRAY_SIZE macro when appropriate, Ahmed S. Darwish, (Tue Feb 6, 9:09 am)
[PATCH 2.6.20] drm: Use ARRAY_SIZE macro when appropriate, Ahmed S. Darwish, (Tue Feb 6, 9:10 am)
Re: [PATCH 2.6.20] w1: Use ARRAY_SIZE macro when appropriate, Evgeniy Polyakov, (Tue Feb 6, 9:19 am)
Re: [PATCH 2.6.20] isdn-capi: Use ARRAY_SIZE macro when ap ..., Philippe De Muyter, (Tue Feb 6, 2:18 pm)
Re: [PATCH 2.6.20] isdn-capi: Use ARRAY_SIZE macro when ap ..., Philippe De Muyter, (Wed Feb 7, 2:02 pm)