staging: comedi: use ARRAY_SIZE instead of custom n_boardtypes macros
authorH Hartley Sweeten <hartleys@visionengravers.com>
Fri, 20 Apr 2012 19:05:04 +0000 (12:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Apr 2012 22:12:13 +0000 (15:12 -0700)
The n_boardtypes macros are simply open-coded versions of the kernels
ARRAY_SIZE macro. Use the kernel provided macro.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 files changed:
drivers/staging/comedi/drivers/acl7225b.c
drivers/staging/comedi/drivers/addi-data/addi_common.c
drivers/staging/comedi/drivers/adl_pci9118.c
drivers/staging/comedi/drivers/adv_pci1710.c
drivers/staging/comedi/drivers/adv_pci1723.c
drivers/staging/comedi/drivers/adv_pci_dio.c
drivers/staging/comedi/drivers/daqboard2000.c
drivers/staging/comedi/drivers/dt282x.c
drivers/staging/comedi/drivers/icp_multi.c
drivers/staging/comedi/drivers/pcl711.c
drivers/staging/comedi/drivers/pcl724.c
drivers/staging/comedi/drivers/pcl726.c
drivers/staging/comedi/drivers/pcl730.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcl816.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/pcm3724.c

index 9def2250bb8002ab84460649bc854069f23ce3f0..f4a301a5aecbac8bd0532e2a5ccae5c60ed76f5c 100644 (file)
@@ -36,7 +36,6 @@ static const struct boardtype boardtypes[] = {
        {"p16r16dio", P16R16DIO_SIZE,},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
 #define this_board ((const struct boardtype *)dev->board_ptr)
 
 static struct comedi_driver driver_acl7225b = {
@@ -45,7 +44,7 @@ static struct comedi_driver driver_acl7225b = {
        .attach = acl7225b_attach,
        .detach = acl7225b_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct boardtype),
 };
 
index 2f341a39cd6cc6705477fc32a0c5df09b68bbd56..5b5dae4ceddbdf22adcb53bb6bed89f60247e607 100644 (file)
@@ -2528,14 +2528,12 @@ static const struct addi_board boardtypes[] = {
 #endif
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct addi_board))
-
 static struct comedi_driver driver_addi = {
        .driver_name = ADDIDATA_DRIVER_NAME,
        .module = THIS_MODULE,
        .attach = i_ADDI_Attach,
        .detach = i_ADDI_Detach,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .board_name = &boardtypes[0].pc_DriverName,
        .offset = sizeof(struct addi_board),
 };
index cfe164a67ee9307367219a207d2f6275b4548702..5b845734fe83f2c68343bec03b3e6a52d0b57558 100644 (file)
@@ -277,14 +277,12 @@ static const struct boardtype boardtypes[] = {
         10000, 40, 512},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
-
 static struct comedi_driver driver_pci9118 = {
        .driver_name = "adl_pci9118",
        .module = THIS_MODULE,
        .attach = pci9118_attach,
        .detach = pci9118_detach,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .board_name = &boardtypes[0].name,
        .offset = sizeof(struct boardtype),
 };
index dc6fe3dbc8609a3e4beeb80bf78008f0c1a12fd3..dc762e724edb417731a6b799705e6bcde029bd61 100644 (file)
@@ -264,14 +264,12 @@ static const struct boardtype boardtypes[] = {
        {.name = DRV_NAME},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
-
 static struct comedi_driver driver_pci1710 = {
        .driver_name = DRV_NAME,
        .module = THIS_MODULE,
        .attach = pci1710_attach,
        .detach = pci1710_detach,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .board_name = &boardtypes[0].name,
        .offset = sizeof(struct boardtype),
 };
@@ -1398,13 +1396,13 @@ static int pci1710_attach(struct comedi_device *dev,
        while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
                                                PCI_ANY_ID, pcidev))) {
                if (strcmp(this_board->name, DRV_NAME) == 0) {
-                       for (i = 0; i < n_boardtypes; ++i) {
+                       for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
                                if (pcidev->device == boardtypes[i].device_id) {
                                        board_index = i;
                                        break;
                                }
                        }
-                       if (i == n_boardtypes)
+                       if (i == ARRAY_SIZE(boardtypes))
                                continue;
                } else {
                        if (pcidev->device != boardtypes[board_index].device_id)
index eb49c8743edac26dac33751c5fdd2d24d8e9dee2..4a4ae5fb88959ca92e4d806acf9ea5271456e973 100644 (file)
@@ -171,8 +171,6 @@ static int pci1723_attach(struct comedi_device *dev,
                          struct comedi_devconfig *it);
 static int pci1723_detach(struct comedi_device *dev);
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pci1723_board))
-
 static struct comedi_driver driver_pci1723 = {
        .driver_name = "adv_pci1723",
        .module = THIS_MODULE,
index 491df0c115c773bcb5aec3284cd5852a574a33c0..7d920fe636c67c05abeea8aa9f0c960a065cebe0 100644 (file)
@@ -406,8 +406,6 @@ static const struct dio_boardtype boardtypes[] = {
         IO_16b}
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype))
-
 static struct comedi_driver driver_pci_dio = {
        .driver_name = "adv_pci_dio",
        .module = THIS_MODULE,
@@ -1134,7 +1132,7 @@ static int pci_dio_attach(struct comedi_device *dev,
 
        for_each_pci_dev(pcidev) {
                /*  loop through cards supported by this driver */
-               for (i = 0; i < n_boardtypes; ++i) {
+               for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
                        if (boardtypes[i].vendor_id != pcidev->vendor)
                                continue;
                        if (boardtypes[i].device_id != pcidev->device)
index 707319727e3ccfd21ebfd9c2cf0ed5d1ff862694..952b08177b4a0830296eb301d67defc91a0ecee1 100644 (file)
@@ -321,7 +321,6 @@ static const struct daq200_boardtype boardtypes[] = {
        {"ids4", DAQBOARD2000_SUBSYSTEM_IDS4},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct daq200_boardtype))
 #define this_board ((const struct daq200_boardtype *)dev->board_ptr)
 
 static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
@@ -761,7 +760,7 @@ static int daqboard2000_attach(struct comedi_device *dev,
                devpriv->pci_dev = card;
                id = ((u32) card->
                      subsystem_device << 16) | card->subsystem_vendor;
-               for (i = 0; i < n_boardtypes; i++) {
+               for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
                        if (boardtypes[i].id == id) {
                                dev_dbg(dev->hw_dev, "%s\n",
                                        boardtypes[i].name);
index 95ebc267bb7460596b97dee5c8a364ef85d686ac..210b3f0f6f01a76a203a37fdcf4775237c22b449 100644 (file)
@@ -350,7 +350,6 @@ static const struct dt282x_board boardtypes[] = {
         },
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dt282x_board))
 #define this_board ((const struct dt282x_board *)dev->board_ptr)
 
 struct dt282x_private {
@@ -420,7 +419,7 @@ static struct comedi_driver driver_dt282x = {
        .attach = dt282x_attach,
        .detach = dt282x_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct dt282x_board),
 };
 
index 126550f3c02bf88e7ad1fe05a8bc4e50301e481d..67b6f5aa1885268f0408186f8f28673d10086e45 100644 (file)
@@ -173,14 +173,12 @@ static const struct boardtype boardtypes[] = {
         &range_analog},        /*  Rangelist for D/A */
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
-
 static struct comedi_driver driver_icp_multi = {
        .driver_name = "icp_multi",
        .module = THIS_MODULE,
        .attach = icp_multi_attach,
        .detach = icp_multi_detach,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .board_name = &boardtypes[0].name,
        .offset = sizeof(struct boardtype),
 };
index b44386a6b63620451b2f307aac64e48beec2a58f..ce6e514cd80286ae67a1ef159807e4ac721cc6e6 100644 (file)
@@ -155,7 +155,6 @@ static const struct pcl711_board boardtypes[] = {
        {"acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl711_board))
 #define this_board ((const struct pcl711_board *)dev->board_ptr)
 
 static int pcl711_attach(struct comedi_device *dev,
@@ -167,7 +166,7 @@ static struct comedi_driver driver_pcl711 = {
        .attach = pcl711_attach,
        .detach = pcl711_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcl711_board),
 };
 
index 61b075db66ef425e65b99456c427429b783bdc5e..20715d150f4f2eb630d55cbef623014160bea60a 100644 (file)
@@ -80,7 +80,6 @@ static const struct pcl724_board boardtypes[] = {
        {"pet48dio", 48, 2, 0x9eb8, PET48_SIZE, 0, 1,},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl724_board))
 #define this_board ((const struct pcl724_board *)dev->board_ptr)
 
 static struct comedi_driver driver_pcl724 = {
@@ -89,7 +88,7 @@ static struct comedi_driver driver_pcl724 = {
        .attach = pcl724_attach,
        .detach = pcl724_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcl724_board),
 };
 
index 897cd808eeb77f16a6ebf64701458c870fd5fbb0..a880ceb422404de20f9b7ff31db4093785518e23 100644 (file)
@@ -149,7 +149,6 @@ static const struct pcl726_board boardtypes[] = {
         &rangelist_728[0],},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl726_board))
 #define this_board ((const struct pcl726_board *)dev->board_ptr)
 
 static struct comedi_driver driver_pcl726 = {
@@ -158,7 +157,7 @@ static struct comedi_driver driver_pcl726 = {
        .attach = pcl726_attach,
        .detach = pcl726_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcl726_board),
 };
 
index c9682d614e0e3daa688c51a67c1965fdc9e9f817..78c8e59bd6d76637bf056c576a5b3d27fc17e655 100644 (file)
@@ -42,7 +42,6 @@ static const struct pcl730_board boardtypes[] = {
        {"acl7130", ACL7130_SIZE,},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl730_board))
 #define this_board ((const struct pcl730_board *)dev->board_ptr)
 
 static struct comedi_driver driver_pcl730 = {
@@ -51,7 +50,7 @@ static struct comedi_driver driver_pcl730 = {
        .attach = pcl730_attach,
        .detach = pcl730_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcl730_board),
 };
 
index 6fc74645af2ccdd7b1c9a33cb7a693954231b646..555d0df71e1f7b8be5a0c0d84ae7c6d40f121805 100644 (file)
@@ -397,7 +397,6 @@ static const struct pcl812_board boardtypes[] = {
         0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl812_board))
 #define this_board ((const struct pcl812_board *)dev->board_ptr)
 
 static struct comedi_driver driver_pcl812 = {
@@ -406,7 +405,7 @@ static struct comedi_driver driver_pcl812 = {
        .attach = pcl812_attach,
        .detach = pcl812_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcl812_board),
 };
 
index 96cd7ec2ad53ba5868baac4547fbb5923b972092..bf7b2621f877bbb20189da1310e3079976a8f096 100644 (file)
@@ -146,7 +146,6 @@ static const struct pcl816_board boardtypes[] = {
         100},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl816_board))
 #define devpriv ((struct pcl816_private *)dev->private)
 #define this_board ((const struct pcl816_board *)dev->board_ptr)
 
@@ -165,7 +164,7 @@ static struct comedi_driver driver_pcl816 = {
        .attach = pcl816_attach,
        .detach = pcl816_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcl816_board),
 };
 
index 7344a53a81c4daf549fe683605070ad439a83bc1..0272491c784f13bd535d3363f189afc0813d9820 100644 (file)
@@ -302,15 +302,13 @@ static const struct pcl818_board boardtypes[] = {
         0x0a, 0xfff, 0xfff, 0, 1 /* XXX ? */ },
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl818_board))
-
 static struct comedi_driver driver_pcl818 = {
        .driver_name = "pcl818",
        .module = THIS_MODULE,
        .attach = pcl818_attach,
        .detach = pcl818_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcl818_board),
 };
 
index f5c0bd17684c4d16092af720f75f8883efa96583..4601703341f66178be26a390ecfdafe3c88e0a04 100644 (file)
@@ -84,7 +84,6 @@ static const struct pcm3724_board boardtypes[] = {
        {"pcm3724", 48, 2, 0x00fc, PCM3724_SIZE,},
 };
 
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcm3724_board))
 #define this_board ((const struct pcm3724_board *)dev->board_ptr)
 
 static struct comedi_driver driver_pcm3724 = {
@@ -93,7 +92,7 @@ static struct comedi_driver driver_pcm3724 = {
        .attach = pcm3724_attach,
        .detach = pcm3724_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = n_boardtypes,
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct pcm3724_board),
 };