Commit 26499b8b authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

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

There are two functions used for the 'reset_cap_flags' 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_reset_cap_flags() function and use
the encoder channel number to handle the differences.

Remove the then unnecessary 'reset_cap_flags' member and just call s626_reset_cap_flags()
directly.
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 92249e1f
...@@ -114,9 +114,6 @@ struct s626_enc_info { ...@@ -114,9 +114,6 @@ struct s626_enc_info {
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,
uint16_t disable_int_src); uint16_t disable_int_src);
/* Reset event capture flags. */
void (*reset_cap_flags)(struct comedi_device *dev,
const struct s626_enc_info *k);
uint16_t my_event_bits[4]; /* bit translations for IntSrc -->RDMISC2 */ uint16_t my_event_bits[4]; /* bit translations for IntSrc -->RDMISC2 */
}; };
...@@ -746,20 +743,18 @@ static void s626_preload(struct comedi_device *dev, ...@@ -746,20 +743,18 @@ static void s626_preload(struct comedi_device *dev,
/* /*
* Reset a counter's index and overflow event capture flags. * Reset a counter's index and overflow event capture flags.
*/ */
static void s626_reset_cap_flags_a(struct comedi_device *dev, static void s626_reset_cap_flags(struct comedi_device *dev,
const struct s626_enc_info *k) const struct s626_enc_info *k)
{ {
s626_debi_replace(dev, S626_LP_CRB(k->chan), ~S626_CRBMSK_INTCTRL, uint16_t set;
(S626_SET_CRB_INTRESETCMD(1) |
S626_SET_CRB_INTRESET_A(1)));
}
static void s626_reset_cap_flags_b(struct comedi_device *dev, set = S626_SET_CRB_INTRESETCMD(1);
const struct s626_enc_info *k) if (k->chan < 3)
{ set |= S626_SET_CRB_INTRESET_A(1);
s626_debi_replace(dev, S626_LP_CRB(k->chan), ~S626_CRBMSK_INTCTRL, else
(S626_SET_CRB_INTRESETCMD(1) | set |= S626_SET_CRB_INTRESET_B(1);
S626_SET_CRB_INTRESET_B(1)));
s626_debi_replace(dev, S626_LP_CRB(k->chan), ~S626_CRBMSK_INTCTRL, set);
} }
/* /*
...@@ -1299,37 +1294,31 @@ static const struct s626_enc_info s626_enc_chan_info[] = { ...@@ -1299,37 +1294,31 @@ static const struct s626_enc_info s626_enc_chan_info[] = {
.chan = 0, .chan = 0,
.get_mode = s626_get_mode_a, .get_mode = s626_get_mode_a,
.set_mode = s626_set_mode_a, .set_mode = s626_set_mode_a,
.reset_cap_flags = s626_reset_cap_flags_a,
.my_event_bits = S626_EVBITS(0), .my_event_bits = S626_EVBITS(0),
}, { }, {
.chan = 1, .chan = 1,
.get_mode = s626_get_mode_a, .get_mode = s626_get_mode_a,
.set_mode = s626_set_mode_a, .set_mode = s626_set_mode_a,
.reset_cap_flags = s626_reset_cap_flags_a,
.my_event_bits = S626_EVBITS(1), .my_event_bits = S626_EVBITS(1),
}, { }, {
.chan = 2, .chan = 2,
.get_mode = s626_get_mode_a, .get_mode = s626_get_mode_a,
.set_mode = s626_set_mode_a, .set_mode = s626_set_mode_a,
.reset_cap_flags = s626_reset_cap_flags_a,
.my_event_bits = S626_EVBITS(2), .my_event_bits = S626_EVBITS(2),
}, { }, {
.chan = 3, .chan = 3,
.get_mode = s626_get_mode_b, .get_mode = s626_get_mode_b,
.set_mode = s626_set_mode_b, .set_mode = s626_set_mode_b,
.reset_cap_flags = s626_reset_cap_flags_b,
.my_event_bits = S626_EVBITS(3), .my_event_bits = S626_EVBITS(3),
}, { }, {
.chan = 4, .chan = 4,
.get_mode = s626_get_mode_b, .get_mode = s626_get_mode_b,
.set_mode = s626_set_mode_b, .set_mode = s626_set_mode_b,
.reset_cap_flags = s626_reset_cap_flags_b,
.my_event_bits = S626_EVBITS(4), .my_event_bits = S626_EVBITS(4),
}, { }, {
.chan = 5, .chan = 5,
.get_mode = s626_get_mode_b, .get_mode = s626_get_mode_b,
.set_mode = s626_set_mode_b, .set_mode = s626_set_mode_b,
.reset_cap_flags = s626_reset_cap_flags_b,
.my_event_bits = S626_EVBITS(5), .my_event_bits = S626_EVBITS(5),
}, },
}; };
...@@ -1474,31 +1463,31 @@ static void s626_check_counter_interrupts(struct comedi_device *dev) ...@@ -1474,31 +1463,31 @@ static void s626_check_counter_interrupts(struct comedi_device *dev)
k = &s626_enc_chan_info[0]; k = &s626_enc_chan_info[0];
/* clear interrupt capture flag */ /* clear interrupt capture flag */
k->reset_cap_flags(dev, k); s626_reset_cap_flags(dev, k);
} }
if (irqbit & S626_IRQ_COINT2A) { if (irqbit & S626_IRQ_COINT2A) {
k = &s626_enc_chan_info[1]; k = &s626_enc_chan_info[1];
/* clear interrupt capture flag */ /* clear interrupt capture flag */
k->reset_cap_flags(dev, k); s626_reset_cap_flags(dev, k);
} }
if (irqbit & S626_IRQ_COINT3A) { if (irqbit & S626_IRQ_COINT3A) {
k = &s626_enc_chan_info[2]; k = &s626_enc_chan_info[2];
/* clear interrupt capture flag */ /* clear interrupt capture flag */
k->reset_cap_flags(dev, k); s626_reset_cap_flags(dev, k);
} }
if (irqbit & S626_IRQ_COINT1B) { if (irqbit & S626_IRQ_COINT1B) {
k = &s626_enc_chan_info[3]; k = &s626_enc_chan_info[3];
/* clear interrupt capture flag */ /* clear interrupt capture flag */
k->reset_cap_flags(dev, k); s626_reset_cap_flags(dev, k);
} }
if (irqbit & S626_IRQ_COINT2B) { if (irqbit & S626_IRQ_COINT2B) {
k = &s626_enc_chan_info[4]; k = &s626_enc_chan_info[4];
/* clear interrupt capture flag */ /* clear interrupt capture flag */
k->reset_cap_flags(dev, k); s626_reset_cap_flags(dev, k);
if (devpriv->ai_convert_count > 0) { if (devpriv->ai_convert_count > 0) {
devpriv->ai_convert_count--; devpriv->ai_convert_count--;
...@@ -1516,7 +1505,7 @@ static void s626_check_counter_interrupts(struct comedi_device *dev) ...@@ -1516,7 +1505,7 @@ static void s626_check_counter_interrupts(struct comedi_device *dev)
k = &s626_enc_chan_info[5]; k = &s626_enc_chan_info[5];
/* clear interrupt capture flag */ /* clear interrupt capture flag */
k->reset_cap_flags(dev, k); s626_reset_cap_flags(dev, k);
if (cmd->scan_begin_src == TRIG_TIMER) { if (cmd->scan_begin_src == TRIG_TIMER) {
/* Trigger ADC scan loop start */ /* Trigger ADC scan loop start */
...@@ -2564,7 +2553,7 @@ static void s626_counters_init(struct comedi_device *dev) ...@@ -2564,7 +2553,7 @@ static void s626_counters_init(struct comedi_device *dev)
k = &s626_enc_chan_info[chan]; k = &s626_enc_chan_info[chan];
k->set_mode(dev, k, setup, true); k->set_mode(dev, k, setup, true);
s626_set_int_src(dev, k, 0); s626_set_int_src(dev, k, 0);
k->reset_cap_flags(dev, k); s626_reset_cap_flags(dev, k);
s626_set_enable(dev, k, S626_CLKENAB_ALWAYS); s626_set_enable(dev, k, S626_CLKENAB_ALWAYS);
} }
} }
......
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