/* 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)
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,
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)) {
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);
.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,
.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
.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
.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,
.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);
.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);
},
};
-/* 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},
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? */
#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},
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? */
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;
*/
#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)
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? */
*/
.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,
.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);
#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 = {
.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]),
};
},
};
-#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 = {
.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]),
};
.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),
};
.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),
};
*/
.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 */
.dabits = 12},
};
-#define n_boardtypes ((sizeof(boardtypes))/(sizeof(boardtypes[0])))
#define boardtype (*(const struct dt2801_board *)dev->board_ptr)
struct dt2801_private {
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;
}
.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),
};
#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},
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,
{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
.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);
.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),
};
.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),
};
.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),
};
.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),
};
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];
}
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];
}
*/
.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,
*/
.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,
*/
.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,
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)
{
.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),
};
/* 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]);
}
}
*/
.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,
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]));
}
.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,
*/
.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,
.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);