]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: addi_apci_3xxx: clarify 'b_AvailableConvertUnit'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 12 Jun 2013 23:20:32 +0000 (16:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jun 2013 21:33:55 +0000 (14:33 -0700)
This boardinfo defines the conversion time bases that the analog input
subdevice supports (ns, us, ms).

Add some defines to get rid of the magic numbers and clarify the code.

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-data/hwdrv_apci3xxx.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c

index 8c825a79671397d23f6ee5b4373527b0321a39ae..edb91849881a5ab502b51d4b543649cb66428d84 100644 (file)
@@ -49,19 +49,23 @@ static int apci3xxx_ai_configure(struct comedi_device *dev,
        if (aref_mode != 0 && aref_mode != 1)
                return -EINVAL;
 
-       if (!(board->b_AvailableConvertUnit & (1 << time_base)))
+       if (time_base > 2)
                return -EINVAL;
 
        if (reload_time > 0xffff)
                return -EINVAL;
 
+       time_base = 1 << time_base;
+       if (!(board->ai_conv_units & time_base))
+               return -EINVAL;
+
        switch (time_base) {
-       case 0:
-               acq_ns = reload_time;           /* ns */
-       case 1:
-               acq_ns = reload_time * 1000;    /* us */
-       case 2:
-               acq_ns = reload_time * 1000000; /* ms */
+       case CONV_UNIT_NS:
+               acq_ns = reload_time;
+       case CONV_UNIT_US:
+               acq_ns = reload_time * 1000;
+       case CONV_UNIT_MS:
+               acq_ns = reload_time * 1000000;
        default:
                return -EINVAL;
        }
index c6cd30bdce969ae13129043a5a2641852e442b30..8deec2b0734f6d927dd803399ac4be7802c93d09 100644 (file)
 
 #include "../comedidev.h"
 
+#define CONV_UNIT_NS           (1 << 0)
+#define CONV_UNIT_US           (1 << 1)
+#define CONV_UNIT_MS           (1 << 2)
+
 static const struct comedi_lrange apci3xxx_ai_range = {
        8, {
                BIP_RANGE(10),
@@ -81,7 +85,7 @@ struct apci3xxx_boardinfo {
        int i_NbrAiChannel;
        int i_NbrAiChannelDiff;
        unsigned int ai_maxdata;
-       unsigned char b_AvailableConvertUnit;
+       unsigned char ai_conv_units;
        unsigned int ui_MinAcquisitiontimeNs;
        unsigned int has_ao:1;
        unsigned int has_dig_in:1;
@@ -96,7 +100,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ttl_io             = 1,
        },
@@ -106,7 +110,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ttl_io             = 1,
        },
@@ -116,7 +120,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 4,
                .i_NbrAiChannelDiff     = 2,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ttl_io             = 1,
        },
@@ -126,7 +130,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ttl_io             = 1,
        },
@@ -136,7 +140,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ttl_io             = 1,
        },
@@ -146,7 +150,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 4,
                .i_NbrAiChannelDiff     = 2,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ttl_io             = 1,
        },
@@ -156,7 +160,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -168,7 +172,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -180,7 +184,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 4,
                .i_NbrAiChannelDiff     = 2,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -192,7 +196,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -204,7 +208,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -216,7 +220,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 4,
                .i_NbrAiChannelDiff     = 2,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -228,7 +232,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ao                 = 1,
                .has_ttl_io             = 1,
@@ -239,7 +243,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ao                 = 1,
                .has_ttl_io             = 1,
@@ -250,7 +254,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ao                 = 1,
                .has_ttl_io             = 1,
@@ -261,7 +265,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 10000,
                .has_ao                 = 1,
                .has_ttl_io             = 1,
@@ -272,7 +276,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_ao                 = 1,
                .has_dig_in             = 1,
@@ -285,7 +289,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0x0fff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_ao                 = 1,
                .has_dig_in             = 1,
@@ -298,7 +302,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 16,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_ao                 = 1,
                .has_dig_in             = 1,
@@ -311,7 +315,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .i_NbrAiChannel         = 8,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_ao                 = 1,
                .has_dig_in             = 1,
@@ -323,7 +327,8 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .ai_subdev_flags        = SDF_DIFF,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 7,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US |
+                                         CONV_UNIT_NS,
                .ui_MinAcquisitiontimeNs = 2500,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -333,7 +338,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .ai_subdev_flags        = SDF_DIFF,
                .i_NbrAiChannelDiff     = 16,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -343,7 +348,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .ai_subdev_flags        = SDF_DIFF,
                .i_NbrAiChannelDiff     = 8,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,
@@ -353,7 +358,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
                .ai_subdev_flags        = SDF_DIFF,
                .i_NbrAiChannelDiff     = 4,
                .ai_maxdata             = 0xffff,
-               .b_AvailableConvertUnit = 6,
+               .ai_conv_units          = CONV_UNIT_MS | CONV_UNIT_US,
                .ui_MinAcquisitiontimeNs = 5000,
                .has_dig_in             = 1,
                .has_dig_out            = 1,