Commit 92249e1f authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

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



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

Remove the then unnecessary 'pulse_index' member and just call s626_pulse_index()
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 13f2609d
Loading
Loading
Loading
Loading
+22 −30
Original line number Diff line number Diff line
@@ -110,9 +110,6 @@ struct s626_enc_info {
	/* Return standardized operating mode. */
	uint16_t (*get_mode)(struct comedi_device *dev,
			    const struct s626_enc_info *k);
	/* Generate soft index strobe. */
	void (*pulse_index)(struct comedi_device *dev,
			    const struct s626_enc_info *k);
	/* Program standardized operating mode. */
	void (*set_mode)(struct comedi_device *dev,
			 const struct s626_enc_info *k, uint16_t setup,
@@ -1272,70 +1269,65 @@ static uint16_t s626_get_index_src(struct comedi_device *dev,
/*
 * Generate an index pulse.
 */
static void s626_pulse_index_a(struct comedi_device *dev,
static void s626_pulse_index(struct comedi_device *dev,
			     const struct s626_enc_info *k)
{
	if (k->chan < 3) {
		uint16_t cra;

		cra = s626_debi_read(dev, S626_LP_CRA(k->chan));
	/* Pulse index. */

		/* Pulse index */
		s626_debi_write(dev, S626_LP_CRA(k->chan),
				(cra ^ S626_CRAMSK_INDXPOL_A));
		s626_debi_write(dev, S626_LP_CRA(k->chan), cra);
}

static void s626_pulse_index_b(struct comedi_device *dev,
			       const struct s626_enc_info *k)
{
	} else {
		uint16_t crb;

	crb = s626_debi_read(dev, S626_LP_CRB(k->chan)) & ~S626_CRBMSK_INTCTRL;
	/* Pulse index. */
		crb = s626_debi_read(dev, S626_LP_CRB(k->chan));
		crb &= ~S626_CRBMSK_INTCTRL;

		/* Pulse index */
		s626_debi_write(dev, S626_LP_CRB(k->chan),
				(crb ^ S626_CRBMSK_INDXPOL_B));
		s626_debi_write(dev, S626_LP_CRB(k->chan), crb);
	}
}

static const struct s626_enc_info s626_enc_chan_info[] = {
	{
		.chan			= 0,
		.get_mode		= s626_get_mode_a,
		.pulse_index		= s626_pulse_index_a,
		.set_mode		= s626_set_mode_a,
		.reset_cap_flags	= s626_reset_cap_flags_a,
		.my_event_bits		= S626_EVBITS(0),
	}, {
		.chan			= 1,
		.get_mode		= s626_get_mode_a,
		.pulse_index		= s626_pulse_index_a,
		.set_mode		= s626_set_mode_a,
		.reset_cap_flags	= s626_reset_cap_flags_a,
		.my_event_bits		= S626_EVBITS(1),
	}, {
		.chan			= 2,
		.get_mode		= s626_get_mode_a,
		.pulse_index		= s626_pulse_index_a,
		.set_mode		= s626_set_mode_a,
		.reset_cap_flags	= s626_reset_cap_flags_a,
		.my_event_bits		= S626_EVBITS(2),
	}, {
		.chan			= 3,
		.get_mode		= s626_get_mode_b,
		.pulse_index		= s626_pulse_index_b,
		.set_mode		= s626_set_mode_b,
		.reset_cap_flags	= s626_reset_cap_flags_b,
		.my_event_bits		= S626_EVBITS(3),
	}, {
		.chan			= 4,
		.get_mode		= s626_get_mode_b,
		.pulse_index		= s626_pulse_index_b,
		.set_mode		= s626_set_mode_b,
		.reset_cap_flags	= s626_reset_cap_flags_b,
		.my_event_bits		= S626_EVBITS(4),
	}, {
		.chan			= 5,
		.get_mode		= s626_get_mode_b,
		.pulse_index		= s626_pulse_index_b,
		.set_mode		= s626_set_mode_b,
		.reset_cap_flags	= s626_reset_cap_flags_b,
		.my_event_bits		= S626_EVBITS(5),
@@ -2088,7 +2080,7 @@ static void s626_timer_load(struct comedi_device *dev,
	 * into the counter
	 */
	s626_set_load_trig(dev, k, 0);
	k->pulse_index(dev, k);
	s626_pulse_index(dev, k);

	/* set reload on counter overflow */
	s626_set_load_trig(dev, k, 1);
@@ -2478,7 +2470,7 @@ static int s626_enc_insn_config(struct comedi_device *dev,

	k->set_mode(dev, k, setup, true);
	s626_preload(dev, k, data[0]);
	k->pulse_index(dev, k);
	s626_pulse_index(dev, k);
	s626_set_latch_source(dev, k, value_latchsrc);
	s626_set_enable(dev, k, (enab != 0));

@@ -2514,7 +2506,7 @@ static int s626_enc_insn_write(struct comedi_device *dev,
	 * into the counter
	 */
	s626_set_load_trig(dev, k, 0);
	k->pulse_index(dev, k);
	s626_pulse_index(dev, k);
	s626_set_load_trig(dev, k, 2);

	return 1;