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

staging: comedi: ni_pcidio: use comedi_load_firmware()



Use comedi_load_firmware() instead of duplicating the code in a
private function.

This driver loads multiple firmware images to the device. Modify
comedi_load_firmware() to take a 'context' that is passed to the
firmware upload callback function.

Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cb43cc0f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -349,7 +349,9 @@ void comedi_spriv_free(struct comedi_device *, int subdev_num);
int comedi_load_firmware(struct comedi_device *, struct device *,
			 const char *name,
			 int (*cb)(struct comedi_device *,
				   const u8 *data, size_t size));
				   const u8 *data, size_t size,
				   unsigned long context),
			 unsigned long context);

int __comedi_request_region(struct comedi_device *,
			    unsigned long start, unsigned long len);
+5 −2
Original line number Diff line number Diff line
@@ -353,12 +353,15 @@ static void comedi_report_boards(struct comedi_driver *driv)
 * @hw_device: device struct for the comedi_device
 * @name: the name of the firmware image
 * @cb: callback to the upload the firmware image
 * @context: private context from the driver
 */
int comedi_load_firmware(struct comedi_device *dev,
			 struct device *device,
			 const char *name,
			 int (*cb)(struct comedi_device *dev,
				   const u8 *data, size_t size))
				   const u8 *data, size_t size,
				   unsigned long context),
			 unsigned long context)
{
	const struct firmware *fw;
	int ret;
@@ -368,7 +371,7 @@ int comedi_load_firmware(struct comedi_device *dev,

	ret = request_firmware(&fw, name, device);
	if (ret == 0) {
		ret = cb(dev, fw->data, fw->size);
		ret = cb(dev, fw->data, fw->size, context);
		release_firmware(fw);
	}

+3 −2
Original line number Diff line number Diff line
@@ -518,7 +518,8 @@ static int daqboard2000_writeCPLD(struct comedi_device *dev, int data)
}

static int initialize_daqboard2000(struct comedi_device *dev,
				   const u8 *cpld_array, size_t len)
				   const u8 *cpld_array, size_t len,
				   unsigned long context)
{
	struct daqboard2000_private *devpriv = dev->private;
	int result = -EIO;
@@ -704,7 +705,7 @@ static int daqboard2000_auto_attach(struct comedi_device *dev,

	result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
				      DAQBOARD2000_FIRMWARE,
				      initialize_daqboard2000);
				      initialize_daqboard2000, 0);
	if (result < 0)
		return result;

+5 −4
Original line number Diff line number Diff line
@@ -325,8 +325,9 @@ static int read_idm_word(const u8 *data, size_t size, int *pos,
	return result;
}

static int jr3_download_firmware(struct comedi_device *dev, const u8 *data,
				 size_t size)
static int jr3_download_firmware(struct comedi_device *dev,
				 const u8 *data, size_t size,
				 unsigned long context)
{
	/*
	 * IDM file format is:
@@ -733,7 +734,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,

	result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
				      "comedi/jr3pci.idm",
				      jr3_download_firmware);
				      jr3_download_firmware, 0);
	dev_dbg(dev->class_dev, "Firmare load %d\n", result);

	if (result < 0)
@@ -745,7 +746,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
	 *
	 *     comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
	 *                          "comedi/jr3_offsets_table",
	 *                          jr3_download_firmware);
	 *                          jr3_download_firmware, 1);
	 */

	/*
+3 −2
Original line number Diff line number Diff line
@@ -386,7 +386,8 @@ static int me_ao_insn_read(struct comedi_device *dev,
}

static int me2600_xilinx_download(struct comedi_device *dev,
				  const u8 *data, size_t size)
				  const u8 *data, size_t size,
				  unsigned long context)
{
	struct me_private_data *dev_private = dev->private;
	unsigned int value;
@@ -510,7 +511,7 @@ static int me_auto_attach(struct comedi_device *dev,
	if (board->needs_firmware) {
		ret = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
					   ME2600_FIRMWARE,
					   me2600_xilinx_download);
					   me2600_xilinx_download, 0);
		if (ret < 0)
			return ret;
	}
Loading