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

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: 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 cc679f97
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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;

+4 −18
Original line number Diff line number Diff line
@@ -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);