From 7828f09660947ea7c15c4f02475d7789755939bc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 17 Jan 2013 17:40:31 -0700 Subject: [PATCH] staging: comedi: addi_apci_2200: cleanup digital output subdevice The board supported by this driver always has a digital output subdevice. Remove the boardinfo for it and just open-code the relevant data in the subdevice init. Remove the SDF_GROUND and SDF_COMMON from the subdevice 'subdev_flags'. These flags only have meaning for analog input/output subdevices. Also, remove the SDF_READABLE flag, it is not required by output only subdevices. Remove the subdevice 'len_chanlist' initialization. This variable only has meaning for subdevices that support asynchronous commands. Remove the subdevice 'io_bits' initialization. Digital output subdevices don't use this variable. Remove the subdevice function pointers that evaluate to NULL based on the boardinfo data. Move the apci2200_do_insn_bits() function from the hwdrv_apci2200.c file into the main driver file. For aesthetic reasons, rename the #define used for the register used to read/write the digital outputs.. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci2200.c | 27 ---------- .../staging/comedi/drivers/addi_apci_2200.c | 50 +++++++++++-------- 2 files changed, 29 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c index f9784e91a25e..4d32509f0c6b 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c @@ -46,12 +46,6 @@ You should also find the complete GPL in the COPYING file accompanying this sour +----------+-----------+------------------------------------------------+ */ -/********* Definitions for APCI-2200 card *****/ - -/* DIGITAL INPUT-OUTPUT DEFINE */ - -#define APCI2200_DIGITAL_OP 4 - /* TIMER COUNTER WATCHDOG DEFINES */ #define APCI2200_WATCHDOG 0x08 @@ -59,27 +53,6 @@ You should also find the complete GPL in the COPYING file accompanying this sour #define APCI2200_WATCHDOG_RELOAD_VALUE 4 #define APCI2200_WATCHDOG_STATUS 16 -static int apci2200_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned int mask = data[0]; - unsigned int bits = data[1]; - - s->state = inw(dev->iobase + APCI2200_DIGITAL_OP); - if (mask) { - s->state &= ~mask; - s->state |= (bits & mask); - - outw(s->state, dev->iobase + APCI2200_DIGITAL_OP); - } - - data[1] = s->state; - - return insn->n; -} - /* +----------------------------------------------------------------------------+ | Function Name : int i_APCI2200_ConfigWatchdog(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index 3db402ca87a5..15a84e5b34e7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -9,15 +9,14 @@ * I/O Register Map */ #define APCI2200_DI_REG 0x00 +#define APCI2200_DO_REG 0x04 static const struct addi_board apci2200_boardtypes[] = { { .pc_DriverName = "apci2200", .i_VendorId = PCI_VENDOR_ID_ADDIDATA, .i_DeviceId = 0x1005, - .i_NbrDoChannel = 16, .i_Timer = 1, - .do_bits = apci2200_do_insn_bits, .timer_config = i_APCI2200_ConfigWatchdog, .timer_write = i_APCI2200_StartStopWriteWatchdog, .timer_read = i_APCI2200_ReadWatchdog, @@ -34,9 +33,30 @@ static int apci2200_di_insn_bits(struct comedi_device *dev, return insn->n; } +static int apci2200_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + unsigned int mask = data[0]; + unsigned int bits = data[1]; + + s->state = inw(dev->iobase + APCI2200_DO_REG); + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); + + outw(s->state, dev->iobase + APCI2200_DO_REG); + } + + data[1] = s->state; + + return insn->n; +} + static int apci2200_reset(struct comedi_device *dev) { - outw(0x0, dev->iobase + APCI2200_DIGITAL_OP); + outw(0x0, dev->iobase + APCI2200_DO_REG); outw(0x0, dev->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE); outw(0x0, dev->iobase + APCI2200_WATCHDOG + @@ -114,24 +134,12 @@ static int apci2200_auto_attach(struct comedi_device *dev, /* Allocate and Initialise DO Subdevice Structures */ s = &dev->subdevices[3]; - if (this_board->i_NbrDoChannel) { - s->type = COMEDI_SUBD_DO; - s->subdev_flags = - SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = this_board->i_NbrDoChannel; - s->maxdata = this_board->i_DoMaxdata; - s->len_chanlist = this_board->i_NbrDoChannel; - s->range_table = &range_digital; - s->io_bits = 0xf; /* all bits output */ - - /* insn_config - for digital output memory */ - s->insn_config = this_board->do_config; - s->insn_write = this_board->do_write; - s->insn_bits = this_board->do_bits; - s->insn_read = this_board->do_read; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITEABLE; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = apci2200_do_insn_bits; /* Allocate and Initialise Timer Subdevice Structures */ s = &dev->subdevices[4]; -- 2.30.2