Commit 5f24e2d6 authored by David Woodhouse's avatar David Woodhouse Committed by David Woodhouse

ti_usb_3410_5052: use request_firmware()

Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent b8e24bfa
This diff is collapsed.
This diff is collapsed.
...@@ -84,11 +84,9 @@ ...@@ -84,11 +84,9 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usb/serial.h> #include <linux/usb/serial.h>
#include <linux/firmware.h>
#include "ti_usb_3410_5052.h" #include "ti_usb_3410_5052.h"
#include "ti_fw_3410.h" /* firmware image for 3410 */
#include "ti_fw_5052.h" /* firmware image for 5052 */
/* Defines */ /* Defines */
...@@ -194,8 +192,8 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command, ...@@ -194,8 +192,8 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
static int ti_write_byte(struct ti_device *tdev, unsigned long addr, static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
__u8 mask, __u8 byte); __u8 mask, __u8 byte);
static int ti_download_firmware(struct ti_device *tdev, static int ti_download_firmware(struct ti_device *tdev, char *fw_name);
unsigned char *firmware, unsigned int firmware_size);
/* circular buffer */ /* circular buffer */
static struct circ_buf *ti_buf_alloc(void); static struct circ_buf *ti_buf_alloc(void);
...@@ -320,6 +318,9 @@ MODULE_DESCRIPTION(TI_DRIVER_DESC); ...@@ -320,6 +318,9 @@ MODULE_DESCRIPTION(TI_DRIVER_DESC);
MODULE_VERSION(TI_DRIVER_VERSION); MODULE_VERSION(TI_DRIVER_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_FIRMWARE("ti_3410.fw");
MODULE_FIRMWARE("ti_5052.fw");
module_param(debug, bool, S_IRUGO | S_IWUSR); module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
...@@ -431,11 +432,9 @@ static int ti_startup(struct usb_serial *serial) ...@@ -431,11 +432,9 @@ static int ti_startup(struct usb_serial *serial)
if (dev->descriptor.bNumConfigurations == 1) { if (dev->descriptor.bNumConfigurations == 1) {
if (tdev->td_is_3410) if (tdev->td_is_3410)
status = ti_download_firmware(tdev, ti_fw_3410, status = ti_download_firmware(tdev, "ti_3410.fw");
sizeof(ti_fw_3410));
else else
status = ti_download_firmware(tdev, ti_fw_5052, status = ti_download_firmware(tdev, "ti_5052.fw");
sizeof(ti_fw_5052));
if (status) if (status)
goto free_tdev; goto free_tdev;
...@@ -1658,8 +1657,9 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr, ...@@ -1658,8 +1657,9 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
static int ti_download_firmware(struct ti_device *tdev, static int ti_download_firmware(struct ti_device *tdev,
unsigned char *firmware, unsigned int firmware_size) char *fw_name)
{ {
const struct firmware *fw;
int status = 0; int status = 0;
int buffer_size; int buffer_size;
int pos; int pos;
...@@ -1672,16 +1672,29 @@ static int ti_download_firmware(struct ti_device *tdev, ...@@ -1672,16 +1672,29 @@ static int ti_download_firmware(struct ti_device *tdev,
unsigned int pipe = usb_sndbulkpipe(dev, unsigned int pipe = usb_sndbulkpipe(dev,
tdev->td_serial->port[0]->bulk_out_endpointAddress); tdev->td_serial->port[0]->bulk_out_endpointAddress);
buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header); buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header);
if (request_firmware(&fw, fw_name, &dev->dev)) {
dev_err(&dev->dev, "%s - failed to load firmware \"%s\"\n",
__func__, fw_name);
return -ENOENT;
}
if (fw->size > buffer_size) {
dev_err(&dev->dev, "%s - firmware \"%s\" is too large\n",
__func__, fw_name);
release_firmware(fw);
return -EINVAL;
}
buffer = kmalloc(buffer_size, GFP_KERNEL); buffer = kmalloc(buffer_size, GFP_KERNEL);
if (!buffer) { if (!buffer) {
dev_err(&dev->dev, "%s - out of memory\n", __func__); dev_err(&dev->dev, "%s - out of memory\n", __func__);
release_firmware(fw);
return -ENOMEM; return -ENOMEM;
} }
memcpy(buffer, firmware, firmware_size); memcpy(buffer, fw->data, fw->size);
memset(buffer+firmware_size, 0xff, buffer_size-firmware_size); memset(buffer+fw->size, 0xff, buffer_size-fw->size);
for(pos = sizeof(struct ti_firmware_header); pos < buffer_size; pos++) for(pos = sizeof(struct ti_firmware_header); pos < buffer_size; pos++)
cs = (__u8)(cs + buffer[pos]); cs = (__u8)(cs + buffer[pos]);
...@@ -1699,6 +1712,7 @@ static int ti_download_firmware(struct ti_device *tdev, ...@@ -1699,6 +1712,7 @@ static int ti_download_firmware(struct ti_device *tdev,
} }
kfree(buffer); kfree(buffer);
release_firmware(fw);
if (status) { if (status) {
dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status);
......
...@@ -53,6 +53,7 @@ fw-shipped- := keyspan/mpr.fw keyspan/usa18x.fw keyspan/usa19.fw \ ...@@ -53,6 +53,7 @@ fw-shipped- := keyspan/mpr.fw keyspan/usa18x.fw keyspan/usa19.fw \
keyspan/usa28.fw keyspan/usa28xa.fw keyspan/usa28xb.fw \ keyspan/usa28.fw keyspan/usa28xa.fw keyspan/usa28xb.fw \
keyspan/usa28x.fw keyspan/usa49w.fw keyspan/usa49wlc.fw keyspan/usa28x.fw keyspan/usa49w.fw keyspan/usa49wlc.fw
endif endif
fw-shipped-$(CONFIG_USB_SERIAL_TI) += ti_3410.fw ti_5052.fw
fw-shipped-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda/keyspan_pda.fw fw-shipped-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda/keyspan_pda.fw
fw-shipped-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda/xircom_pgs.fw fw-shipped-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda/xircom_pgs.fw
......
...@@ -190,3 +190,18 @@ Converted from Intel HEX files, used in our binary representation of ihex. ...@@ -190,3 +190,18 @@ Converted from Intel HEX files, used in our binary representation of ihex.
Original licence information: None Original licence information: None
-------------------------------------------------------------------------- --------------------------------------------------------------------------
Driver: tu_usb_3410_5052 -- USB TI 3410/5052 serial device
File: ti_3410.fw
Info: firmware 9/10/04 FW3410_Special_StartWdogOnStartPort
File: ti_5052.fw
Info: firmware 9/18/04
Licence: Allegedly GPLv2+, but no source visible. Marked:
Copyright (C) 2004 Texas Instruments
Found in hex form in kernel source.
--------------------------------------------------------------------------
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment