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));
+
int __comedi_request_region(struct comedi_device *,
unsigned long start, unsigned long len);
int comedi_request_region(struct comedi_device *,
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/interrupt.h>
+#include <linux/firmware.h>
#include "comedidev.h"
#include "comedi_internal.h"
}
/**
+ * comedi_load_firmware() - Request and load firmware for a device.
+ * @dev: comedi_device struct
+ * @hw_device: device struct for the comedi_device
+ * @name: the name of the firmware image
+ * @cb: callback to the upload the firmware image
+ */
+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 struct firmware *fw;
+ int ret;
+
+ if (!cb)
+ return -EINVAL;
+
+ ret = request_firmware(&fw, name, device);
+ if (ret == 0) {
+ ret = cb(dev, fw->data, fw->size);
+ release_firmware(fw);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(comedi_load_firmware);
+
+/**
* __comedi_request_region() - Request an I/O reqion for a legacy driver.
* @dev: comedi_device struct
* @start: base address of the I/O reqion
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/ctype.h>
-#include <linux/firmware.h>
#include <linux/jiffies.h>
#include <linux/slab.h>
#include <linux/timer.h>
int retries;
};
-/* Hotplug firmware loading stuff */
-static int comedi_load_firmware(struct comedi_device *dev, const char *name,
- int (*cb)(struct comedi_device *dev,
- const u8 *data, size_t size))
-{
- struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- const struct firmware *fw;
- char *firmware_path;
- int ret;
-
- if (!cb)
- return -EINVAL;
-
- firmware_path = kasprintf(GFP_KERNEL, "comedi/%s", name);
- if (!firmware_path)
- return -ENOMEM;
-
- ret = request_firmware(&fw, firmware_path, &pcidev->dev);
- if (ret == 0) {
- ret = cb(dev, fw->data, fw->size);
- release_firmware(fw);
- }
- kfree(firmware_path);
-
- return ret;
-}
-
static struct poll_delay_t poll_delay_min_max(int min, int max)
{
struct poll_delay_t result;
/* Reset DSP card */
writel(0, &devpriv->iobase->channel[0].reset);
- result = comedi_load_firmware(dev, "jr3pci.idm", jr3_download_firmware);
+ result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
+ "comedi/jr3pci.idm",
+ jr3_download_firmware);
dev_dbg(dev->class_dev, "Firmare load %d\n", result);
if (result < 0)
* format:
* model serial Fx Fy Fz Mx My Mz\n
*
- * comedi_load_firmware(dev, "jr3_offsets_table",
+ * comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev,
+ * "comedi/jr3_offsets_table",
* jr3_download_firmware);
*/