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

staging: comedi: ni_labpc_common: use subdevice readback for eeprom



Use the comedi_subdevice 'readback' member and the core provided (*insn_read)
to handle the readback of the eeprom subdevice. Remove the then unused
'eeprom_data' member from the private data.

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 c82f0e6b
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -68,8 +68,6 @@ struct labpc_private {
	unsigned int dma_transfer_size;
	/* we are using dma/fifo-half-full/etc. */
	enum transfer_type current_transfer;
	/* stores contents of board's eeprom */
	unsigned int eeprom_data[EEPROM_SIZE];
	/*
	 * function pointers so we can use inb/outb or readb/writeb as
	 * appropriate
+10 −20
Original line number Diff line number Diff line
@@ -1099,8 +1099,6 @@ static int labpc_eeprom_write(struct comedi_device *dev,
		dev_err(dev->class_dev, "eeprom write timed out\n");
		return -ETIME;
	}
	/*  update software copy of eeprom */
	devpriv->eeprom_data[address] = value;

	/*  enable read/write to eeprom */
	devpriv->cmd5 &= ~CMD5_EEPROMCS;
@@ -1202,26 +1200,15 @@ static int labpc_eeprom_insn_write(struct comedi_device *dev,
	 * data would be overwritten anyway.
	 */
	if (insn->n > 0) {
		ret = labpc_eeprom_write(dev, chan, data[insn->n - 1]);
		unsigned int val = data[insn->n - 1];

		ret = labpc_eeprom_write(dev, chan, val);
		if (ret)
			return ret;
	}

	return insn->n;
		s->readback[chan] = val;
	}

static int labpc_eeprom_insn_read(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  struct comedi_insn *insn,
				  unsigned int *data)
{
	struct labpc_private *devpriv = dev->private;
	unsigned int chan = CR_CHAN(insn->chanspec);
	int i;

	for (i = 0; i < insn->n; i++)
		data[i] = devpriv->eeprom_data[chan];

	return insn->n;
}

@@ -1339,11 +1326,14 @@ int labpc_common_attach(struct comedi_device *dev,
		s->subdev_flags	= SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
		s->n_chan	= EEPROM_SIZE;
		s->maxdata	= 0xff;
		s->insn_read	= labpc_eeprom_insn_read;
		s->insn_write	= labpc_eeprom_insn_write;

		ret = comedi_alloc_subdev_readback(s);
		if (ret)
			return ret;

		for (i = 0; i < s->n_chan; i++)
			devpriv->eeprom_data[i] = labpc_eeprom_read(dev, i);
			s->readback[i] = labpc_eeprom_read(dev, i);
	} else {
		s->type		= COMEDI_SUBD_UNUSED;
	}