staging: comedi: addi_apci_3xxx: refactor 'i_NbrAoChannel' boardinfo
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 12 Jun 2013 23:14:47 +0000 (16:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jun 2013 21:33:42 +0000 (14:33 -0700)
The boards that have analog outputs always have 4 channels.

Remove the 'i_NbrAoChannel' data from the boardinfo and add a bit
field to indicate that the board 'has_ao'. Use that to conditionally
initialize the subdevice and open code the s->n_chan value of 4.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi_apci_3xxx.c

index 394d4105a4b206baf760482dc938bc6804ff80b6..8453dfe2d7391dee463b2f51b58865b682294855 100644 (file)
@@ -81,10 +81,10 @@ struct apci3xxx_boardinfo {
        int i_NbrAiChannel;
        int i_NbrAiChannelDiff;
        int i_AiChannelList;
-       int i_NbrAoChannel;
        int i_AiMaxdata;
        unsigned char b_AvailableConvertUnit;
        unsigned int ui_MinAcquisitiontimeNs;
+       unsigned int has_ao:1;
        unsigned int has_dig_in:1;
        unsigned int has_dig_out:1;
        unsigned int has_ttl_io:1;
@@ -228,10 +228,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .i_AiChannelList        = 16,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 4095,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 10000,
+               .has_ao                 = 1,
                .has_ttl_io             = 1,
        },
        [BOARD_APCI3100_8_4] = {
@@ -239,10 +239,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .i_AiChannelList        = 8,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 4095,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 10000,
+               .has_ao                 = 1,
                .has_ttl_io             = 1,
        },
        [BOARD_APCI3106_16_4] = {
@@ -250,10 +250,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .i_AiChannelList        = 16,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 65535,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 10000,
+               .has_ao                 = 1,
                .has_ttl_io             = 1,
        },
        [BOARD_APCI3106_8_4] = {
@@ -261,10 +261,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .i_AiChannelList        = 8,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 65535,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 10000,
+               .has_ao                 = 1,
                .has_ttl_io             = 1,
        },
        [BOARD_APCI3110_16_4] = {
@@ -272,10 +272,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .i_AiChannelList        = 16,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 4095,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 5000,
+               .has_ao                 = 1,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
                .has_ttl_io             = 1,
@@ -285,10 +285,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .i_AiChannelList        = 8,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 4095,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 5000,
+               .has_ao                 = 1,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
                .has_ttl_io             = 1,
@@ -298,10 +298,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .i_AiChannelList        = 16,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 65535,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 5000,
+               .has_ao                 = 1,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
                .has_ttl_io             = 1,
@@ -311,10 +311,10 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .i_AiChannelList        = 8,
-               .i_NbrAoChannel         = 4,
                .i_AiMaxdata            = 65535,
                .b_AvailableConvertUnit = 6,
                .ui_MinAcquisitiontimeNs = 5000,
+               .has_ao                 = 1,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
                .has_ttl_io             = 1,
@@ -361,7 +361,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
        },
        [BOARD_APCI3500] = {
                .pc_DriverName          = "apci3500",
-               .i_NbrAoChannel         = 4,
+               .has_ao                 = 1,
                .has_ttl_io             = 1,
        },
 };
@@ -555,10 +555,10 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
 
        /*  Allocate and Initialise AO Subdevice Structures */
        s = &dev->subdevices[1];
-       if (board->i_NbrAoChannel) {
+       if (board->has_ao) {
                s->type = COMEDI_SUBD_AO;
                s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = board->i_NbrAoChannel;
+               s->n_chan = 4;
                s->maxdata = 0x0fff;
                s->range_table = &apci3xxx_ao_range;
                s->insn_write = i_APCI3XXX_InsnWriteAnalogOutput;