diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2006-08-15 03:05:38 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 17:54:45 -0400 |
commit | 9c3bd6833a4df1abd9ecd3b51492b8949bf9cd11 (patch) | |
tree | 6835d90852cd40289ad970b979b694ed55203e60 /drivers/net/irda | |
parent | 9a673e563e543a5c8a6f9824562e55e807b8a56c (diff) |
[IRDA]: Replace hard-coded dev_self[] array sizes with ARRAY_SIZE()
Several IR drivers used "for (i = 0; i < 4; i++)" to walk their
dev_self[] table. Better to use ARRAY_SIZE(). And fix ali-ircc so it
won't run off the end if we find too many adapters.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/irda')
-rw-r--r-- | drivers/net/irda/ali-ircc.c | 8 | ||||
-rw-r--r-- | drivers/net/irda/irport.c | 4 | ||||
-rw-r--r-- | drivers/net/irda/via-ircc.c | 5 | ||||
-rw-r--r-- | drivers/net/irda/w83977af_ir.c | 4 |
4 files changed, 15 insertions, 6 deletions
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c index e3c8cd5eca67..68d4c418cb98 100644 --- a/drivers/net/irda/ali-ircc.c +++ b/drivers/net/irda/ali-ircc.c | |||
@@ -249,7 +249,7 @@ static void __exit ali_ircc_cleanup(void) | |||
249 | 249 | ||
250 | IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); | 250 | IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); |
251 | 251 | ||
252 | for (i=0; i < 4; i++) { | 252 | for (i=0; i < ARRAY_SIZE(dev_self); i++) { |
253 | if (dev_self[i]) | 253 | if (dev_self[i]) |
254 | ali_ircc_close(dev_self[i]); | 254 | ali_ircc_close(dev_self[i]); |
255 | } | 255 | } |
@@ -273,6 +273,12 @@ static int ali_ircc_open(int i, chipio_t *info) | |||
273 | int err; | 273 | int err; |
274 | 274 | ||
275 | IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); | 275 | IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__); |
276 | |||
277 | if (i >= ARRAY_SIZE(dev_self)) { | ||
278 | IRDA_ERROR("%s(), maximum number of supported chips reached!\n", | ||
279 | __FUNCTION__); | ||
280 | return -ENOMEM; | ||
281 | } | ||
276 | 282 | ||
277 | /* Set FIR FIFO and DMA Threshold */ | 283 | /* Set FIR FIFO and DMA Threshold */ |
278 | if ((ali_ircc_setup(info)) == -1) | 284 | if ((ali_ircc_setup(info)) == -1) |
diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c index 44efd49bf4a9..ba4f3eb988b3 100644 --- a/drivers/net/irda/irport.c +++ b/drivers/net/irda/irport.c | |||
@@ -1090,7 +1090,7 @@ static int __init irport_init(void) | |||
1090 | { | 1090 | { |
1091 | int i; | 1091 | int i; |
1092 | 1092 | ||
1093 | for (i=0; (io[i] < 2000) && (i < 4); i++) { | 1093 | for (i=0; (io[i] < 2000) && (i < ARRAY_SIZE(dev_self)); i++) { |
1094 | if (irport_open(i, io[i], irq[i]) != NULL) | 1094 | if (irport_open(i, io[i], irq[i]) != NULL) |
1095 | return 0; | 1095 | return 0; |
1096 | } | 1096 | } |
@@ -1112,7 +1112,7 @@ static void __exit irport_cleanup(void) | |||
1112 | 1112 | ||
1113 | IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); | 1113 | IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); |
1114 | 1114 | ||
1115 | for (i=0; i < 4; i++) { | 1115 | for (i=0; i < ARRAY_SIZE(dev_self); i++) { |
1116 | if (dev_self[i]) | 1116 | if (dev_self[i]) |
1117 | irport_close(dev_self[i]); | 1117 | irport_close(dev_self[i]); |
1118 | } | 1118 | } |
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c index 8bafb455c102..79b85f327500 100644 --- a/drivers/net/irda/via-ircc.c +++ b/drivers/net/irda/via-ircc.c | |||
@@ -279,7 +279,7 @@ static void via_ircc_clean(void) | |||
279 | 279 | ||
280 | IRDA_DEBUG(3, "%s()\n", __FUNCTION__); | 280 | IRDA_DEBUG(3, "%s()\n", __FUNCTION__); |
281 | 281 | ||
282 | for (i=0; i < 4; i++) { | 282 | for (i=0; i < ARRAY_SIZE(dev_self); i++) { |
283 | if (dev_self[i]) | 283 | if (dev_self[i]) |
284 | via_ircc_close(dev_self[i]); | 284 | via_ircc_close(dev_self[i]); |
285 | } | 285 | } |
@@ -327,6 +327,9 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id) | |||
327 | 327 | ||
328 | IRDA_DEBUG(3, "%s()\n", __FUNCTION__); | 328 | IRDA_DEBUG(3, "%s()\n", __FUNCTION__); |
329 | 329 | ||
330 | if (i >= ARRAY_SIZE(dev_self)) | ||
331 | return -ENOMEM; | ||
332 | |||
330 | /* Allocate new instance of the driver */ | 333 | /* Allocate new instance of the driver */ |
331 | dev = alloc_irdadev(sizeof(struct via_ircc_cb)); | 334 | dev = alloc_irdadev(sizeof(struct via_ircc_cb)); |
332 | if (dev == NULL) | 335 | if (dev == NULL) |
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c index 0ea65c4c6f85..8421597072a7 100644 --- a/drivers/net/irda/w83977af_ir.c +++ b/drivers/net/irda/w83977af_ir.c | |||
@@ -117,7 +117,7 @@ static int __init w83977af_init(void) | |||
117 | 117 | ||
118 | IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); | 118 | IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); |
119 | 119 | ||
120 | for (i=0; (io[i] < 2000) && (i < 4); i++) { | 120 | for (i=0; (io[i] < 2000) && (i < ARRAY_SIZE(dev_self)); i++) { |
121 | if (w83977af_open(i, io[i], irq[i], dma[i]) == 0) | 121 | if (w83977af_open(i, io[i], irq[i], dma[i]) == 0) |
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
@@ -136,7 +136,7 @@ static void __exit w83977af_cleanup(void) | |||
136 | 136 | ||
137 | IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); | 137 | IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); |
138 | 138 | ||
139 | for (i=0; i < 4; i++) { | 139 | for (i=0; i < ARRAY_SIZE(dev_self); i++) { |
140 | if (dev_self[i]) | 140 | if (dev_self[i]) |
141 | w83977af_close(dev_self[i]); | 141 | w83977af_close(dev_self[i]); |
142 | } | 142 | } |