Staging: comedi: make use of ARRAY_SIZE macro
authorBill Pemberton <wfp5p@virginia.edu>
Thu, 23 Apr 2009 19:54:56 +0000 (15:54 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 19 Jun 2009 18:00:33 +0000 (11:00 -0700)
Replace instances of computing number of elements in an array with
sizeof(foo)/sizeof(struct footype) with the ARRAY_SIZE macro.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
40 files changed:
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/adl_pci6208.c
drivers/staging/comedi/drivers/adq12b.c
drivers/staging/comedi/drivers/aio_iiro_16.c
drivers/staging/comedi/drivers/amplc_dio200.c
drivers/staging/comedi/drivers/amplc_pc236.c
drivers/staging/comedi/drivers/amplc_pc263.c
drivers/staging/comedi/drivers/amplc_pci224.c
drivers/staging/comedi/drivers/amplc_pci230.c
drivers/staging/comedi/drivers/cb_pcidas.c
drivers/staging/comedi/drivers/cb_pcidas64.c
drivers/staging/comedi/drivers/cb_pcidio.c
drivers/staging/comedi/drivers/cb_pcimdda.c
drivers/staging/comedi/drivers/comedi_bond.c
drivers/staging/comedi/drivers/comedi_test.c
drivers/staging/comedi/drivers/das16.c
drivers/staging/comedi/drivers/das16m1.c
drivers/staging/comedi/drivers/das1800.c
drivers/staging/comedi/drivers/das800.c
drivers/staging/comedi/drivers/dmm32at.c
drivers/staging/comedi/drivers/dt2801.c
drivers/staging/comedi/drivers/dt2811.c
drivers/staging/comedi/drivers/gsc_hpdi.c
drivers/staging/comedi/drivers/me4000.c
drivers/staging/comedi/drivers/ni_at_ao.c
drivers/staging/comedi/drivers/ni_daq_700.c
drivers/staging/comedi/drivers/ni_daq_dio24.c
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_labpc_cs.c
drivers/staging/comedi/drivers/ni_stc.h
drivers/staging/comedi/drivers/pcmda12.c
drivers/staging/comedi/drivers/pcmmio.c
drivers/staging/comedi/drivers/pcmuio.c
drivers/staging/comedi/drivers/rtd520.c
drivers/staging/comedi/drivers/rti800.c
drivers/staging/comedi/drivers/s526.c
drivers/staging/comedi/drivers/s626.c
drivers/staging/comedi/drivers/serial2002.c
drivers/staging/comedi/drivers/skel.c
drivers/staging/comedi/drivers/ssv_dnp.c

index cabbf090f60b0ff7fdc0b426bc701723a78cc2b8..e5185ac3604c28b7390db130b7fad1460728c5a2 100644 (file)
@@ -853,7 +853,8 @@ int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name)
        /*  pci slot */
        options[1] = PCI_SLOT(pcidev->devfn);
 
-       return comedi_auto_config(&pcidev->dev, board_name, options, sizeof(options) / sizeof(options[0]));
+       return comedi_auto_config(&pcidev->dev, board_name,
+                                 options, ARRAY_SIZE(options));
 }
 
 void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
index 7cd6043ed49fb7239690d70e7d55852d2cf98b22..b4807fc7eb01a95075629d8b71c637e3dc011b45 100644 (file)
@@ -110,9 +110,6 @@ struct pci6208_private {
 static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 static int pci6208_detach(struct comedi_device *dev);
 
-#define pci6208_board_nbr \
-       (sizeof(pci6208_boards) / sizeof(struct pci6208_board))
-
 static struct comedi_driver driver_pci6208 = {
        .driver_name = PCI6208_DRIVER_NAME,
        .module = THIS_MODULE,
@@ -315,7 +312,7 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
                pci_dev != NULL;
                pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
                if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) {
-                       for (i = 0; i < pci6208_board_nbr; i++) {
+                       for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
                                if (pci6208_boards[i].dev_id == pci_dev->device) {
                                        /*  was a particular bus/slot requested? */
                                        if ((bus != 0) || (slot != 0)) {
index 54724653a79223cb0837752ac738fcbb4eb8926d..c51e9ba5880840aebad3e249d87069d069b5c586 100644 (file)
@@ -171,7 +171,7 @@ static struct comedi_driver driver_adq12b={
         detach:         adq12b_detach,
         board_name:     &adq12b_boards[0].name,
         offset:         sizeof(struct adq12b_board),
-        num_names:      sizeof(adq12b_boards) / sizeof(struct adq12b_board),
+        num_names:      ARRAY_SIZE(adq12b_boards),
 };
 
 static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
index 764cac2fd7d263764b0ef2e7d4c4f357526983c9..d062f8619b6e3b16ccdd1d7a734d001a8af7bc63 100644 (file)
@@ -78,7 +78,7 @@ static struct comedi_driver driver_aio_iiro_16 = {
        .detach = aio_iiro_16_detach,
        .board_name = &aio_iiro_16_boards[0].name,
        .offset = sizeof(struct aio_iiro_16_board),
-       .num_names = sizeof(aio_iiro_16_boards) / sizeof(struct aio_iiro_16_board),
+       .num_names = ARRAY_SIZE(aio_iiro_16_boards),
 };
 
 static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
index 582d6a2cfef682b2a196ea4f64507f8bfb9cc0b8..ddf58d4866ebb3ccc99fa060f2e5c98241bac07c 100644 (file)
@@ -484,7 +484,7 @@ static struct comedi_driver driver_amplc_dio200 = {
        .detach = dio200_detach,
        .board_name = &dio200_boards[0].name,
        .offset = sizeof(struct dio200_board),
-       .num_names = sizeof(dio200_boards) / sizeof(struct dio200_board),
+       .num_names = ARRAY_SIZE(dio200_boards),
 };
 
 #ifdef CONFIG_COMEDI_PCI
index 3befe507ce2f3b8bc99afe4e66b6c464296a5911..235cbfffa14b99adbb557c42640d54c21a0f919a 100644 (file)
@@ -176,7 +176,7 @@ static struct comedi_driver driver_amplc_pc236 = {
        .detach = pc236_detach,
        .board_name = &pc236_boards[0].name,
        .offset = sizeof(struct pc236_board),
-       .num_names = sizeof(pc236_boards) / sizeof(struct pc236_board),
+       .num_names = ARRAY_SIZE(pc236_boards),
 };
 
 #ifdef CONFIG_COMEDI_PCI
index 1d516b1f159150373d50eac17ca50284017144e1..c804c7c649c184c5e852dc5a34dda573f3540e1a 100644 (file)
@@ -141,7 +141,7 @@ static struct comedi_driver driver_amplc_pc263 = {
        .detach = pc263_detach,
        .board_name = &pc263_boards[0].name,
        .offset = sizeof(struct pc263_board),
-       .num_names = sizeof(pc263_boards) / sizeof(struct pc263_board),
+       .num_names = ARRAY_SIZE(pc263_boards),
 };
 
 static int pc263_request_region(unsigned minor, unsigned long from,
index 19e4428c338092395e94931ca34602867a9f7cb6..6b53cb4b93f9cf0c8fe8aef1bac37e6650bb2088 100644 (file)
@@ -437,7 +437,7 @@ static struct comedi_driver driver_amplc_pci224 = {
        .detach = pci224_detach,
        .board_name = &pci224_boards[0].name,
        .offset = sizeof(struct pci224_board),
-       .num_names = sizeof(pci224_boards) / sizeof(struct pci224_board),
+       .num_names = ARRAY_SIZE(pci224_boards),
 };
 
 COMEDI_PCI_INITCLEANUP(driver_amplc_pci224, pci224_pci_table);
index 1d675173cd32a438c2a67d5d6ddd53e37efbe804..057443551c23b12db355d010639a3cca4ad95413 100644 (file)
@@ -612,7 +612,7 @@ static struct comedi_driver driver_amplc_pci230 = {
        .detach = pci230_detach,
        .board_name = &pci230_boards[0].name,
        .offset = sizeof(pci230_boards[0]),
-       .num_names = sizeof(pci230_boards) / sizeof(pci230_boards[0]),
+       .num_names = ARRAY_SIZE(pci230_boards),
 };
 
 COMEDI_PCI_INITCLEANUP(driver_amplc_pci230, pci230_pci_table);
index 17dec7567481a51fa92f5e1bdbb2d74d549dcf32..11212b01d49354e29eb2c33e146971291d1ef807 100644 (file)
@@ -375,9 +375,6 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
                },
 };
 
-/* Number of boards in cb_pcidas_boards */
-#define N_BOARDS       (sizeof(cb_pcidas_boards) / sizeof(struct cb_pcidas_board))
-
 static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = {
        {PCI_VENDOR_ID_CB, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
        {PCI_VENDOR_ID_CB, 0x000f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -536,7 +533,7 @@ static int cb_pcidas_attach(struct comedi_device *dev, struct comedi_devconfig *
                if (pcidev->vendor != PCI_VENDOR_ID_CB)
                        continue;
                /*  loop through cards supported by this driver */
-               for (index = 0; index < N_BOARDS; index++) {
+               for (index = 0; index < ARRAY_SIZE(cb_pcidas_boards); index++) {
                        if (cb_pcidas_boards[index].device_id != pcidev->device)
                                continue;
                        /*  was a particular bus/slot requested? */
index adce530adc53482f295bafce879d8f694bae7eda..caa8b568871d8164c49189ba63825f120f02fa7c 100644 (file)
@@ -1014,12 +1014,6 @@ static const struct pcidas64_board pcidas64_boards[] = {
 #endif
 };
 
-/* Number of boards in cb_pcidas_boards */
-static inline unsigned int num_boards(void)
-{
-       return sizeof(pcidas64_boards) / sizeof(struct pcidas64_board);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(pcidas64_pci_table) = {
        {PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
        {PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -1702,7 +1696,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
                if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
                        continue;
                /*  loop through cards supported by this driver */
-               for (index = 0; index < num_boards(); index++) {
+               for (index = 0; index < ARRAY_SIZE(pcidas64_boards); index++) {
                        if (pcidas64_boards[index].device_id != pcidev->device)
                                continue;
                        /*  was a particular bus/slot requested? */
index 799b5aded13c15b22518c6624b25209a71da7641..dc701273167ca141f6b6eb2934ee3effcf7cec98 100644 (file)
@@ -204,7 +204,7 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                        continue;
                /*  loop through cards supported by this driver */
                for (index = 0;
-                       index < sizeof pcidio_boards / sizeof(struct pcidio_board);
+                       index < ARRAY_SIZE(pcidio_boards);
                        index++) {
                        if (pcidio_pci_table[index].device != pcidev->device)
                                continue;
index 3ce133c69e278e0699923de77cae2e53af10ad8f..57bb1182480db820938e55b377c0648621a808e1 100644 (file)
@@ -135,8 +135,6 @@ static const struct board_struct boards[] = {
  */
 #define thisboard    ((const struct board_struct *)dev->board_ptr)
 
-/* Number of boards in boards[] */
-#define N_BOARDS       (sizeof(boards) / sizeof(struct board_struct))
 #define REG_SZ (thisboard->reg_sz)
 #define REGS_BADRINDEX (thisboard->regs_badrindex)
 
@@ -439,7 +437,7 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
                if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
                        continue;
                /*  loop through cards supported by this driver */
-               for (index = 0; index < N_BOARDS; index++) {
+               for (index = 0; index < ARRAY_SIZE(boards); index++) {
                        if (boards[index].device_id != pcidev->device)
                                continue;
                        /*  was a particular bus/slot requested? */
index 1ee489864d3b7658ce25b890b086a2d70751df3d..45cd41f7fd29229a3f8ef3291e8bbbb97f7a0364 100644 (file)
@@ -210,7 +210,7 @@ static struct comedi_driver driver_bonding = {
         */
       .board_name =    &bondingBoards[0].name,
       .offset =                sizeof(struct BondingBoard),
-      .num_names =     sizeof(bondingBoards) / sizeof(struct BondingBoard),
+      .num_names =     ARRAY_SIZE(bondingBoards),
 };
 
 static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
index e679328a4f8fc3be421a1ea4f2ae66bebdf083a9..93ed1a0ae1264c75240e34e6406b14f4c72562e8 100644 (file)
@@ -102,7 +102,7 @@ static struct comedi_driver driver_waveform = {
       .detach =                waveform_detach,
       .board_name =    &waveform_boards[0].name,
       .offset =                sizeof(struct waveform_board),
-      .num_names =     sizeof(waveform_boards) / sizeof(struct waveform_board),
+      .num_names =     ARRAY_SIZE(waveform_boards),
 };
 
 COMEDI_INITCLEANUP(driver_waveform);
index 982837d879ce43c819ef404e27a7f2f70088f4e0..6ca888429e6af00edf1bd6bd65e1a45b9a5d7113 100644 (file)
@@ -696,8 +696,6 @@ static const struct das16_board das16_boards[] = {
 #endif
 };
 
-#define n_das16_boards ((sizeof(das16_boards))/(sizeof(struct das16_board)))
-
 static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 static int das16_detach(struct comedi_device *dev);
 static struct comedi_driver driver_das16 = {
@@ -706,7 +704,7 @@ static struct comedi_driver driver_das16 = {
        .attach = das16_attach,
        .detach = das16_detach,
        .board_name = &das16_boards[0].name,
-       .num_names = n_das16_boards,
+       .num_names = ARRAY_SIZE(das16_boards),
        .offset = sizeof(das16_boards[0]),
 };
 
index 91b1a0e7575cc6c739127efa09a892ebb2d6a2de..e22f546e8162e4208705908061d7a1080ea9ced9 100644 (file)
@@ -164,8 +164,6 @@ static const struct das16m1_board das16m1_boards[] = {
                },
 };
 
-#define das16m1_num_boards ((sizeof(das16m1_boards)) / (sizeof(das16m1_boards[0])))
-
 static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 static int das16m1_detach(struct comedi_device *dev);
 static struct comedi_driver driver_das16m1 = {
@@ -174,7 +172,7 @@ static struct comedi_driver driver_das16m1 = {
        .attach = das16m1_attach,
        .detach = das16m1_detach,
        .board_name = &das16m1_boards[0].name,
-       .num_names = das16m1_num_boards,
+       .num_names = ARRAY_SIZE(das16m1_boards),
        .offset = sizeof(das16m1_boards[0]),
 };
 
index 9c6c9b89558abec3dc0dc1e86ffc761e0513a85c..7fbcfb107e6da92781a67b27403f9cad06ad500b 100644 (file)
@@ -509,7 +509,7 @@ static struct comedi_driver driver_das1800 = {
        .module = THIS_MODULE,
        .attach = das1800_attach,
        .detach = das1800_detach,
-       .num_names = sizeof(das1800_boards) / sizeof(struct das1800_board),
+       .num_names = ARRAY_SIZE(das1800_boards),
        .board_name = &das1800_boards[0].name,
        .offset = sizeof(struct das1800_board),
 };
index db646598619ea83c71e884a113ecda88272da1d5..6ee9648e5e18c085804e1ebd81c08a11cae80dd1 100644 (file)
@@ -251,7 +251,7 @@ static struct comedi_driver driver_das800 = {
        .module = THIS_MODULE,
        .attach = das800_attach,
        .detach = das800_detach,
-       .num_names = sizeof(das800_boards) / sizeof(struct das800_board),
+       .num_names = ARRAY_SIZE(das800_boards),
        .board_name = &das800_boards[0].name,
        .offset = sizeof(struct das800_board),
 };
index e7c5130de8d0b116c88682ff8cf68ecc3671de8a..47b3ebc34a685dd521e0e966349fadd8e277ff20 100644 (file)
@@ -285,7 +285,7 @@ static struct comedi_driver driver_dmm32at = {
  */
        .board_name = &dmm32at_boards[0].name,
        .offset = sizeof(struct dmm32at_board),
-       .num_names = sizeof(dmm32at_boards) / sizeof(struct dmm32at_board),
+       .num_names = ARRAY_SIZE(dmm32at_boards),
 };
 
 /* prototypes for driver functions below */
index 335e3a0660cfa19240f259aedd0ba15aa70d9fd3..9b100405b8b71b79c38b201e03f3810ed85bc224 100644 (file)
@@ -217,7 +217,6 @@ static const struct dt2801_board boardtypes[] = {
        .dabits = 12},
 };
 
-#define n_boardtypes ((sizeof(boardtypes))/(sizeof(boardtypes[0])))
 #define boardtype (*(const struct dt2801_board *)dev->board_ptr)
 
 struct dt2801_private {
@@ -506,7 +505,7 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        if (!board_code)
                board_code = dt2801_reset(dev);
 
-       for (type = 0; type < n_boardtypes; type++) {
+       for (type = 0; type < ARRAY_SIZE(boardtypes); type++) {
                if (boardtypes[type].boardcode == board_code)
                        goto havetype;
        }
index 7e6995ed886d5e5f8588c272c3bc07f9f9baf6d4..f05b3e71115774cd3d2a03fab980b0ee84e3de3f 100644 (file)
@@ -222,7 +222,7 @@ static struct comedi_driver driver_dt2811 = {
        .attach = dt2811_attach,
        .detach = dt2811_detach,
        .board_name = &boardtypes[0].name,
-       .num_names = sizeof(boardtypes) / sizeof(struct dt2811_board),
+       .num_names = ARRAY_SIZE(boardtypes),
        .offset = sizeof(struct dt2811_board),
 };
 
index 098a78e9307a57bbd603e089bc19372cccb4d460..a344e2cebde10e225dfc5bc4ebd4bbeb1f9fecb0 100644 (file)
@@ -283,11 +283,6 @@ static const struct hpdi_board hpdi_boards[] = {
 #endif
 };
 
-static inline unsigned int num_boards(void)
-{
-       return sizeof(hpdi_boards) / sizeof(struct hpdi_board);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(hpdi_pci_table) = {
        {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX, 0x2400,
                0, 0, 0},
@@ -568,7 +563,7 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                return -ENOMEM;
 
        pcidev = NULL;
-       for (i = 0; i < num_boards() && dev->board_ptr == NULL; i++) {
+       for (i = 0; i < ARRAY_SIZE(hpdi_boards) && dev->board_ptr == NULL; i++) {
                do {
                        pcidev = pci_get_subsys(PCI_VENDOR_ID_PLX,
                                hpdi_boards[i].device_id, PCI_VENDOR_ID_PLX,
index c3db3b80eba4847146dff225ee287578cdb00173..bffa3cf91c84c97ad56a71c797685318fd2b8e9f 100644 (file)
@@ -113,7 +113,7 @@ static const struct me4000_board me4000_boards[] = {
        {0},
 };
 
-#define ME4000_BOARD_VERSIONS (sizeof(me4000_boards) / sizeof(struct me4000_board) - 1)
+#define ME4000_BOARD_VERSIONS (ARRAY_SIZE(me4000_boards) - 1)
 
 /*-----------------------------------------------------------------------------
   Comedi function prototypes
index 1b752f615002fd09cee17a5abcbe6109d70a3710..4e8bf9ed167ccdf75a7145d5fe6e9d98525e734c 100644 (file)
@@ -190,7 +190,7 @@ static struct comedi_driver driver_atao = {
        .detach = atao_detach,
        .board_name = &atao_boards[0].name,
        .offset = sizeof(struct atao_board),
-       .num_names = sizeof(atao_boards) / sizeof(struct atao_board),
+       .num_names = ARRAY_SIZE(atao_boards),
 };
 
 COMEDI_INITCLEANUP(driver_atao);
index 3f0c1b3694dc9c30fbac61f17615f0b3104b8e6f..f01c0b008b50152d212193e35e047cc9294eacae 100644 (file)
@@ -104,7 +104,7 @@ static struct comedi_driver driver_dio700 = {
        .module = THIS_MODULE,
        .attach = dio700_attach,
        .detach = dio700_detach,
-       .num_names = sizeof(dio700_boards) / sizeof(struct dio700_board),
+       .num_names = ARRAY_SIZE(dio700_boards),
        .board_name = &dio700_boards[0].name,
        .offset = sizeof(struct dio700_board),
 };
index a0b3dd25438413e5d0bc8e287d5c7d38e669fe44..68c3121c1b323daf19944ca49ea4e4496001c982 100644 (file)
@@ -104,7 +104,7 @@ static struct comedi_driver driver_dio24 = {
        .module = THIS_MODULE,
        .attach = dio24_attach,
        .detach = dio24_detach,
-       .num_names = sizeof(dio24_boards) / sizeof(struct dio24_board_struct),
+       .num_names = ARRAY_SIZE(dio24_boards),
        .board_name = &dio24_boards[0].name,
        .offset = sizeof(struct dio24_board_struct),
 };
index d1a2b5065036ec884f60ca68c981b0da6730d553..031d994ed227121e75b6ec4fd12ee7321b2edd94 100644 (file)
@@ -434,7 +434,7 @@ static struct comedi_driver driver_labpc = {
        .module = THIS_MODULE,
        .attach = labpc_attach,
        .detach = labpc_common_detach,
-       .num_names = sizeof(labpc_boards) / sizeof(struct labpc_board_struct),
+       .num_names = ARRAY_SIZE(labpc_boards),
        .board_name = &labpc_boards[0].name,
        .offset = sizeof(struct labpc_board_struct),
 };
index 41538c3c80ff3a7eb58778db5445bab075e281c8..fb56c03a1b9fb9a6a92d5c43eca368afa41ef856 100644 (file)
@@ -121,7 +121,7 @@ static struct comedi_driver driver_labpc_cs = {
        .module = THIS_MODULE,
        .attach = &labpc_attach,
        .detach = &labpc_common_detach,
-       .num_names = sizeof(labpc_cs_boards) / sizeof(struct labpc_board_struct),
+       .num_names = ARRAY_SIZE(labpc_cs_boards),
        .board_name = &labpc_cs_boards[0].name,
        .offset = sizeof(struct labpc_board_struct),
 };
index d4d352b6b465e850ba9b7d76002237bf73e1072e..f97b18181534f6cff69057af60c3f8b12586dc16 100644 (file)
@@ -1084,7 +1084,7 @@ static inline int M_Offset_Static_AI_Control(int i)
                0x262,
                0x263,
        };
-       if (((unsigned)i) >= sizeof(offset) / sizeof(offset[0])) {
+       if (((unsigned)i) >= ARRAY_SIZE(offset)) {
                rt_printk("%s: invalid channel=%i\n", __func__, i);
                return offset[0];
        }
@@ -1098,7 +1098,7 @@ static inline int M_Offset_AO_Reference_Attenuation(int channel)
                0x266,
                0x267
        };
-       if (((unsigned)channel) >= sizeof(offset) / sizeof(offset[0])) {
+       if (((unsigned)channel) >= ARRAY_SIZE(offset)) {
                rt_printk("%s: invalid channel=%i\n", __func__, channel);
                return offset[0];
        }
index 7bc4d7ef950597201889144ccb4d10d3a761ee77..f1a8cdfaaa487ebc4ecd8fc21fd6f75bf825bb4b 100644 (file)
@@ -137,7 +137,7 @@ static struct comedi_driver driver = {
         */
        .board_name = &pcmda12_boards[0].name,
        .offset = sizeof(struct pcmda12_board),
-       .num_names = sizeof(pcmda12_boards) / sizeof(struct pcmda12_board),
+       .num_names = ARRAY_SIZE(pcmda12_boards),
 };
 
 static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
index 9d025ab5b9f3d7bed8d33a306df16dabc020b649..2ff2fe94b7042afa342ad61b5f5ed2e9ef5ccc75 100644 (file)
@@ -292,7 +292,7 @@ static struct comedi_driver driver = {
         */
        .board_name = &pcmmio_boards[0].name,
        .offset = sizeof(struct pcmmio_board),
-       .num_names = sizeof(pcmmio_boards) / sizeof(struct pcmmio_board),
+       .num_names = ARRAY_SIZE(pcmmio_boards),
 };
 
 static int pcmmio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
index e515eadc0fb58ef1b74c3d6d545a695455f1d76f..c28e6dfd0f9c3a9d783b5719b12b7e5c22e15538 100644 (file)
@@ -250,7 +250,7 @@ static struct comedi_driver driver = {
         */
        .board_name = &pcmuio_boards[0].name,
        .offset = sizeof(struct pcmuio_board),
-       .num_names = sizeof(pcmuio_boards) / sizeof(struct pcmuio_board),
+       .num_names = ARRAY_SIZE(pcmuio_boards),
 };
 
 static int pcmuio_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
index 0e765641838b1476f7238534d5c34306b7a9120c..6af081b04a0cea957b1558d9b3bf0cbe808b4abe 100644 (file)
@@ -757,7 +757,7 @@ static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                                continue;
                        }
                }
-               for (i = 0; i < sizeof (rtd520Boards) / sizeof (rtd520Boards[0]); ++i)
+               for (i = 0; i < ARRAY_SIZE(rtd520Boards); ++i)
                {
                        if (pcidev->device == rtd520Boards[i].device_id)
                        {
index 57541d52a159daf5a8910a18212175deaa6274a0..3986459a1645ec75532f7b9f7b486dcd0a0c9f5e 100644 (file)
@@ -138,7 +138,7 @@ static struct comedi_driver driver_rti800 = {
        .module = THIS_MODULE,
        .attach = rti800_attach,
        .detach = rti800_detach,
-       .num_names = sizeof(boardtypes) / sizeof(struct rti800_board),
+       .num_names = ARRAY_SIZE(boardtypes),
        .board_name = &boardtypes[0].name,
        .offset = sizeof(struct rti800_board),
 };
@@ -199,8 +199,7 @@ static int rti800_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
                /* without a delay here, the RTI_OVERRUN bit
                 * gets set, and you will have an error. */
                if (insn->n > 0) {
-                       BUG_ON(gain >=
-                               sizeof(gaindelay) / sizeof(gaindelay[0]));
+                       BUG_ON(gain >= ARRAY_SIZE(gaindelay));
                        comedi_udelay(gaindelay[gain]);
                }
        }
index d9b8f837bfdb590022a0352cffe39c1daeab8396..7a6be1ee8f61159ae32925d4bf4ebd9fde872975 100644 (file)
@@ -244,7 +244,7 @@ static struct comedi_driver driver_s526 = {
         */
        .board_name = &s526_boards[0].name,
        .offset = sizeof(struct s526_board),
-       .num_names = sizeof(s526_boards) / sizeof(struct s526_board),
+       .num_names = ARRAY_SIZE(s526_boards),
 };
 
 static int s526_gpct_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
index 6e78194fe551dfd8b94c4c9c8c0017f02902369f..ff8ec589298ca0f75fa1e1144f205d144caadf84 100644 (file)
@@ -2358,7 +2358,7 @@ static void LoadTrimDACs(struct comedi_device *dev)
        register uint8_t i;
 
        /*  Copy TrimDac setpoint values from EEPROM to TrimDacs. */
-       for (i = 0; i < (sizeof(trimchan) / sizeof(trimchan[0])); i++)
+       for (i = 0; i < ARRAY_SIZE(trimchan); i++)
                WriteTrimDAC(dev, i, I2Cread(dev, trimadrs[i]));
 }
 
index cf3e925261a035d595e16dfb688f3656263dfbe6..89f97e85eff324f65bb6030355b596a86881ead0 100644 (file)
@@ -98,7 +98,7 @@ struct comedi_driver driver_serial2002 = {
        .detach = serial2002_detach,
        .board_name = &serial2002_boards[0].name,
        .offset = sizeof(struct serial2002_board),
-       .num_names = sizeof(serial2002_boards) / sizeof(struct serial2002_board),
+       .num_names = ARRAY_SIZE(serial2002_boards),
 };
 
 static int serial2002_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
index a0764f81917bb9df70cf697ef95a1ad69a4bc414..b73518129f85bff265d266b2e0311daa030a999b 100644 (file)
@@ -181,7 +181,7 @@ static struct comedi_driver driver_skel = {
         */
        .board_name = &skel_boards[0].name,
        .offset = sizeof(struct skel_board),
-       .num_names = sizeof(skel_boards) / sizeof(struct skel_board),
+       .num_names = ARRAY_SIZE(skel_boards),
 };
 
 static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
index b12c42991bba2601e6bd8570fa1c47ea3914ae39..13c29bb99100f5a654f43d3505e70dda6f2afcf0 100644 (file)
@@ -99,7 +99,7 @@ static struct comedi_driver driver_dnp = {
        .board_name = &dnp_boards[0].name,
        /* only necessary for non-PnP devs   */
        .offset = sizeof(struct dnp_board),/* like ISA-PnP, PCI or PCMCIA.      */
-       .num_names = sizeof(dnp_boards) / sizeof(struct dnp_board),
+       .num_names = ARRAY_SIZE(dnp_boards),
 };
 
 COMEDI_INITCLEANUP(driver_dnp);