Commit 7f03b749 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: s626: remove 'set_load_trig' callback from encoder private data

There are two functions used for the 'set_load_trig' callback, One is used for
the channel 0-2 encoders and the other for the channel 3-5 encoders.

Refactor the two callbacks into a single s626_set_load_trig() function and use
the encoder channel number to handle the differences.

Remove the then unnecessary 'set_load_trig' member and just call s626_set_load_trig()
drectly.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4487502e
...@@ -122,9 +122,6 @@ struct s626_enc_info { ...@@ -122,9 +122,6 @@ struct s626_enc_info {
/* Program interrupt source. */ /* Program interrupt source. */
void (*set_int_src)(struct comedi_device *dev, void (*set_int_src)(struct comedi_device *dev,
const struct s626_enc_info *k, uint16_t int_source); const struct s626_enc_info *k, uint16_t int_source);
/* Program preload trigger source. */
void (*set_load_trig)(struct comedi_device *dev,
const struct s626_enc_info *k, uint16_t trig);
/* Program standardized operating mode. */ /* Program standardized operating mode. */
void (*set_mode)(struct comedi_device *dev, void (*set_mode)(struct comedi_device *dev,
const struct s626_enc_info *k, uint16_t setup, const struct s626_enc_info *k, uint16_t setup,
...@@ -1109,19 +1106,23 @@ static uint16_t s626_get_latch_source(struct comedi_device *dev, ...@@ -1109,19 +1106,23 @@ static uint16_t s626_get_latch_source(struct comedi_device *dev,
* register into the counter. 0=ThisCntr_Index, 1=ThisCntr_Overflow, * register into the counter. 0=ThisCntr_Index, 1=ThisCntr_Overflow,
* 2=OverflowA (B counters only), 3=disabled. * 2=OverflowA (B counters only), 3=disabled.
*/ */
static void s626_set_load_trig_a(struct comedi_device *dev, static void s626_set_load_trig(struct comedi_device *dev,
const struct s626_enc_info *k, uint16_t trig) const struct s626_enc_info *k, uint16_t trig)
{ {
s626_debi_replace(dev, S626_LP_CRA(k->chan), ~S626_CRAMSK_LOADSRC_A, uint16_t reg;
S626_SET_CRA_LOADSRC_A(trig)); uint16_t mask;
} uint16_t set;
static void s626_set_load_trig_b(struct comedi_device *dev, if (k->chan < 3) {
const struct s626_enc_info *k, uint16_t trig) reg = S626_LP_CRA(k->chan);
{ mask = S626_CRAMSK_LOADSRC_A;
s626_debi_replace(dev, S626_LP_CRB(k->chan), set = S626_SET_CRA_LOADSRC_A(trig);
~(S626_CRBMSK_LOADSRC_B | S626_CRBMSK_INTCTRL), } else {
S626_SET_CRB_LOADSRC_B(trig)); reg = S626_LP_CRB(k->chan);
mask = S626_CRBMSK_LOADSRC_B | S626_CRBMSK_INTCTRL;
set = S626_SET_CRB_LOADSRC_B(trig);
}
s626_debi_replace(dev, reg, ~mask, set);
} }
static uint16_t s626_get_load_trig_a(struct comedi_device *dev, static uint16_t s626_get_load_trig_a(struct comedi_device *dev,
...@@ -1321,7 +1322,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = { ...@@ -1321,7 +1322,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = {
.get_mode = s626_get_mode_a, .get_mode = s626_get_mode_a,
.pulse_index = s626_pulse_index_a, .pulse_index = s626_pulse_index_a,
.set_int_src = s626_set_int_src_a, .set_int_src = s626_set_int_src_a,
.set_load_trig = s626_set_load_trig_a,
.set_mode = s626_set_mode_a, .set_mode = s626_set_mode_a,
.reset_cap_flags = s626_reset_cap_flags_a, .reset_cap_flags = s626_reset_cap_flags_a,
.my_event_bits = S626_EVBITS(0), .my_event_bits = S626_EVBITS(0),
...@@ -1332,7 +1332,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = { ...@@ -1332,7 +1332,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = {
.get_mode = s626_get_mode_a, .get_mode = s626_get_mode_a,
.pulse_index = s626_pulse_index_a, .pulse_index = s626_pulse_index_a,
.set_int_src = s626_set_int_src_a, .set_int_src = s626_set_int_src_a,
.set_load_trig = s626_set_load_trig_a,
.set_mode = s626_set_mode_a, .set_mode = s626_set_mode_a,
.reset_cap_flags = s626_reset_cap_flags_a, .reset_cap_flags = s626_reset_cap_flags_a,
.my_event_bits = S626_EVBITS(1), .my_event_bits = S626_EVBITS(1),
...@@ -1343,7 +1342,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = { ...@@ -1343,7 +1342,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = {
.get_mode = s626_get_mode_a, .get_mode = s626_get_mode_a,
.pulse_index = s626_pulse_index_a, .pulse_index = s626_pulse_index_a,
.set_int_src = s626_set_int_src_a, .set_int_src = s626_set_int_src_a,
.set_load_trig = s626_set_load_trig_a,
.set_mode = s626_set_mode_a, .set_mode = s626_set_mode_a,
.reset_cap_flags = s626_reset_cap_flags_a, .reset_cap_flags = s626_reset_cap_flags_a,
.my_event_bits = S626_EVBITS(2), .my_event_bits = S626_EVBITS(2),
...@@ -1354,7 +1352,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = { ...@@ -1354,7 +1352,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = {
.get_mode = s626_get_mode_b, .get_mode = s626_get_mode_b,
.pulse_index = s626_pulse_index_b, .pulse_index = s626_pulse_index_b,
.set_int_src = s626_set_int_src_b, .set_int_src = s626_set_int_src_b,
.set_load_trig = s626_set_load_trig_b,
.set_mode = s626_set_mode_b, .set_mode = s626_set_mode_b,
.reset_cap_flags = s626_reset_cap_flags_b, .reset_cap_flags = s626_reset_cap_flags_b,
.my_event_bits = S626_EVBITS(3), .my_event_bits = S626_EVBITS(3),
...@@ -1365,7 +1362,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = { ...@@ -1365,7 +1362,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = {
.get_mode = s626_get_mode_b, .get_mode = s626_get_mode_b,
.pulse_index = s626_pulse_index_b, .pulse_index = s626_pulse_index_b,
.set_int_src = s626_set_int_src_b, .set_int_src = s626_set_int_src_b,
.set_load_trig = s626_set_load_trig_b,
.set_mode = s626_set_mode_b, .set_mode = s626_set_mode_b,
.reset_cap_flags = s626_reset_cap_flags_b, .reset_cap_flags = s626_reset_cap_flags_b,
.my_event_bits = S626_EVBITS(4), .my_event_bits = S626_EVBITS(4),
...@@ -1376,7 +1372,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = { ...@@ -1376,7 +1372,6 @@ static const struct s626_enc_info s626_enc_chan_info[] = {
.get_mode = s626_get_mode_b, .get_mode = s626_get_mode_b,
.pulse_index = s626_pulse_index_b, .pulse_index = s626_pulse_index_b,
.set_int_src = s626_set_int_src_b, .set_int_src = s626_set_int_src_b,
.set_load_trig = s626_set_load_trig_b,
.set_mode = s626_set_mode_b, .set_mode = s626_set_mode_b,
.reset_cap_flags = s626_reset_cap_flags_b, .reset_cap_flags = s626_reset_cap_flags_b,
.my_event_bits = S626_EVBITS(5), .my_event_bits = S626_EVBITS(5),
...@@ -2128,11 +2123,11 @@ static void s626_timer_load(struct comedi_device *dev, ...@@ -2128,11 +2123,11 @@ static void s626_timer_load(struct comedi_device *dev,
* Software index pulse forces the preload register to load * Software index pulse forces the preload register to load
* into the counter * into the counter
*/ */
k->set_load_trig(dev, k, 0); s626_set_load_trig(dev, k, 0);
k->pulse_index(dev, k); k->pulse_index(dev, k);
/* set reload on counter overflow */ /* set reload on counter overflow */
k->set_load_trig(dev, k, 1); s626_set_load_trig(dev, k, 1);
/* set interrupt on overflow */ /* set interrupt on overflow */
k->set_int_src(dev, k, S626_INTSRC_OVER); k->set_int_src(dev, k, S626_INTSRC_OVER);
...@@ -2554,9 +2549,9 @@ static int s626_enc_insn_write(struct comedi_device *dev, ...@@ -2554,9 +2549,9 @@ static int s626_enc_insn_write(struct comedi_device *dev,
* Software index pulse forces the preload register to load * Software index pulse forces the preload register to load
* into the counter * into the counter
*/ */
k->set_load_trig(dev, k, 0); s626_set_load_trig(dev, k, 0);
k->pulse_index(dev, k); k->pulse_index(dev, k);
k->set_load_trig(dev, k, 2); s626_set_load_trig(dev, k, 2);
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment