From: Bill Pemberton Date: Thu, 23 Apr 2009 19:54:56 +0000 (-0400) Subject: Staging: comedi: make use of ARRAY_SIZE macro X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=8629efa4cbf6f89a54a85af4b8bc31762af01800;p=linux-beck.git Staging: comedi: make use of ARRAY_SIZE macro 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index cabbf090f60b..e5185ac3604c 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -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) diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 7cd6043ed49f..b4807fc7eb01 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -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)) { diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index 54724653a792..c51e9ba58808 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -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); diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index 764cac2fd7d2..d062f8619b6e 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -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, diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 582d6a2cfef6..ddf58d4866eb 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -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 diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 3befe507ce2f..235cbfffa14b 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -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 diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 1d516b1f1591..c804c7c649c1 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -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, diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 19e4428c3380..6b53cb4b93f9 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -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); diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 1d675173cd32..057443551c23 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -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); diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 17dec7567481..11212b01d493 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -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? */ diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index adce530adc53..caa8b568871d 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -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? */ diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c index 799b5aded13c..dc701273167c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidio.c +++ b/drivers/staging/comedi/drivers/cb_pcidio.c @@ -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; diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 3ce133c69e27..57bb1182480d 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -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? */ diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 1ee489864d3b..45cd41f7fd29 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -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, diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index e679328a4f8f..93ed1a0ae126 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -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); diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 982837d879ce..6ca888429e6a 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -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]), }; diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 91b1a0e7575c..e22f546e8162 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -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]), }; diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 9c6c9b89558a..7fbcfb107e6d 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -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), }; diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index db646598619e..6ee9648e5e18 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -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), }; diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index e7c5130de8d0..47b3ebc34a68 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -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 */ diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 335e3a0660cf..9b100405b8b7 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -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; } diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 7e6995ed886d..f05b3e711157 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -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), }; diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 098a78e9307a..a344e2cebde1 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -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, diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index c3db3b80eba4..bffa3cf91c84 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -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 diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 1b752f615002..4e8bf9ed167c 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -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); diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 3f0c1b3694dc..f01c0b008b50 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -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), }; diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index a0b3dd254384..68c3121c1b32 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -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), }; diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index d1a2b5065036..031d994ed227 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -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), }; diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index 41538c3c80ff..fb56c03a1b9f 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -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), }; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index d4d352b6b465..f97b18181534 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -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]; } diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 7bc4d7ef9505..f1a8cdfaaa48 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -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, diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 9d025ab5b9f3..2ff2fe94b704 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -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, diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index e515eadc0fb5..c28e6dfd0f9c 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -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, diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 0e765641838b..6af081b04a0c 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -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) { diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index 57541d52a159..3986459a1645 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -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]); } } diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index d9b8f837bfdb..7a6be1ee8f61 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -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, diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 6e78194fe551..ff8ec589298c 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -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])); } diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index cf3e925261a0..89f97e85eff3 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -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, diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index a0764f81917b..b73518129f85 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -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, diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index b12c42991bba..13c29bb99100 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -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);