Commit 4bb40217 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman
Browse files

staging: comedi: amplc_dio200: remove 'has_clk_gat_sce' from subdevice



The `has_clk_gat_sce` member of `struct dio200_subdev_8254` indicates
whether the board has clock and gate source selection registers.  The
same information can be obtained from read-only board layout data so
doesn't need to be set per '8254' counter subdevice.  Eliminate the
member and use the read-only data instead.  The last parameter of
`dio200_subdev_8254_init()` is used to initialize this member, so remove
that parameter as well.

Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a56a8a3c
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -425,7 +425,6 @@ struct dio200_subdev_8254 {
	unsigned long clk_sce_iobase;	/* CLK_SCE base address */
	unsigned long gat_sce_iobase;	/* GAT_SCE base address */
	int which;		/* Bit 5 of CLK_SCE or GAT_SCE */
	int has_clk_gat_sce;
	unsigned clock_src[3];	/* Current clock sources */
	unsigned gate_src[3];	/* Current gate sources */
	spinlock_t spinlock;
@@ -970,10 +969,11 @@ dio200_subdev_8254_set_gate_src(struct comedi_device *dev,
				unsigned int counter_number,
				unsigned int gate_src)
{
	const struct dio200_layout *layout = dio200_dev_layout(dev);
	struct dio200_subdev_8254 *subpriv = s->private;
	unsigned char byte;

	if (!subpriv->has_clk_gat_sce)
	if (!layout->has_clk_gat_sce)
		return -1;
	if (counter_number > 2)
		return -1;
@@ -995,9 +995,10 @@ dio200_subdev_8254_get_gate_src(struct comedi_device *dev,
				struct comedi_subdevice *s,
				unsigned int counter_number)
{
	const struct dio200_layout *layout = dio200_dev_layout(dev);
	struct dio200_subdev_8254 *subpriv = s->private;

	if (!subpriv->has_clk_gat_sce)
	if (!layout->has_clk_gat_sce)
		return -1;
	if (counter_number > 2)
		return -1;
@@ -1014,10 +1015,11 @@ dio200_subdev_8254_set_clock_src(struct comedi_device *dev,
				 unsigned int counter_number,
				 unsigned int clock_src)
{
	const struct dio200_layout *layout = dio200_dev_layout(dev);
	struct dio200_subdev_8254 *subpriv = s->private;
	unsigned char byte;

	if (!subpriv->has_clk_gat_sce)
	if (!layout->has_clk_gat_sce)
		return -1;
	if (counter_number > 2)
		return -1;
@@ -1040,10 +1042,11 @@ dio200_subdev_8254_get_clock_src(struct comedi_device *dev,
				 unsigned int counter_number,
				 unsigned int *period_ns)
{
	const struct dio200_layout *layout = dio200_dev_layout(dev);
	struct dio200_subdev_8254 *subpriv = s->private;
	unsigned clock_src;

	if (!subpriv->has_clk_gat_sce)
	if (!layout->has_clk_gat_sce)
		return -1;
	if (counter_number > 2)
		return -1;
@@ -1117,9 +1120,9 @@ dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s,
 */
static int
dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
			unsigned long iobase, unsigned offset,
			int has_clk_gat_sce)
			unsigned long iobase, unsigned offset)
{
	const struct dio200_layout *layout = dio200_dev_layout(dev);
	struct dio200_subdev_8254 *subpriv;
	unsigned int chan;

@@ -1140,8 +1143,7 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,

	spin_lock_init(&subpriv->spinlock);
	subpriv->iobase = offset + iobase;
	subpriv->has_clk_gat_sce = has_clk_gat_sce;
	if (has_clk_gat_sce) {
	if (layout->has_clk_gat_sce) {
		/* Derive CLK_SCE and GAT_SCE register offsets from
		 * 8254 offset. */
		subpriv->clk_sce_iobase =
@@ -1155,7 +1157,7 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
	for (chan = 0; chan < 3; chan++) {
		i8254_set_mode(subpriv->iobase, 0, chan,
			       I8254_MODE0 | I8254_BINARY);
		if (subpriv->has_clk_gat_sce) {
		if (layout->has_clk_gat_sce) {
			/* Gate source 0 is VCC (logic 1). */
			dio200_subdev_8254_set_gate_src(dev, s, chan, 0);
			/* Clock source 0 is the dedicated clock input. */
@@ -1227,8 +1229,7 @@ static int dio200_common_attach(struct comedi_device *dev, unsigned long iobase,
		case sd_8254:
			/* counter subdevice (8254) */
			ret = dio200_subdev_8254_init(dev, s, iobase,
						      layout->sdinfo[n],
						      layout->has_clk_gat_sce);
						      layout->sdinfo[n]);
			if (ret < 0)
				return ret;
			break;