aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ti_usb_3410_5052.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2008-05-30 11:49:51 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-10 09:49:34 -0400
commit5f24e2d6b40f0c74ce5bfaddfdb89f9bfae4b594 (patch)
tree2e5491ba6ddf2d927f6fbc2dc43a85ccef8ccf48 /drivers/usb/serial/ti_usb_3410_5052.c
parentb8e24bfabb03527d1c876fcaf24cccb05e1cbc65 (diff)
ti_usb_3410_5052: use request_firmware()
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/usb/serial/ti_usb_3410_5052.c')
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index a1c8aef01417..a26a629dfc4f 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -84,11 +84,9 @@
84#include <asm/uaccess.h> 84#include <asm/uaccess.h>
85#include <linux/usb.h> 85#include <linux/usb.h>
86#include <linux/usb/serial.h> 86#include <linux/usb/serial.h>
87#include <linux/firmware.h>
87 88
88#include "ti_usb_3410_5052.h" 89#include "ti_usb_3410_5052.h"
89#include "ti_fw_3410.h" /* firmware image for 3410 */
90#include "ti_fw_5052.h" /* firmware image for 5052 */
91
92 90
93/* Defines */ 91/* Defines */
94 92
@@ -194,8 +192,8 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
194static int ti_write_byte(struct ti_device *tdev, unsigned long addr, 192static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
195 __u8 mask, __u8 byte); 193 __u8 mask, __u8 byte);
196 194
197static int ti_download_firmware(struct ti_device *tdev, 195static int ti_download_firmware(struct ti_device *tdev, char *fw_name);
198 unsigned char *firmware, unsigned int firmware_size); 196
199 197
200/* circular buffer */ 198/* circular buffer */
201static struct circ_buf *ti_buf_alloc(void); 199static struct circ_buf *ti_buf_alloc(void);
@@ -320,6 +318,9 @@ MODULE_DESCRIPTION(TI_DRIVER_DESC);
320MODULE_VERSION(TI_DRIVER_VERSION); 318MODULE_VERSION(TI_DRIVER_VERSION);
321MODULE_LICENSE("GPL"); 319MODULE_LICENSE("GPL");
322 320
321MODULE_FIRMWARE("ti_3410.fw");
322MODULE_FIRMWARE("ti_5052.fw");
323
323module_param(debug, bool, S_IRUGO | S_IWUSR); 324module_param(debug, bool, S_IRUGO | S_IWUSR);
324MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); 325MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
325 326
@@ -431,11 +432,9 @@ static int ti_startup(struct usb_serial *serial)
431 if (dev->descriptor.bNumConfigurations == 1) { 432 if (dev->descriptor.bNumConfigurations == 1) {
432 433
433 if (tdev->td_is_3410) 434 if (tdev->td_is_3410)
434 status = ti_download_firmware(tdev, ti_fw_3410, 435 status = ti_download_firmware(tdev, "ti_3410.fw");
435 sizeof(ti_fw_3410));
436 else 436 else
437 status = ti_download_firmware(tdev, ti_fw_5052, 437 status = ti_download_firmware(tdev, "ti_5052.fw");
438 sizeof(ti_fw_5052));
439 if (status) 438 if (status)
440 goto free_tdev; 439 goto free_tdev;
441 440
@@ -1658,8 +1657,9 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
1658 1657
1659 1658
1660static int ti_download_firmware(struct ti_device *tdev, 1659static int ti_download_firmware(struct ti_device *tdev,
1661 unsigned char *firmware, unsigned int firmware_size) 1660 char *fw_name)
1662{ 1661{
1662 const struct firmware *fw;
1663 int status = 0; 1663 int status = 0;
1664 int buffer_size; 1664 int buffer_size;
1665 int pos; 1665 int pos;
@@ -1672,16 +1672,29 @@ static int ti_download_firmware(struct ti_device *tdev,
1672 unsigned int pipe = usb_sndbulkpipe(dev, 1672 unsigned int pipe = usb_sndbulkpipe(dev,
1673 tdev->td_serial->port[0]->bulk_out_endpointAddress); 1673 tdev->td_serial->port[0]->bulk_out_endpointAddress);
1674 1674
1675
1676 buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header); 1675 buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header);
1676
1677 if (request_firmware(&fw, fw_name, &dev->dev)) {
1678 dev_err(&dev->dev, "%s - failed to load firmware \"%s\"\n",
1679 __func__, fw_name);
1680 return -ENOENT;
1681 }
1682 if (fw->size > buffer_size) {
1683 dev_err(&dev->dev, "%s - firmware \"%s\" is too large\n",
1684 __func__, fw_name);
1685 release_firmware(fw);
1686 return -EINVAL;
1687 }
1688
1677 buffer = kmalloc(buffer_size, GFP_KERNEL); 1689 buffer = kmalloc(buffer_size, GFP_KERNEL);
1678 if (!buffer) { 1690 if (!buffer) {
1679 dev_err(&dev->dev, "%s - out of memory\n", __func__); 1691 dev_err(&dev->dev, "%s - out of memory\n", __func__);
1692 release_firmware(fw);
1680 return -ENOMEM; 1693 return -ENOMEM;
1681 } 1694 }
1682 1695
1683 memcpy(buffer, firmware, firmware_size); 1696 memcpy(buffer, fw->data, fw->size);
1684 memset(buffer+firmware_size, 0xff, buffer_size-firmware_size); 1697 memset(buffer+fw->size, 0xff, buffer_size-fw->size);
1685 1698
1686 for(pos = sizeof(struct ti_firmware_header); pos < buffer_size; pos++) 1699 for(pos = sizeof(struct ti_firmware_header); pos < buffer_size; pos++)
1687 cs = (__u8)(cs + buffer[pos]); 1700 cs = (__u8)(cs + buffer[pos]);
@@ -1699,6 +1712,7 @@ static int ti_download_firmware(struct ti_device *tdev,
1699 } 1712 }
1700 1713
1701 kfree(buffer); 1714 kfree(buffer);
1715 release_firmware(fw);
1702 1716
1703 if (status) { 1717 if (status) {
1704 dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status); 1718 dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status);