From: H Hartley Sweeten Date: Fri, 1 May 2015 22:00:03 +0000 (-0700) Subject: staging: comedi: ni_stc.h: tidy up AI_AO_Select register and bits X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a4b7ef9d8eae56f0355d0ee2a762639901d7bef4;p=linux-beck.git staging: comedi: ni_stc.h: tidy up AI_AO_Select register and bits Rename the CamelCase and convert the enum into macros. Tidy up the driver code to use the new macros. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 2e1fde3d843d..7dfa38268bdc 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -546,7 +546,7 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, devpriv->io_bidirection_pin_reg |= bit_values & bit_mask; ni_stc_writew(dev, devpriv->io_bidirection_pin_reg, reg); break; - case AI_AO_Select: + case NI_E_DMA_AI_AO_SEL_REG: devpriv->ai_ao_select_reg &= ~bit_mask; devpriv->ai_ao_select_reg |= bit_values & bit_mask; ni_writeb(dev, devpriv->ai_ao_select_reg, reg); @@ -571,29 +571,25 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg, /* negative channel means no channel */ static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel) { - unsigned bitfield; + unsigned bits = 0; if (channel >= 0) - bitfield = - (ni_stc_dma_channel_select_bitfield(channel) << - AI_DMA_Select_Shift) & AI_DMA_Select_Mask; - else - bitfield = 0; - ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield); + bits = ni_stc_dma_channel_select_bitfield(channel); + + ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, + NI_E_DMA_AI_SEL_MASK, NI_E_DMA_AI_SEL(bits)); } /* negative channel means no channel */ static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel) { - unsigned bitfield; + unsigned bits = 0; if (channel >= 0) - bitfield = - (ni_stc_dma_channel_select_bitfield(channel) << - AO_DMA_Select_Shift) & AO_DMA_Select_Mask; - else - bitfield = 0; - ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield); + bits = ni_stc_dma_channel_select_bitfield(channel); + + ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG, + NI_E_DMA_AO_SEL_MASK, NI_E_DMA_AO_SEL(bits)); } /* negative mite_channel means no channel */ @@ -5373,7 +5369,7 @@ static int ni_E_init(struct comedi_device *dev, } /* DMA setup */ - ni_writeb(dev, devpriv->ai_ao_select_reg, AI_AO_Select); + 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); if (devpriv->is_6xxx) { diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 9ce4c5639923..2db29a14b2ec 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -571,6 +571,12 @@ #define NI_E_STATUS_AI_FIFO_LOWER_NE BIT(3) #define NI_E_STATUS_PROMOUT BIT(0) +#define NI_E_DMA_AI_AO_SEL_REG 0x09 /* w8 */ +#define NI_E_DMA_AI_SEL(x) (((x) & 0xf) << 0) +#define NI_E_DMA_AI_SEL_MASK NI_E_DMA_AI_SEL(0xf) +#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_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) @@ -582,13 +588,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 AI_AO_Select 0x09 -enum AI_AO_Select_Bits { - AI_DMA_Select_Shift = 0, - AI_DMA_Select_Mask = 0xf, - AO_DMA_Select_Shift = 4, - AO_DMA_Select_Mask = 0xf << AO_DMA_Select_Shift -}; #define G0_G1_Select 0x0b static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel) {