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);
* @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;
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);
}
}
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;
result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
DAQBOARD2000_FIRMWARE,
- initialize_daqboard2000);
+ initialize_daqboard2000, 0);
if (result < 0)
return result;
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:
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)
*
* comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
* "comedi/jr3_offsets_table",
- * jr3_download_firmware);
+ * jr3_download_firmware, 1);
*/
/*
}
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;
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;
}
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/sched.h>
-#include <linux/firmware.h>
#include "../comedidev.h"
return 0;
}
-static int pci_6534_load_fpga(struct comedi_device *dev, int fpga_index,
- const u8 *data, size_t data_len)
+static int pci_6534_load_fpga(struct comedi_device *dev,
+ const u8 *data, size_t data_len,
+ unsigned long context)
{
struct nidio96_private *devpriv = dev->private;
static const int timeout = 1000;
+ int fpga_index = context;
int i;
size_t j;
static int pci_6534_reset_fpga(struct comedi_device *dev, int fpga_index)
{
- return pci_6534_load_fpga(dev, fpga_index, NULL, 0);
+ return pci_6534_load_fpga(dev, NULL, 0, fpga_index);
}
static int pci_6534_reset_fpgas(struct comedi_device *dev)
static int pci_6534_upload_firmware(struct comedi_device *dev)
{
struct nidio96_private *devpriv = dev->private;
- int ret;
- const struct firmware *fw;
static const char *const fw_file[3] = {
FW_PCI_6534_SCARAB_DI, /* loaded into scarab A for DI */
FW_PCI_6534_SCARAB_DO, /* loaded into scarab B for DO */
FW_PCI_6534_MAIN, /* loaded into main FPGA */
};
+ int ret;
int n;
ret = pci_6534_reset_fpgas(dev);
return ret;
/* load main FPGA first, then the two scarabs */
for (n = 2; n >= 0; n--) {
- ret = request_firmware(&fw, fw_file[n],
- &devpriv->mite->pcidev->dev);
- if (ret == 0) {
- ret = pci_6534_load_fpga(dev, n, fw->data, fw->size);
- if (ret == 0 && n == 2)
- pci_6534_init_main_fpga(dev);
- release_firmware(fw);
- }
+ ret = comedi_load_firmware(dev, &devpriv->mite->pcidev->dev,
+ fw_file[n],
+ pci_6534_load_fpga, n);
+ if (ret == 0 && n == 2)
+ pci_6534_init_main_fpga(dev);
if (ret < 0)
break;
}