From 7d6f3aaead3a76e7e12aa2bbfe18d8ed423d1d19 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 May 2015 15:00:04 -0700 Subject: [PATCH] staging: comedi: ni_stc.h: tidy up G0_G1_Select register and bits Rename the CamelCase. Convert the inline helper functions into macros. Tidy up the driver code to use the new macros. For consistency, make the ni_set_gpct_dma_channel() helper follow the same style as the ni_set_ai_dma_channel() and ni_set_ao_dma_channel() helpers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/ni_mio_common.c | 22 +++++++++---------- drivers/staging/comedi/drivers/ni_stc.h | 17 ++++---------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 7dfa38268bdc..cfb5f34b4937 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -551,7 +551,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, devpriv->ai_ao_select_reg |= bit_values & bit_mask; ni_writeb(dev, devpriv->ai_ao_select_reg, reg); break; - case G0_G1_Select: + case NI_E_DMA_G0_G1_SEL_REG: devpriv->g0_g1_select_reg &= ~bit_mask; devpriv->g0_g1_select_reg |= bit_values & bit_mask; ni_writeb(dev, devpriv->g0_g1_select_reg, reg); @@ -592,19 +592,19 @@ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel) NI_E_DMA_AO_SEL_MASK, NI_E_DMA_AO_SEL(bits)); } -/* negative mite_channel means no channel */ +/* negative channel means no channel */ static inline void ni_set_gpct_dma_channel(struct comedi_device *dev, unsigned gpct_index, - int mite_channel) + int channel) { - unsigned bitfield; + unsigned bits = 0; - if (mite_channel >= 0) - bitfield = GPCT_DMA_Select_Bits(gpct_index, mite_channel); - else - bitfield = 0; - ni_set_bitfield(dev, G0_G1_Select, GPCT_DMA_Select_Mask(gpct_index), - bitfield); + if (channel >= 0) + bits = ni_stc_dma_channel_select_bitfield(channel); + + ni_set_bitfield(dev, NI_E_DMA_G0_G1_SEL_REG, + NI_E_DMA_G0_G1_SEL_MASK(gpct_index), + NI_E_DMA_G0_G1_SEL(gpct_index, bits)); } /* negative mite_channel means no channel */ @@ -5370,7 +5370,7 @@ static int ni_E_init(struct comedi_device *dev, /* DMA setup */ ni_writeb(dev, devpriv->ai_ao_select_reg, NI_E_DMA_AI_AO_SEL_REG); - ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select); + ni_writeb(dev, devpriv->g0_g1_select_reg, NI_E_DMA_G0_G1_SEL_REG); if (devpriv->is_6xxx) { ni_writeb(dev, 0, Magic_611x); diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 2db29a14b2ec..e181d914d3e7 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -577,6 +577,10 @@ #define NI_E_DMA_AO_SEL(x) (((x) & 0xf) << 4) #define NI_E_DMA_AO_SEL_MASK NI_E_DMA_AO_SEL(0xf) +#define NI_E_DMA_G0_G1_SEL_REG 0x0b /* w8 */ +#define NI_E_DMA_G0_G1_SEL(_g, _c) (((_c) & 0xf) << ((_g) * 4)) +#define NI_E_DMA_G0_G1_SEL_MASK(_g) NI_E_DMA_G0_G1_SEL((_g), 0xf) + #define NI_E_SERIAL_CMD_REG 0x0d /* w8 */ #define NI_E_SERIAL_CMD_DAC_LD(x) BIT(3 + (x)) #define NI_E_SERIAL_CMD_EEPROM_CS BIT(2) @@ -588,7 +592,6 @@ #define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0) #define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1) -#define G0_G1_Select 0x0b static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) { if (channel < 4) @@ -601,18 +604,6 @@ static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) return 0; } -static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index, - unsigned mite_channel) -{ - return ni_stc_dma_channel_select_bitfield(mite_channel) << (4 * - gpct_index); -} - -static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index) -{ - return 0xf << (4 * gpct_index); -} - #define NI_E_AI_CFG_LO_REG 0x10 /* w16 */ #define NI_E_AI_CFG_LO_LAST_CHAN BIT(15) #define NI_E_AI_CFG_LO_GEN_TRIG BIT(12) -- 2.39.5