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 cabbf09..e5185ac 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 7cd6043..b4807fc 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 5472465..c51e9ba 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 764cac2..d062f86 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 582d6a2..ddf58d4 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 3befe50..235cbff 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 1d516b1..c804c7c 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 19e4428..6b53cb4 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 1d67517..0574435 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 17dec75..11212b0 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 adce530..caa8b56 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 799b5ad..dc70127 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 3ce133c..57bb118 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 1ee4898..45cd41f 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 e679328..93ed1a0 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 982837d..6ca8884 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 91b1a0e..e22f546 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 9c6c9b8..7fbcfb1 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 db64659..6ee9648 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 e7c5130..47b3ebc 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 335e3a0..9b10040 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 7e6995e..f05b3e7 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 098a78e..a344e2c 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 c3db3b8..bffa3cf 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 1b752f6..4e8bf9e 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 3f0c1b3..f01c0b0 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 a0b3dd2..68c3121 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 d1a2b50..031d994 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 41538c3..fb56c03 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 d4d352b..f97b181 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 7bc4d7e..f1a8cdf 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 9d025ab..2ff2fe9 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 e515ead..c28e6df 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 0e76564..6af081b 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 57541d5..3986459 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 d9b8f83..7a6be1e 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 6e78194..ff8ec58 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 cf3e925..89f97e8 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 a0764f8..b735181 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 b12c429..13c29bb 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);