From: H Hartley Sweeten Date: Fri, 1 May 2015 21:58:43 +0000 (-0700) Subject: staging: comedi: ni_stc.h: tidy up NI_M_PFI_OUT_SEL_REG bits X-Git-Tag: v4.2-rc1~88^2~743 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=43e9d883f02a57fe989ebd568e2508f7f4da25ef;p=karo-tx-linux.git staging: comedi: ni_stc.h: tidy up NI_M_PFI_OUT_SEL_REG bits Rename the CamelCase and convert the inline helper functions that set/get the bits in this register to 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 af095e621e9f..740a92c4b98f 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4367,7 +4367,7 @@ static unsigned ni_m_series_get_pfi_routing(struct comedi_device *dev, struct ni_private *devpriv = dev->private; const unsigned array_offset = chan / 3; - return MSeries_PFI_Output_Select_Source(chan, + return NI_M_PFI_OUT_SEL_TO_SRC(chan, devpriv->pfi_output_select_reg[array_offset]); } @@ -4381,8 +4381,8 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev, if ((source & 0x1f) != source) return -EINVAL; - val &= ~MSeries_PFI_Output_Select_Mask(chan); - val |= MSeries_PFI_Output_Select_Bits(chan, source); + val &= ~NI_M_PFI_OUT_SEL_MASK(chan); + val |= NI_M_PFI_OUT_SEL(chan, source); ni_writew(dev, val, NI_M_PFI_OUT_SEL_REG(index)); devpriv->pfi_output_select_reg[index] = val; diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 33ed998890a0..be9efdc18693 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1005,6 +1005,10 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_PLL_STATUS_REG 0x1c8 #define NI_M_PLL_STATUS_LOCKED BIT(0) #define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2)) +#define NI_M_PFI_CHAN(_c) (((_c) % 3) * 5) +#define NI_M_PFI_OUT_SEL(_c, _s) (((_s) & 0x1f) << NI_M_PFI_CHAN(_c)) +#define NI_M_PFI_OUT_SEL_MASK(_c) (0x1f << NI_M_PFI_CHAN(_c)) +#define NI_M_PFI_OUT_SEL_TO_SRC(_c, _b) (((_b) >> NI_M_PFI_CHAN(_c)) & 0x1f) #define NI_M_PFI_DI_REG 0x1dc #define NI_M_PFI_DO_REG 0x1de #define NI_M_CFG_BYPASS_FIFO_REG 0x218 @@ -1041,24 +1045,6 @@ static const struct comedi_lrange range_ni_E_ao_ext; #define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x)) #define NI_M_AO_REF_ATTENUATION_X5 BIT(0) -static inline unsigned MSeries_PFI_Output_Select_Mask(unsigned channel) -{ - return 0x1f << (channel % 3) * 5; -}; - -static inline unsigned MSeries_PFI_Output_Select_Bits(unsigned channel, - unsigned source) -{ - return (source & 0x1f) << ((channel % 3) * 5); -}; - -/* inverse to MSeries_PFI_Output_Select_Bits */ -static inline unsigned MSeries_PFI_Output_Select_Source(unsigned channel, - unsigned bits) -{ - return (bits >> ((channel % 3) * 5)) & 0x1f; -}; - static inline unsigned MSeries_PFI_Filter_Select_Mask(unsigned channel) { return 0x3 << (channel * 2);