Skip to content

Commit 3edbf98

Browse files
dwmw2David Woodhouse
authored andcommitted
keyspan_pda: use request_firmware()
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
1 parent 2971c57 commit 3edbf98

9 files changed

Lines changed: 210 additions & 229 deletions

File tree

‎drivers/usb/serial/keyspan_pda.c‎

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,14 @@
7676
#include <linux/module.h>
7777
#include <linux/spinlock.h>
7878
#include <linux/workqueue.h>
79+
#include <linux/firmware.h>
80+
#include <linux/ihex.h>
7981
#include <asm/uaccess.h>
8082
#include <linux/usb.h>
8183
#include <linux/usb/serial.h>
8284

8385
static int debug;
8486

85-
struct ezusb_hex_record {
86-
__u16 address;
87-
__u8 data_size;
88-
__u8 data[16];
89-
};
90-
9187
/* make a simple define to handle if we are compiling keyspan_pda or xircom support */
9288
#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE)
9389
#define KEYSPAN
@@ -100,14 +96,6 @@ struct ezusb_hex_record {
10096
#undef XIRCOM
10197
#endif
10298

103-
#ifdef KEYSPAN
104-
#include "keyspan_pda_fw.h"
105-
#endif
106-
107-
#ifdef XIRCOM
108-
#include "xircom_pgs_fw.h"
109-
#endif
110-
11199
/*
112100
* Version Information
113101
*/
@@ -722,38 +710,47 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
722710
static int keyspan_pda_fake_startup (struct usb_serial *serial)
723711
{
724712
int response;
725-
const struct ezusb_hex_record *record = NULL;
713+
const char *fw_name;
714+
const struct ihex_binrec *record;
715+
const struct firmware *fw;
726716

727717
/* download the firmware here ... */
728718
response = ezusb_set_reset(serial, 1);
729719

720+
if (0) { ; }
730721
#ifdef KEYSPAN
731-
if (le16_to_cpu(serial->dev->descriptor.idVendor) == KEYSPAN_VENDOR_ID)
732-
record = &keyspan_pda_firmware[0];
722+
else if (le16_to_cpu(serial->dev->descriptor.idVendor) == KEYSPAN_VENDOR_ID)
723+
fw_name = "keyspan_pda/keyspan_pda.fw";
733724
#endif
734725
#ifdef XIRCOM
735-
if ((le16_to_cpu(serial->dev->descriptor.idVendor) == XIRCOM_VENDOR_ID) ||
736-
(le16_to_cpu(serial->dev->descriptor.idVendor) == ENTREGRA_VENDOR_ID))
737-
record = &xircom_pgs_firmware[0];
726+
else if ((le16_to_cpu(serial->dev->descriptor.idVendor) == XIRCOM_VENDOR_ID) ||
727+
(le16_to_cpu(serial->dev->descriptor.idVendor) == ENTREGRA_VENDOR_ID))
728+
fw_name = "keyspan_pda/xircom_pgs.fw";
738729
#endif
739-
if (record == NULL) {
730+
else {
740731
err("%s: unknown vendor, aborting.", __func__);
741732
return -ENODEV;
742733
}
734+
if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) {
735+
err("failed to load firmware \"%s\"\n", fw_name);
736+
return -ENOENT;
737+
}
738+
record = (const struct ihex_binrec *)fw->data;
743739

744-
while(record->address != 0xffff) {
745-
response = ezusb_writememory(serial, record->address,
740+
while (record) {
741+
response = ezusb_writememory(serial, be32_to_cpu(record->addr),
746742
(unsigned char *)record->data,
747-
record->data_size, 0xa0);
743+
be16_to_cpu(record->len), 0xa0);
748744
if (response < 0) {
749745
err("ezusb_writememory failed for Keyspan PDA "
750746
"firmware (%d %04X %p %d)",
751-
response,
752-
record->address, record->data, record->data_size);
747+
response, be32_to_cpu(record->addr),
748+
record->data, be16_to_cpu(record->len));
753749
break;
754750
}
755-
record++;
751+
record = ihex_next_binrec(record);
756752
}
753+
release_firmware(fw);
757754
/* bring device out of reset. Renumeration will occur in a moment
758755
and the new device will bind to the real driver */
759756
response = ezusb_set_reset(serial, 0);

‎drivers/usb/serial/keyspan_pda_fw.h‎

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)