Skip to content

Commit

Permalink
staging: comedi: s626: replace S626_MULT_X? values
Browse files Browse the repository at this point in the history
Replace the use of the `S626_MULT_X1`, `S626_MULT_X2` and `S626_MULT_X4`
clock multiplier values with the equivalent `S626_CLKMULT_1X`,
`S626_CLKMULT_2X` and `S626_CLKMULT_4X` values to avoid duplication.
Replace the use of `S626_MULT_X0` with a new macro
`S626_CLKMULT_SPECIAL` (this is treated specially by the
'ClkMultA'/'ClkMultB' field of the 'CRA'/'CRB' register).  Remove the
now unused `S626_MULT_X?` macros.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Oct 29, 2013
1 parent 43ce748 commit 7a1046e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 25 deletions.
28 changes: 14 additions & 14 deletions drivers/staging/comedi/drivers/s626.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,16 +731,16 @@ static uint16_t s626_get_mode_a(struct comedi_device *dev,
/* Set ClkPol to indicate count direction (CntSrcA<0>). */
clkpol = cntsrc & 1;
/* ClkMult must be 1x in Timer mode. */
clkmult = S626_MULT_X1;
clkmult = S626_CLKMULT_1X;
} else {
/* Counter mode (CntSrcA<1> == 0): */
encmode = S626_ENCMODE_COUNTER;
/* Pass through ClkPol. */
clkpol = S626_GET_CRA_CLKPOL_A(cra);
/* Force ClkMult to 1x if not legal, else pass through. */
clkmult = S626_GET_CRA_CLKMULT_A(cra);
if (clkmult == S626_MULT_X0)
clkmult = S626_MULT_X1;
if (clkmult == S626_CLKMULT_SPECIAL)
clkmult = S626_CLKMULT_1X;
}
setup |= S626_SET_STD_ENCMODE(encmode) | S626_SET_STD_CLKMULT(clkmult) |
S626_SET_STD_CLKPOL(clkpol);
Expand Down Expand Up @@ -781,18 +781,18 @@ static uint16_t s626_get_mode_b(struct comedi_device *dev,
/* Adjust mode-dependent parameters. */
cntsrc = S626_GET_CRA_CNTSRC_B(cra);
clkmult = S626_GET_CRB_CLKMULT_B(crb);
if (clkmult == S626_MULT_X0) {
/* Extender mode (ClkMultB == S626_MULT_X0): */
if (clkmult == S626_CLKMULT_SPECIAL) {
/* Extender mode (ClkMultB == S626_CLKMULT_SPECIAL): */
encmode = S626_ENCMODE_EXTENDER;
/* Indicate multiplier is 1x. */
clkmult = S626_MULT_X1;
clkmult = S626_CLKMULT_1X;
/* Set ClkPol equal to Timer count direction (CntSrcB<0>). */
clkpol = cntsrc & 1;
} else if (cntsrc & S626_CNTSRC_SYSCLK) {
/* Timer mode (CntSrcB<1> == 1): */
encmode = S626_ENCMODE_TIMER;
/* Indicate multiplier is 1x. */
clkmult = S626_MULT_X1;
clkmult = S626_CLKMULT_1X;
/* Set ClkPol equal to Timer count direction (CntSrcB<0>). */
clkpol = cntsrc & 1;
} else {
Expand Down Expand Up @@ -853,16 +853,16 @@ static void s626_set_mode_a(struct comedi_device *dev,
/* ClkPolA behaves as always-on clock enable. */
clkpol = 1;
/* ClkMult must be 1x. */
clkmult = S626_MULT_X1;
clkmult = S626_CLKMULT_1X;
break;
default: /* Counter Mode: */
/* Select ENC_C and ENC_D as clock/direction inputs. */
cntsrc = S626_CNTSRC_ENCODER;
/* Clock polarity is passed through. */
/* Force multiplier to x1 if not legal, else pass through. */
clkmult = S626_GET_STD_CLKMULT(setup);
if (clkmult == S626_MULT_X0)
clkmult = S626_MULT_X1;
if (clkmult == S626_CLKMULT_SPECIAL)
clkmult = S626_CLKMULT_1X;
break;
}
cra |= S626_SET_CRA_CNTSRC_A(cntsrc) | S626_SET_CRA_CLKPOL_A(clkpol) |
Expand Down Expand Up @@ -927,7 +927,7 @@ static void s626_set_mode_b(struct comedi_device *dev,
/* ClkPolB behaves as always-on clock enable. */
clkpol = 1;
/* ClkMultB must be 1x. */
clkmult = S626_MULT_X1;
clkmult = S626_CLKMULT_1X;
break;
case S626_ENCMODE_EXTENDER: /* Extender Mode: */
/* CntSrcB source is OverflowA (same as "timer") */
Expand All @@ -937,16 +937,16 @@ static void s626_set_mode_b(struct comedi_device *dev,
/* ClkPolB controls IndexB -- always set to active. */
clkpol = 1;
/* ClkMultB selects OverflowA as the clock source. */
clkmult = S626_MULT_X0;
clkmult = S626_CLKMULT_SPECIAL;
break;
default: /* Counter Mode: */
/* Select ENC_C and ENC_D as clock/direction inputs. */
cntsrc = S626_CNTSRC_ENCODER;
/* ClkPol is passed through. */
/* Force ClkMult to x1 if not legal, otherwise pass through. */
clkmult = S626_GET_STD_CLKMULT(setup);
if (clkmult == S626_MULT_X0)
clkmult = S626_MULT_X1;
if (clkmult == S626_CLKMULT_SPECIAL)
clkmult = S626_CLKMULT_1X;
break;
}
cra |= S626_SET_CRA_CNTSRC_B(cntsrc);
Expand Down
12 changes: 1 addition & 11 deletions drivers/staging/comedi/drivers/s626.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,17 +498,7 @@
#define S626_CLKMULT_4X 0 /* 4x clock multiplier. */
#define S626_CLKMULT_2X 1 /* 2x clock multiplier. */
#define S626_CLKMULT_1X 2 /* 1x clock multiplier. */

/* Enumerated counter clock multipliers. */

#define S626_MULT_X0 0x0003 /* Supports no multipliers;
* fixed physical multiplier = 3. */
#define S626_MULT_X1 0x0002 /* Supports multiplier x1;
* fixed physical multiplier = 2. */
#define S626_MULT_X2 0x0001 /* Supports multipliers x1, x2;
* physical multipliers = 1 or 2. */
#define S626_MULT_X4 0x0000 /* Supports multipliers x1, x2, x4;
* physical multipliers = 0, 1 or 2. */
#define S626_CLKMULT_SPECIAL 3 /* Special clock multiplier value. */

/* Sanity-check limits for parameters. */

Expand Down

0 comments on commit 7a1046e

Please sign in to comment.