Skip to content

Commit 547d8bb

Browse files
dwmw2David Woodhouse
authored andcommitted
ip2: use request_firmware()
Converted with help from Jaswinder Singh Signed-off-by: David Woodhouse <dwmw2@infradead.org> Acked-by: Alan Cox <alan@redhat.com>
1 parent 27d202f commit 547d8bb

File tree

6 files changed

+2196
-2163
lines changed

6 files changed

+2196
-2163
lines changed

drivers/char/ip2/fip_firm.h

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

drivers/char/ip2/ip2base.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
#endif
2222

2323
#include "ip2types.h"
24-
#include "fip_firm.h" // the meat
2524

2625
int
27-
ip2_loadmain(int *, int *, unsigned char *, int ); // ref into ip2main.c
26+
ip2_loadmain(int *, int *); // ref into ip2main.c
2827

2928
/* Note: Add compiled in defaults to these arrays, not to the structure
3029
in ip2.h any longer. That structure WILL get overridden
@@ -52,7 +51,7 @@ static int __init ip2_init(void)
5251
irq[0] = irq[1] = irq[2] = irq[3] = 0;
5352
}
5453

55-
return ip2_loadmain(io,irq,(unsigned char *)fip_firm,sizeof(fip_firm));
54+
return ip2_loadmain(io, irq);
5655
}
5756
module_init(ip2_init);
5857

drivers/char/ip2/ip2main.c

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
#include <linux/major.h>
9999
#include <linux/wait.h>
100100
#include <linux/device.h>
101+
#include <linux/firmware.h>
102+
#include <linux/platform_device.h>
101103

102104
#include <linux/tty.h>
103105
#include <linux/tty_flip.h>
@@ -155,9 +157,7 @@ static char *pcDriver_name = "ip2";
155157
static char *pcIpl = "ip2ipl";
156158

157159
// cheezy kludge or genius - you decide?
158-
int ip2_loadmain(int *, int *, unsigned char *, int);
159-
static unsigned char *Fip_firmware;
160-
static int Fip_firmware_size;
160+
int ip2_loadmain(int *, int *);
161161

162162
/***********************/
163163
/* Function Prototypes */
@@ -208,7 +208,7 @@ static int ip2_ipl_open(struct inode *, struct file *);
208208
static int DumpTraceBuffer(char __user *, int);
209209
static int DumpFifoBuffer( char __user *, int);
210210

211-
static void ip2_init_board(int);
211+
static void ip2_init_board(int, const struct firmware *);
212212
static unsigned short find_eisa_board(int);
213213

214214
/***************/
@@ -474,15 +474,35 @@ static const struct tty_operations ip2_ops = {
474474
/* SA_RANDOM - can be source for cert. random number generators */
475475
#define IP2_SA_FLAGS 0
476476

477+
478+
static const struct firmware *ip2_request_firmware(void)
479+
{
480+
struct platform_device *pdev;
481+
const struct firmware *fw;
482+
483+
pdev = platform_device_register_simple("ip2", 0, NULL, 0);
484+
if (IS_ERR(pdev)) {
485+
printk(KERN_ERR "Failed to register platform device for ip2\n");
486+
return NULL;
487+
}
488+
if (request_firmware(&fw, "intelliport2.bin", &pdev->dev)) {
489+
printk(KERN_ERR "Failed to load firmware 'intelliport2.bin'\n");
490+
fw = NULL;
491+
}
492+
platform_device_unregister(pdev);
493+
return fw;
494+
}
495+
477496
int
478-
ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
497+
ip2_loadmain(int *iop, int *irqp)
479498
{
480499
int i, j, box;
481500
int err = 0;
482501
static int loaded;
483502
i2eBordStrPtr pB = NULL;
484503
int rc = -1;
485504
static struct pci_dev *pci_dev_i = NULL;
505+
const struct firmware *fw = NULL;
486506

487507
ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0 );
488508

@@ -516,9 +536,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
516536
}
517537
poll_only = !poll_only;
518538

519-
Fip_firmware = firmware;
520-
Fip_firmware_size = firmsize;
521-
522539
/* Announce our presence */
523540
printk( KERN_INFO "%s version %s\n", pcName, pcVersion );
524541

@@ -638,10 +655,18 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
638655
}
639656
}
640657
for ( i = 0; i < IP2_MAX_BOARDS; ++i ) {
658+
/* We don't want to request the firmware unless we have at
659+
least one board */
641660
if ( i2BoardPtrTable[i] != NULL ) {
642-
ip2_init_board( i );
661+
if (!fw)
662+
fw = ip2_request_firmware();
663+
if (!fw)
664+
break;
665+
ip2_init_board(i, fw);
643666
}
644667
}
668+
if (fw)
669+
release_firmware(fw);
645670

646671
ip2trace (ITRC_NO_PORT, ITRC_INIT, 2, 0 );
647672

@@ -769,7 +794,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
769794
/* are reported on the console. */
770795
/******************************************************************************/
771796
static void
772-
ip2_init_board( int boardnum )
797+
ip2_init_board(int boardnum, const struct firmware *fw)
773798
{
774799
int i;
775800
int nports = 0, nboxes = 0;
@@ -789,7 +814,7 @@ ip2_init_board( int boardnum )
789814
goto err_initialize;
790815
}
791816

792-
if ( iiDownloadAll ( pB, (loadHdrStrPtr)Fip_firmware, 1, Fip_firmware_size )
817+
if ( iiDownloadAll ( pB, (loadHdrStrPtr)fw->data, 1, fw->size )
793818
!= II_DOWN_GOOD ) {
794819
printk ( KERN_ERR "IP2: failed to download loadware\n" );
795820
goto err_release_region;

firmware/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ fw-external-y := $(subst ",,$(CONFIG_EXTRA_FIRMWARE))
2121
# But be aware that the config file might not be included at all.
2222

2323
fw-shipped-$(CONFIG_ATM_AMBASSADOR) += atmsar11.fw
24+
fw-shipped-$(CONFIG_COMPUTONE) += intelliport2.bin
2425
fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin
2526
fw-shipped-$(CONFIG_SMCTR) += tr_smctr.bin
2627
fw-shipped-$(CONFIG_SND_KORG1212) += korg/k1212.dsp

firmware/WHENCE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,13 @@ Debug loader claims the following behaviour:
226226
Converted from Intel HEX files, used in our binary representation of ihex.
227227

228228
--------------------------------------------------------------------------
229+
230+
Driver: ip2 -- Computone IntelliPort Plus serial device
231+
232+
File: intelliport2.bin
233+
234+
Licence: Unknown
235+
236+
Found in hex form in kernel source.
237+
238+
--------------------------------------------------------------------------

0 commit comments

Comments
 (0)