@@ -2080,7 +2080,7 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
20802080 const struct ni_board_struct * board = comedi_board (dev );
20812081 struct ni_private * devpriv = dev -> private ;
20822082 int err = 0 ;
2083- int tmp ;
2083+ unsigned int tmp ;
20842084 unsigned int sources ;
20852085
20862086 /* Step 1 : check if triggers are trivially valid */
@@ -2119,17 +2119,19 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
21192119
21202120 /* Step 3: check if arguments are trivially valid */
21212121
2122- if (cmd -> start_src == TRIG_EXT ) {
2123- /* external trigger */
2124- unsigned int tmp = CR_CHAN (cmd -> start_arg );
2122+ switch (cmd -> start_src ) {
2123+ case TRIG_NOW :
2124+ case TRIG_INT :
2125+ err |= cfc_check_trigger_arg_is (& cmd -> start_arg , 0 );
2126+ break ;
2127+ case TRIG_EXT :
2128+ tmp = CR_CHAN (cmd -> start_arg );
21252129
21262130 if (tmp > 16 )
21272131 tmp = 16 ;
21282132 tmp |= (cmd -> start_arg & (CR_INVERT | CR_EDGE ));
21292133 err |= cfc_check_trigger_arg_is (& cmd -> start_arg , tmp );
2130- } else {
2131- /* true for both TRIG_NOW and TRIG_INT */
2132- err |= cfc_check_trigger_arg_is (& cmd -> start_arg , 0 );
2134+ break ;
21332135 }
21342136
21352137 if (cmd -> scan_begin_src == TRIG_TIMER ) {
@@ -2510,30 +2512,28 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
25102512 }
25112513#endif
25122514
2513- switch (cmd -> start_src ) {
2514- case TRIG_NOW :
2515+ if (cmd -> start_src == TRIG_NOW ) {
25152516 /* AI_START1_Pulse */
25162517 devpriv -> stc_writew (dev , AI_START1_Pulse | devpriv -> ai_cmd2 ,
25172518 AI_Command_2_Register );
25182519 s -> async -> inttrig = NULL ;
2519- break ;
2520- case TRIG_EXT :
2520+ } else if (cmd -> start_src == TRIG_EXT ) {
25212521 s -> async -> inttrig = NULL ;
2522- break ;
2523- case TRIG_INT :
2524- s -> async -> inttrig = & ni_ai_inttrig ;
2525- break ;
2522+ } else { /* TRIG_INT */
2523+ s -> async -> inttrig = ni_ai_inttrig ;
25262524 }
25272525
25282526 return 0 ;
25292527}
25302528
2531- static int ni_ai_inttrig (struct comedi_device * dev , struct comedi_subdevice * s ,
2532- unsigned int trignum )
2529+ static int ni_ai_inttrig (struct comedi_device * dev ,
2530+ struct comedi_subdevice * s ,
2531+ unsigned int trig_num )
25332532{
25342533 struct ni_private * devpriv = dev -> private ;
2534+ struct comedi_cmd * cmd = & s -> async -> cmd ;
25352535
2536- if (trignum != 0 )
2536+ if (trig_num != cmd -> start_arg )
25372537 return - EINVAL ;
25382538
25392539 devpriv -> stc_writew (dev , AI_START1_Pulse | devpriv -> ai_cmd2 ,
@@ -2946,17 +2946,19 @@ static int ni_ao_insn_config(struct comedi_device *dev,
29462946 return - EINVAL ;
29472947}
29482948
2949- static int ni_ao_inttrig (struct comedi_device * dev , struct comedi_subdevice * s ,
2950- unsigned int trignum )
2949+ static int ni_ao_inttrig (struct comedi_device * dev ,
2950+ struct comedi_subdevice * s ,
2951+ unsigned int trig_num )
29512952{
29522953 const struct ni_board_struct * board __maybe_unused = comedi_board (dev );
29532954 struct ni_private * devpriv = dev -> private ;
2955+ struct comedi_cmd * cmd = & s -> async -> cmd ;
29542956 int ret ;
29552957 int interrupt_b_bits ;
29562958 int i ;
29572959 static const int timeout = 1000 ;
29582960
2959- if (trignum != 0 )
2961+ if (trig_num != cmd -> start_arg )
29602962 return - EINVAL ;
29612963
29622964 /* Null trig at beginning prevent ao start trigger from executing more than
@@ -3217,7 +3219,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
32173219 AO_BC_TC_Interrupt_Enable , 1 );
32183220 }
32193221
3220- s -> async -> inttrig = & ni_ao_inttrig ;
3222+ s -> async -> inttrig = ni_ao_inttrig ;
32213223
32223224 return 0 ;
32233225}
@@ -3228,7 +3230,7 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
32283230 const struct ni_board_struct * board = comedi_board (dev );
32293231 struct ni_private * devpriv = dev -> private ;
32303232 int err = 0 ;
3231- int tmp ;
3233+ unsigned int tmp ;
32323234
32333235 /* Step 1 : check if triggers are trivially valid */
32343236
@@ -3258,17 +3260,18 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
32583260
32593261 /* Step 3: check if arguments are trivially valid */
32603262
3261- if (cmd -> start_src == TRIG_EXT ) {
3262- /* external trigger */
3263- unsigned int tmp = CR_CHAN (cmd -> start_arg );
3263+ switch (cmd -> start_src ) {
3264+ case TRIG_INT :
3265+ err |= cfc_check_trigger_arg_is (& cmd -> start_arg , 0 );
3266+ break ;
3267+ case TRIG_EXT :
3268+ tmp = CR_CHAN (cmd -> start_arg );
32643269
32653270 if (tmp > 18 )
32663271 tmp = 18 ;
32673272 tmp |= (cmd -> start_arg & (CR_INVERT | CR_EDGE ));
32683273 err |= cfc_check_trigger_arg_is (& cmd -> start_arg , tmp );
3269- } else {
3270- /* true for both TRIG_NOW and TRIG_INT */
3271- err |= cfc_check_trigger_arg_is (& cmd -> start_arg , 0 );
3274+ break ;
32723275 }
32733276
32743277 if (cmd -> scan_begin_src == TRIG_TIMER ) {
@@ -3537,21 +3540,28 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
35373540 retval = ni_request_cdo_mite_channel (dev );
35383541 if (retval < 0 )
35393542 return retval ;
3540- s -> async -> inttrig = & ni_cdo_inttrig ;
3543+
3544+ s -> async -> inttrig = ni_cdo_inttrig ;
3545+
35413546 return 0 ;
35423547}
35433548
3544- static int ni_cdo_inttrig (struct comedi_device * dev , struct comedi_subdevice * s ,
3545- unsigned int trignum )
3549+ static int ni_cdo_inttrig (struct comedi_device * dev ,
3550+ struct comedi_subdevice * s ,
3551+ unsigned int trig_num )
35463552{
35473553#ifdef PCIDMA
35483554 struct ni_private * devpriv = dev -> private ;
35493555 unsigned long flags ;
35503556#endif
3557+ struct comedi_cmd * cmd = & s -> async -> cmd ;
35513558 int retval = 0 ;
35523559 unsigned i ;
35533560 const unsigned timeout = 1000 ;
35543561
3562+ if (trig_num != cmd -> start_arg )
3563+ return - EINVAL ;
3564+
35553565 s -> async -> inttrig = NULL ;
35563566
35573567 /* read alloc the entire buffer */
0 commit comments