[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>
This commit is contained in:

committed by
David S. Miller

parent
9a673e563e
commit
9c3bd6833a
@@ -279,7 +279,7 @@ static void via_ircc_clean(void)
|
||||
|
||||
IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
|
||||
|
||||
for (i=0; i < 4; i++) {
|
||||
for (i=0; i < ARRAY_SIZE(dev_self); i++) {
|
||||
if (dev_self[i])
|
||||
via_ircc_close(dev_self[i]);
|
||||
}
|
||||
@@ -327,6 +327,9 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
|
||||
|
||||
IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
|
||||
|
||||
if (i >= ARRAY_SIZE(dev_self))
|
||||
return -ENOMEM;
|
||||
|
||||
/* Allocate new instance of the driver */
|
||||
dev = alloc_irdadev(sizeof(struct via_ircc_cb));
|
||||
if (dev == NULL)
|
||||
|
Reference in New Issue
Block a user