mirror of https://gitee.com/openkylin/linux.git
staging: comedi: addi_apci_3xxx: clarify 'b_AvailableConvertUnit'
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>
This commit is contained in:
parent
850643bd05
commit
a67e0cc7aa
|
@ -49,19 +49,23 @@ static int apci3xxx_ai_configure(struct comedi_device *dev,
|
||||||
if (aref_mode != 0 && aref_mode != 1)
|
if (aref_mode != 0 && aref_mode != 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!(board->b_AvailableConvertUnit & (1 << time_base)))
|
if (time_base > 2)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (reload_time > 0xffff)
|
if (reload_time > 0xffff)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
time_base = 1 << time_base;
|
||||||
|
if (!(board->ai_conv_units & time_base))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
switch (time_base) {
|
switch (time_base) {
|
||||||
case 0:
|
case CONV_UNIT_NS:
|
||||||
acq_ns = reload_time; /* ns */
|
acq_ns = reload_time;
|
||||||
case 1:
|
case CONV_UNIT_US:
|
||||||
acq_ns = reload_time * 1000; /* us */
|
acq_ns = reload_time * 1000;
|
||||||
case 2:
|
case CONV_UNIT_MS:
|
||||||
acq_ns = reload_time * 1000000; /* ms */
|
acq_ns = reload_time * 1000000;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
|
|
||||||
#include "../comedidev.h"
|
#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 = {
|
static const struct comedi_lrange apci3xxx_ai_range = {
|
||||||
8, {
|
8, {
|
||||||
BIP_RANGE(10),
|
BIP_RANGE(10),
|
||||||
|
@ -81,7 +85,7 @@ struct apci3xxx_boardinfo {
|
||||||
int i_NbrAiChannel;
|
int i_NbrAiChannel;
|
||||||
int i_NbrAiChannelDiff;
|
int i_NbrAiChannelDiff;
|
||||||
unsigned int ai_maxdata;
|
unsigned int ai_maxdata;
|
||||||
unsigned char b_AvailableConvertUnit;
|
unsigned char ai_conv_units;
|
||||||
unsigned int ui_MinAcquisitiontimeNs;
|
unsigned int ui_MinAcquisitiontimeNs;
|
||||||
unsigned int has_ao:1;
|
unsigned int has_ao:1;
|
||||||
unsigned int has_dig_in:1;
|
unsigned int has_dig_in:1;
|
||||||
|
@ -96,7 +100,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
},
|
},
|
||||||
|
@ -106,7 +110,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
},
|
},
|
||||||
|
@ -116,7 +120,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 4,
|
.i_NbrAiChannel = 4,
|
||||||
.i_NbrAiChannelDiff = 2,
|
.i_NbrAiChannelDiff = 2,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
},
|
},
|
||||||
|
@ -126,7 +130,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
},
|
},
|
||||||
|
@ -136,7 +140,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
},
|
},
|
||||||
|
@ -146,7 +150,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 4,
|
.i_NbrAiChannel = 4,
|
||||||
.i_NbrAiChannelDiff = 2,
|
.i_NbrAiChannelDiff = 2,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
},
|
},
|
||||||
|
@ -156,7 +160,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -168,7 +172,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -180,7 +184,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 4,
|
.i_NbrAiChannel = 4,
|
||||||
.i_NbrAiChannelDiff = 2,
|
.i_NbrAiChannelDiff = 2,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -192,7 +196,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -204,7 +208,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -216,7 +220,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 4,
|
.i_NbrAiChannel = 4,
|
||||||
.i_NbrAiChannelDiff = 2,
|
.i_NbrAiChannelDiff = 2,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -228,7 +232,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
|
@ -239,7 +243,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
|
@ -250,7 +254,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
|
@ -261,7 +265,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 10000,
|
.ui_MinAcquisitiontimeNs = 10000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_ttl_io = 1,
|
.has_ttl_io = 1,
|
||||||
|
@ -272,7 +276,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
|
@ -285,7 +289,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0x0fff,
|
.ai_maxdata = 0x0fff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
|
@ -298,7 +302,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 16,
|
.i_NbrAiChannel = 16,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
|
@ -311,7 +315,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.i_NbrAiChannel = 8,
|
.i_NbrAiChannel = 8,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
|
@ -323,7 +327,8 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.ai_subdev_flags = SDF_DIFF,
|
.ai_subdev_flags = SDF_DIFF,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 7,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US |
|
||||||
|
CONV_UNIT_NS,
|
||||||
.ui_MinAcquisitiontimeNs = 2500,
|
.ui_MinAcquisitiontimeNs = 2500,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -333,7 +338,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.ai_subdev_flags = SDF_DIFF,
|
.ai_subdev_flags = SDF_DIFF,
|
||||||
.i_NbrAiChannelDiff = 16,
|
.i_NbrAiChannelDiff = 16,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -343,7 +348,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.ai_subdev_flags = SDF_DIFF,
|
.ai_subdev_flags = SDF_DIFF,
|
||||||
.i_NbrAiChannelDiff = 8,
|
.i_NbrAiChannelDiff = 8,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
@ -353,7 +358,7 @@ static const struct apci3xxx_boardinfo apci3xxx_boardtypes[] = {
|
||||||
.ai_subdev_flags = SDF_DIFF,
|
.ai_subdev_flags = SDF_DIFF,
|
||||||
.i_NbrAiChannelDiff = 4,
|
.i_NbrAiChannelDiff = 4,
|
||||||
.ai_maxdata = 0xffff,
|
.ai_maxdata = 0xffff,
|
||||||
.b_AvailableConvertUnit = 6,
|
.ai_conv_units = CONV_UNIT_MS | CONV_UNIT_US,
|
||||||
.ui_MinAcquisitiontimeNs = 5000,
|
.ui_MinAcquisitiontimeNs = 5000,
|
||||||
.has_dig_in = 1,
|
.has_dig_in = 1,
|
||||||
.has_dig_out = 1,
|
.has_dig_out = 1,
|
||||||
|
|
Loading…
Reference in New Issue