summaryrefslogtreecommitdiff
path: root/drivers/staging/wlan-ng/prism2fw.c
diff options
context:
space:
mode:
authorMithlesh Thukral <mithlesh@linsyssoft.com>2009-05-25 19:06:16 +0530
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 11:00:38 -0700
commit75f49e07520d036c2a0903694fdc0bcfb5523b76 (patch)
treec049a32d58d6406aee35d2dac769ef758f5f499b /drivers/staging/wlan-ng/prism2fw.c
parent1611a52c395e6036725104af3a74a0cef8ea42b8 (diff)
Staging: wlan-ng: Lindent cleanups
Lindent script cleanups in wlan-ng driver in the staging tree. This is a item in the TODO list. Signed-off-by: Mithlesh Thukral <mithlesh@linsyssoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/wlan-ng/prism2fw.c')
-rw-r--r--drivers/staging/wlan-ng/prism2fw.c868
1 files changed, 432 insertions, 436 deletions
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 48bfb8331ddb..608b234b6a44 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -50,7 +50,6 @@
#include <linux/sort.h>
#include <linux/firmware.h>
-
/*================================================================*/
/* Local Constants */
@@ -125,89 +124,80 @@
: "cc"); \
__v; }))
-
-
/*================================================================*/
/* Local Types */
-typedef struct s3datarec
-{
- u32 len;
- u32 addr;
- u8 checksum;
- u8 *data;
+typedef struct s3datarec {
+ u32 len;
+ u32 addr;
+ u8 checksum;
+ u8 *data;
} s3datarec_t;
-typedef struct s3plugrec
-{
- u32 itemcode;
- u32 addr;
- u32 len;
+typedef struct s3plugrec {
+ u32 itemcode;
+ u32 addr;
+ u32 len;
} s3plugrec_t;
-typedef struct s3crcrec
-{
- u32 addr;
- u32 len;
- unsigned int dowrite;
+typedef struct s3crcrec {
+ u32 addr;
+ u32 len;
+ unsigned int dowrite;
} s3crcrec_t;
-typedef struct s3inforec
-{
- u16 len;
- u16 type;
+typedef struct s3inforec {
+ u16 len;
+ u16 type;
union {
- hfa384x_compident_t version;
- hfa384x_caplevel_t compat;
- u16 buildseq;
- hfa384x_compident_t platform;
- } info;
+ hfa384x_compident_t version;
+ hfa384x_caplevel_t compat;
+ u16 buildseq;
+ hfa384x_compident_t platform;
+ } info;
} s3inforec_t;
-typedef struct pda
-{
- u8 buf[HFA384x_PDA_LEN_MAX];
- hfa384x_pdrec_t *rec[HFA384x_PDA_RECS_MAX];
- unsigned int nrec;
+typedef struct pda {
+ u8 buf[HFA384x_PDA_LEN_MAX];
+ hfa384x_pdrec_t *rec[HFA384x_PDA_RECS_MAX];
+ unsigned int nrec;
} pda_t;
-typedef struct imgchunk
-{
- u32 addr; /* start address */
- u32 len; /* in bytes */
- u16 crc; /* CRC value (if it falls at a chunk boundary) */
- u8 *data;
+typedef struct imgchunk {
+ u32 addr; /* start address */
+ u32 len; /* in bytes */
+ u16 crc; /* CRC value (if it falls at a chunk boundary) */
+ u8 *data;
} imgchunk_t;
/*================================================================*/
/* Local Static Definitions */
-
/*----------------------------------------------------------------*/
/* s-record image processing */
/* Data records */
-unsigned int ns3data = 0;
-s3datarec_t s3data[S3DATA_MAX];
+unsigned int ns3data = 0;
+s3datarec_t s3data[S3DATA_MAX];
/* Plug records */
-unsigned int ns3plug = 0;
-s3plugrec_t s3plug[S3PLUG_MAX];
+unsigned int ns3plug = 0;
+s3plugrec_t s3plug[S3PLUG_MAX];
/* CRC records */
-unsigned int ns3crc = 0;
-s3crcrec_t s3crc[S3CRC_MAX];
+unsigned int ns3crc = 0;
+s3crcrec_t s3crc[S3CRC_MAX];
/* Info records */
-unsigned int ns3info = 0;
-s3inforec_t s3info[S3INFO_MAX];
+unsigned int ns3info = 0;
+s3inforec_t s3info[S3INFO_MAX];
/* S7 record (there _better_ be only one) */
-u32 startaddr;
+u32 startaddr;
/* Load image chunks */
-unsigned int nfchunks;
-imgchunk_t fchunk[CHUNKS_MAX];
+unsigned int nfchunks;
+imgchunk_t fchunk[CHUNKS_MAX];
/* Note that for the following pdrec_t arrays, the len and code */
/* fields are stored in HOST byte order. The mkpdrlist() function */
@@ -215,36 +205,35 @@ imgchunk_t fchunk[CHUNKS_MAX];
/*----------------------------------------------------------------*/
/* PDA, built from [card|newfile]+[addfile1+addfile2...] */
-pda_t pda;
+pda_t pda;
hfa384x_compident_t nicid;
-hfa384x_caplevel_t rfid;
-hfa384x_caplevel_t macid;
-hfa384x_caplevel_t priid;
-
+hfa384x_caplevel_t rfid;
+hfa384x_caplevel_t macid;
+hfa384x_caplevel_t priid;
/*================================================================*/
/* Local Function Declarations */
-int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev);
-int read_srecfile(char *rfptr, int rfsize);
-int mkimage(imgchunk_t *clist, unsigned int *ccnt);
-int read_cardpda(pda_t *pda, wlandevice_t *wlandev);
-int mkpdrlist( pda_t *pda);
-int s3datarec_compare(const void *p1, const void *p2);
-int plugimage( imgchunk_t *fchunk, unsigned int nfchunks,
- s3plugrec_t* s3plug, unsigned int ns3plug, pda_t *pda);
-int crcimage( imgchunk_t *fchunk, unsigned int nfchunks,
- s3crcrec_t *s3crc, unsigned int ns3crc);
-int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, unsigned int nfchunks);
-void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks);
-void free_srecs(void);
-
-int validate_identity(void);
+int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t * wlandev);
+int read_srecfile(char *rfptr, int rfsize);
+int mkimage(imgchunk_t * clist, unsigned int *ccnt);
+int read_cardpda(pda_t * pda, wlandevice_t * wlandev);
+int mkpdrlist(pda_t * pda);
+int s3datarec_compare(const void *p1, const void *p2);
+int plugimage(imgchunk_t * fchunk, unsigned int nfchunks,
+ s3plugrec_t * s3plug, unsigned int ns3plug, pda_t * pda);
+int crcimage(imgchunk_t * fchunk, unsigned int nfchunks,
+ s3crcrec_t * s3crc, unsigned int ns3crc);
+int writeimage(wlandevice_t * wlandev, imgchunk_t * fchunk,
+ unsigned int nfchunks);
+void free_chunks(imgchunk_t * fchunk, unsigned int *nfchunks);
+void free_srecs(void);
+
+int validate_identity(void);
/*================================================================*/
/* Function Definitions */
-
/*----------------------------------------------------------------
* prism2_fwtry
*
@@ -258,13 +247,13 @@ int validate_identity(void);
* 0 - success
* ~0 - failure
----------------------------------------------------------------*/
-int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
+int prism2_fwtry(struct usb_device *udev, wlandevice_t * wlandev)
{
const struct firmware *fw_entry = NULL;
- printk(KERN_INFO "prism2_usb: Checking for firmware %s\n", PRISM2_USB_FWFILE);
- if(request_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0)
- {
+ printk(KERN_INFO "prism2_usb: Checking for firmware %s\n",
+ PRISM2_USB_FWFILE);
+ if (request_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0) {
printk(KERN_INFO
"prism2_usb: Firmware not available, but not essential\n");
printk(KERN_INFO
@@ -272,14 +261,14 @@ int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
return 1;
}
- printk(KERN_INFO "prism2_usb: %s will be processed, size %d\n", PRISM2_USB_FWFILE, fw_entry->size);
+ printk(KERN_INFO "prism2_usb: %s will be processed, size %d\n",
+ PRISM2_USB_FWFILE, fw_entry->size);
prism2_fwapply((char *)fw_entry->data, fw_entry->size, wlandev);
release_firmware(fw_entry);
return 0;
}
-
/*----------------------------------------------------------------
* prism2_fwapply
*
@@ -294,12 +283,12 @@ int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
* 0 - success
* ~0 - failure
----------------------------------------------------------------*/
-int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
+int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t * wlandev)
{
- signed int result = 0;
+ signed int result = 0;
p80211msg_dot11req_mibget_t getmsg;
p80211itemd_t *item;
- u32 *data;
+ u32 *data;
/* Initialize the data structures */
ns3data = 0;
@@ -313,20 +302,19 @@ int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
startaddr = 0;
nfchunks = 0;
- memset( fchunk, 0, sizeof(fchunk));
- memset( &nicid, 0, sizeof(nicid));
- memset( &rfid, 0, sizeof(rfid));
- memset( &macid, 0, sizeof(macid));
- memset( &priid, 0, sizeof(priid));
+ memset(fchunk, 0, sizeof(fchunk));
+ memset(&nicid, 0, sizeof(nicid));
+ memset(&rfid, 0, sizeof(rfid));
+ memset(&macid, 0, sizeof(macid));
+ memset(&priid, 0, sizeof(priid));
/* clear the pda and add an initial END record */
memset(&pda, 0, sizeof(pda));
- pda.rec[0] = (hfa384x_pdrec_t*)pda.buf;
- pda.rec[0]->len = cpu_to_le16(2); /* len in words */ /* len in words */
+ pda.rec[0] = (hfa384x_pdrec_t *) pda.buf;
+ pda.rec[0]->len = cpu_to_le16(2); /* len in words *//* len in words */
pda.rec[0]->code = cpu_to_le16(HFA384x_PDR_END_OF_PDA);
pda.nrec = 1;
-
/*-----------------------------------------------------*/
/* Put card into fwload state */
prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
@@ -334,7 +322,7 @@ int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
/* Build the PDA we're going to use. */
if (read_cardpda(&pda, wlandev)) {
printk(KERN_ERR "load_cardpda failed, exiting.\n");
- return(1);
+ return (1);
}
/* read the card's PRI-SUP */
@@ -352,7 +340,7 @@ int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
item->did = DIDmib_p2_p2NIC_p2PRISupRange;
item->status = P80211ENUM_msgitem_status_no_value;
- data = (u32*) item->data;
+ data = (u32 *) item->data;
/* DIDmsg_dot11req_mibget */
prism2mgmt_mibset_mibget(wlandev, &getmsg);
@@ -367,53 +355,48 @@ int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
priid.bottom = *data++;
priid.top = *data++;
-
/* Read the S3 file */
result = read_srecfile(rfptr, rfsize);
- if ( result ) {
+ if (result) {
printk(KERN_ERR "Failed to read the data exiting.\n");
- return(1);
+ return (1);
}
/* Sort the S3 data records */
- sort( s3data,
- ns3data,
- sizeof(s3datarec_t),
- s3datarec_compare, NULL);
+ sort(s3data, ns3data, sizeof(s3datarec_t), s3datarec_compare, NULL);
result = validate_identity();
- if ( result ) {
+ if (result) {
printk(KERN_ERR "Incompatible firmware image.\n");
- return(1);
+ return (1);
}
if (startaddr == 0x00000000) {
printk(KERN_ERR "Can't RAM download a Flash image!\n");
- return(1);
+ return (1);
}
/* Make the image chunks */
result = mkimage(fchunk, &nfchunks);
/* Do any plugging */
- result = plugimage(fchunk, nfchunks, s3plug, ns3plug,
- &pda);
- if ( result ) {
+ result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
+ if (result) {
printk(KERN_ERR "Failed to plug data.\n");
- return(1);
+ return (1);
}
/* Insert any CRCs */
- if (crcimage(fchunk, nfchunks, s3crc, ns3crc) ) {
+ if (crcimage(fchunk, nfchunks, s3crc, ns3crc)) {
printk(KERN_ERR "Failed to insert all CRCs\n");
- return(1);
+ return (1);
}
/* Write the image */
result = writeimage(wlandev, fchunk, nfchunks);
- if ( result ) {
+ if (result) {
printk(KERN_ERR "Failed to ramwrite image data.\n");
- return(1);
+ return (1);
}
/* clear any allocated memory */
@@ -425,7 +408,6 @@ int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
return result;
}
-
/*----------------------------------------------------------------
* crcimage
*
@@ -443,59 +425,60 @@ int prism2_fwapply(char *rfptr, int rfsize, wlandevice_t *wlandev)
* 0 success
* ~0 failure
----------------------------------------------------------------*/
-int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc,
+int crcimage(imgchunk_t * fchunk, unsigned int nfchunks, s3crcrec_t * s3crc,
unsigned int ns3crc)
{
- int result = 0;
- int i;
- int c;
- u32 crcstart;
- u32 crcend;
- u32 cstart = 0;
- u32 cend;
- u8 *dest;
- u32 chunkoff;
-
- for ( i = 0; i < ns3crc; i++ ) {
- if ( !s3crc[i].dowrite ) continue;
+ int result = 0;
+ int i;
+ int c;
+ u32 crcstart;
+ u32 crcend;
+ u32 cstart = 0;
+ u32 cend;
+ u8 *dest;
+ u32 chunkoff;
+
+ for (i = 0; i < ns3crc; i++) {
+ if (!s3crc[i].dowrite)
+ continue;
crcstart = s3crc[i].addr;
- crcend = s3crc[i].addr + s3crc[i].len;
+ crcend = s3crc[i].addr + s3crc[i].len;
/* Find chunk */
- for ( c = 0; c < nfchunks; c++) {
+ for (c = 0; c < nfchunks; c++) {
cstart = fchunk[c].addr;
- cend = fchunk[c].addr + fchunk[c].len;
+ cend = fchunk[c].addr + fchunk[c].len;
/* the line below does an address & len match search */
/* unfortunately, I've found that the len fields of */
/* some crc records don't match with the length of */
/* the actual data, so we're not checking right */
/* now */
- /* if ( crcstart-2 >= cstart && crcend <= cend ) break;*/
+ /* if ( crcstart-2 >= cstart && crcend <= cend ) break; */
/* note the -2 below, it's to make sure the chunk has */
/* space for the CRC value */
- if ( crcstart-2 >= cstart && crcstart < cend ) break;
+ if (crcstart - 2 >= cstart && crcstart < cend)
+ break;
}
- if ( c >= nfchunks ) {
+ if (c >= nfchunks) {
printk(KERN_ERR
- "Failed to find chunk for "
- "crcrec[%d], addr=0x%06x len=%d , "
- "aborting crc.\n",
- i, s3crc[i].addr, s3crc[i].len);
+ "Failed to find chunk for "
+ "crcrec[%d], addr=0x%06x len=%d , "
+ "aborting crc.\n",
+ i, s3crc[i].addr, s3crc[i].len);
return 1;
}
/* Insert crc */
- pr_debug("Adding crc @ 0x%06x\n", s3crc[i].addr-2);
+ pr_debug("Adding crc @ 0x%06x\n", s3crc[i].addr - 2);
chunkoff = crcstart - cstart - 2;
dest = fchunk[c].data + chunkoff;
- *dest = 0xde;
- *(dest+1) = 0xc0;
+ *dest = 0xde;
+ *(dest + 1) = 0xc0;
}
return result;
}
-
/*----------------------------------------------------------------
* free_chunks
*
@@ -507,20 +490,19 @@ int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc,
* Returns:
* nothing
----------------------------------------------------------------*/
-void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks)
+void free_chunks(imgchunk_t * fchunk, unsigned int *nfchunks)
{
int i;
- for ( i = 0; i < *nfchunks; i++) {
- if ( fchunk[i].data != NULL ) {
+ for (i = 0; i < *nfchunks; i++) {
+ if (fchunk[i].data != NULL) {
kfree(fchunk[i].data);
}
}
*nfchunks = 0;
- memset( fchunk, 0, sizeof(fchunk));
+ memset(fchunk, 0, sizeof(fchunk));
}
-
/*----------------------------------------------------------------
* free_srecs
*
@@ -535,7 +517,7 @@ void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks)
void free_srecs(void)
{
int i;
- for ( i = 0; i < ns3data; i++) {
+ for (i = 0; i < ns3data; i++) {
kfree(s3data[i].data);
}
ns3data = 0;
@@ -549,7 +531,6 @@ void free_srecs(void)
startaddr = 0;
}
-
/*----------------------------------------------------------------
* mkimage
*
@@ -564,25 +545,25 @@ void free_srecs(void)
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
-int mkimage(imgchunk_t *clist, unsigned int *ccnt)
+int mkimage(imgchunk_t * clist, unsigned int *ccnt)
{
- int result = 0;
- int i;
- int j;
- int currchunk = 0;
- u32 nextaddr = 0;
- u32 s3start;
- u32 s3end;
- u32 cstart = 0;
- u32 cend;
- u32 coffset;
+ int result = 0;
+ int i;
+ int j;
+ int currchunk = 0;
+ u32 nextaddr = 0;
+ u32 s3start;
+ u32 s3end;
+ u32 cstart = 0;
+ u32 cend;
+ u32 coffset;
/* There may already be data in the chunklist */
*ccnt = 0;
/* Establish the location and size of each chunk */
- for ( i = 0; i < ns3data; i++) {
- if ( s3data[i].addr == nextaddr ) {
+ for (i = 0; i < ns3data; i++) {
+ if (s3data[i].addr == nextaddr) {
/* existing chunk, grow it */
clist[currchunk].len += s3data[i].len;
nextaddr += s3data[i].len;
@@ -595,9 +576,9 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt)
nextaddr = s3data[i].addr + s3data[i].len;
/* Expand the chunk if there is a CRC record at */
/* their beginning bound */
- for ( j = 0; j < ns3crc; j++) {
- if ( s3crc[j].dowrite &&
- s3crc[j].addr == clist[currchunk].addr ) {
+ for (j = 0; j < ns3crc; j++) {
+ if (s3crc[j].dowrite &&
+ s3crc[j].addr == clist[currchunk].addr) {
clist[currchunk].addr -= 2;
clist[currchunk].len += 2;
}
@@ -609,41 +590,41 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt)
/* if this proves false, we'll need to add code to coalesce. */
/* Allocate buffer space for chunks */
- for ( i = 0; i < *ccnt; i++) {
+ for (i = 0; i < *ccnt; i++) {
clist[i].data = kmalloc(clist[i].len, GFP_KERNEL);
- if ( clist[i].data == NULL ) {
- printk(KERN_ERR "failed to allocate image space, exitting.\n");
- return(1);
+ if (clist[i].data == NULL) {
+ printk(KERN_ERR
+ "failed to allocate image space, exitting.\n");
+ return (1);
}
memset(clist[i].data, 0, clist[i].len);
}
-
/* Display chunks */
- for ( i = 0; i < *ccnt; i++) {
+ for (i = 0; i < *ccnt; i++) {
pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
- i, clist[i].addr, clist[i].len);
+ i, clist[i].addr, clist[i].len);
}
/* Copy srec data to chunks */
- for ( i = 0; i < ns3data; i++) {
+ for (i = 0; i < ns3data; i++) {
s3start = s3data[i].addr;
- s3end = s3start + s3data[i].len - 1;
- for ( j = 0; j < *ccnt; j++) {
+ s3end = s3start + s3data[i].len - 1;
+ for (j = 0; j < *ccnt; j++) {
cstart = clist[j].addr;
cend = cstart + clist[j].len - 1;
- if ( s3start >= cstart && s3end <= cend ) {
+ if (s3start >= cstart && s3end <= cend) {
break;
}
}
- if ( ((unsigned int)j) >= (*ccnt) ) {
+ if (((unsigned int)j) >= (*ccnt)) {
printk(KERN_ERR
- "s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n",
- s3start, s3data[i].len);
- return(1);
+ "s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n",
+ s3start, s3data[i].len);
+ return (1);
}
coffset = s3start - cstart;
- memcpy( clist[j].data + coffset, s3data[i].data, s3data[i].len);
+ memcpy(clist[j].data + coffset, s3data[i].data, s3data[i].len);
}
return result;
@@ -663,21 +644,19 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt)
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
-int mkpdrlist( pda_t *pda)
+int mkpdrlist(pda_t * pda)
{
- int result = 0;
- u16 *pda16 = (u16*)pda->buf;
- int curroff; /* in 'words' */
+ int result = 0;
+ u16 *pda16 = (u16 *) pda->buf;
+ int curroff; /* in 'words' */
pda->nrec = 0;
curroff = 0;
- while ( curroff < (HFA384x_PDA_LEN_MAX / 2) &&
- le16_to_cpu(pda16[curroff + 1]) !=
- HFA384x_PDR_END_OF_PDA ) {
- pda->rec[pda->nrec] = (hfa384x_pdrec_t*)&(pda16[curroff]);
+ while (curroff < (HFA384x_PDA_LEN_MAX / 2) &&
+ le16_to_cpu(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA) {
+ pda->rec[pda->nrec] = (hfa384x_pdrec_t *) & (pda16[curroff]);
- if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
- HFA384x_PDR_NICID) {
+ if (le16_to_cpu(pda->rec[pda->nrec]->code) == HFA384x_PDR_NICID) {
memcpy(&nicid, &pda->rec[pda->nrec]->data.nicid,
sizeof(nicid));
nicid.id = le16_to_cpu(nicid.id);
@@ -686,7 +665,7 @@ int mkpdrlist( pda_t *pda)
nicid.minor = le16_to_cpu(nicid.minor);
}
if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
- HFA384x_PDR_MFISUPRANGE) {
+ HFA384x_PDR_MFISUPRANGE) {
memcpy(&rfid, &pda->rec[pda->nrec]->data.mfisuprange,
sizeof(rfid));
rfid.id = le16_to_cpu(rfid.id);
@@ -695,7 +674,7 @@ int mkpdrlist( pda_t *pda)
rfid.top = le16_to_cpu(rfid.top);
}
if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
- HFA384x_PDR_CFISUPRANGE) {
+ HFA384x_PDR_CFISUPRANGE) {
memcpy(&macid, &pda->rec[pda->nrec]->data.cfisuprange,
sizeof(macid));
macid.id = le16_to_cpu(macid.id);
@@ -708,21 +687,19 @@ int mkpdrlist( pda_t *pda)
curroff += le16_to_cpu(pda16[curroff]) + 1;
}
- if ( curroff >= (HFA384x_PDA_LEN_MAX / 2) ) {
+ if (curroff >= (HFA384x_PDA_LEN_MAX / 2)) {
printk(KERN_ERR
- "no end record found or invalid lengths in "
- "PDR data, exiting. %x %d\n", curroff, pda->nrec);
- return(1);
+ "no end record found or invalid lengths in "
+ "PDR data, exiting. %x %d\n", curroff, pda->nrec);
+ return (1);
}
- if (le16_to_cpu(pda16[curroff + 1]) == HFA384x_PDR_END_OF_PDA ) {
- pda->rec[pda->nrec] = (hfa384x_pdrec_t*)&(pda16[curroff]);
+ if (le16_to_cpu(pda16[curroff + 1]) == HFA384x_PDR_END_OF_PDA) {
+ pda->rec[pda->nrec] = (hfa384x_pdrec_t *) & (pda16[curroff]);
(pda->nrec)++;
}
return result;
}
-
-
/*----------------------------------------------------------------
* plugimage
*
@@ -740,39 +717,39 @@ int mkpdrlist( pda_t *pda)
* 0 success
* ~0 failure
----------------------------------------------------------------*/
-int plugimage( imgchunk_t *fchunk, unsigned int nfchunks,
- s3plugrec_t* s3plug, unsigned int ns3plug, pda_t *pda)
+int plugimage(imgchunk_t * fchunk, unsigned int nfchunks,
+ s3plugrec_t * s3plug, unsigned int ns3plug, pda_t * pda)
{
- int result = 0;
- int i; /* plug index */
- int j; /* index of PDR or -1 if fname plug */
- int c; /* chunk index */
- u32 pstart;
- u32 pend;
- u32 cstart = 0;
- u32 cend;
- u32 chunkoff;
- u8 *dest;
+ int result = 0;
+ int i; /* plug index */
+ int j; /* index of PDR or -1 if fname plug */
+ int c; /* chunk index */
+ u32 pstart;
+ u32 pend;
+ u32 cstart = 0;
+ u32 cend;
+ u32 chunkoff;
+ u8 *dest;
/* for each plug record */
- for ( i = 0; i < ns3plug; i++) {
+ for (i = 0; i < ns3plug; i++) {
pstart = s3plug[i].addr;
- pend = s3plug[i].addr + s3plug[i].len;
+ pend = s3plug[i].addr + s3plug[i].len;
/* find the matching PDR (or filename) */
- if ( s3plug[i].itemcode != 0xffffffffUL ) { /* not filename */
- for ( j = 0; j < pda->nrec; j++) {
- if ( s3plug[i].itemcode ==
- le16_to_cpu(pda->rec[j]->code) ) break;
+ if (s3plug[i].itemcode != 0xffffffffUL) { /* not filename */
+ for (j = 0; j < pda->nrec; j++) {
+ if (s3plug[i].itemcode ==
+ le16_to_cpu(pda->rec[j]->code))
+ break;
}
} else {
j = -1;
}
- if ( j >= pda->nrec && j != -1 ) { /* if no matching PDR, fail */
+ if (j >= pda->nrec && j != -1) { /* if no matching PDR, fail */
printk(KERN_WARNING
- "warning: Failed to find PDR for "
- "plugrec 0x%04x.\n",
- s3plug[i].itemcode);
- continue; /* and move on to the next PDR */
+ "warning: Failed to find PDR for "
+ "plugrec 0x%04x.\n", s3plug[i].itemcode);
+ continue; /* and move on to the next PDR */
#if 0
/* MSM: They swear that unless it's the MAC address,
* the serial number, or the TX calibration records,
@@ -787,27 +764,26 @@ int plugimage( imgchunk_t *fchunk, unsigned int nfchunks,
}
/* Validate plug len against PDR len */
- if ( j != -1 &&
- s3plug[i].len < le16_to_cpu(pda->rec[j]->len) ) {
+ if (j != -1 && s3plug[i].len < le16_to_cpu(pda->rec[j]->len)) {
printk(KERN_ERR
- "error: Plug vs. PDR len mismatch for "
- "plugrec 0x%04x, abort plugging.\n",
- s3plug[i].itemcode);
+ "error: Plug vs. PDR len mismatch for "
+ "plugrec 0x%04x, abort plugging.\n",
+ s3plug[i].itemcode);
result = 1;
continue;
}
/* Validate plug address against chunk data and identify chunk */
- for ( c = 0; c < nfchunks; c++) {
+ for (c = 0; c < nfchunks; c++) {
cstart = fchunk[c].addr;
- cend = fchunk[c].addr + fchunk[c].len;
- if ( pstart >= cstart && pend <= cend ) break;
+ cend = fchunk[c].addr + fchunk[c].len;
+ if (pstart >= cstart && pend <= cend)
+ break;
}
- if ( c >= nfchunks ) {
+ if (c >= nfchunks) {
printk(KERN_ERR
- "error: Failed to find image chunk for "
- "plugrec 0x%04x.\n",
- s3plug[i].itemcode);
+ "error: Failed to find image chunk for "
+ "plugrec 0x%04x.\n", s3plug[i].itemcode);
result = 1;
continue;
}
@@ -816,22 +792,21 @@ int plugimage( imgchunk_t *fchunk, unsigned int nfchunks,
chunkoff = pstart - cstart;
dest = fchunk[c].data + chunkoff;
pr_debug("Plugging item 0x%04x @ 0x%06x, len=%d, "
- "cnum=%d coff=0x%06x\n",
- s3plug[i].itemcode, pstart, s3plug[i].len,
- c, chunkoff);
+ "cnum=%d coff=0x%06x\n",
+ s3plug[i].itemcode, pstart, s3plug[i].len,
+ c, chunkoff);
- if ( j == -1 ) { /* plug the filename */
+ if (j == -1) { /* plug the filename */
memset(dest, 0, s3plug[i].len);
strncpy(dest, PRISM2_USB_FWFILE, s3plug[i].len - 1);
- } else { /* plug a PDR */
- memcpy( dest, &(pda->rec[j]->data), s3plug[i].len);
+ } else { /* plug a PDR */
+ memcpy(dest, &(pda->rec[j]->data), s3plug[i].len);
}
}
return result;
}
-
/*----------------------------------------------------------------
* read_cardpda
*
@@ -850,10 +825,10 @@ int plugimage( imgchunk_t *fchunk, unsigned int nfchunks,
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
-int read_cardpda(pda_t *pda, wlandevice_t *wlandev)
+int read_cardpda(pda_t * pda, wlandevice_t * wlandev)
{
- int result = 0;
- p80211msg_p2req_readpda_t msg;
+ int result = 0;
+ p80211msg_p2req_readpda_t msg;
/* set up the msg */
msg.msgcode = DIDmsg_p2req_readpda;
@@ -866,10 +841,10 @@ int read_cardpda(pda_t *pda, wlandevice_t *wlandev)
msg.resultcode.len = sizeof(u32);
msg.resultcode.status = P80211ENUM_msgitem_status_no_value;
- if ( prism2mgmt_readpda(wlandev, &msg) != 0 ) {
+ if (prism2mgmt_readpda(wlandev, &msg) != 0) {
/* prism2mgmt_readpda prints an errno if appropriate */
result = -1;
- } else if ( msg.resultcode.data == P80211ENUM_resultcode_success ) {
+ } else if (msg.resultcode.data == P80211ENUM_resultcode_success) {
memcpy(pda->buf, msg.pda.data, HFA384x_PDA_LEN_MAX);
result = mkpdrlist(pda);
} else {
@@ -880,7 +855,6 @@ int read_cardpda(pda_t *pda, wlandevice_t *wlandev)
return result;
}
-
/*----------------------------------------------------------------
* copy_line
*
@@ -909,7 +883,6 @@ int copyline(char *from, char *to, char *limit)
return (c < SREC_LINE_MAX - 1) ? c + 1 : c;
}
-
/*----------------------------------------------------------------
* read_srecfile
*
@@ -964,131 +937,159 @@ int copyline(char *from, char *to, char *limit)
----------------------------------------------------------------*/
int read_srecfile(char *rfptr, int rfsize)
{
- int result = 0;
- char buf[SREC_LINE_MAX];
- char tmpbuf[30];
- s3datarec_t tmprec;
- int i, c;
- int line = 0;
- u16 *tmpinfo;
- char *endptr = rfptr + rfsize;
-
+ int result = 0;
+ char buf[SREC_LINE_MAX];
+ char tmpbuf[30];
+ s3datarec_t tmprec;
+ int i, c;
+ int line = 0;
+ u16 *tmpinfo;
+ char *endptr = rfptr + rfsize;
pr_debug("Reading S-record file ...\n");
- while ( (c = copyline(rfptr, buf, endptr)) >= 12 ) {
+ while ((c = copyline(rfptr, buf, endptr)) >= 12) {
rfptr = rfptr + c;
line++;
- if ( buf[0] != 'S' ) {
+ if (buf[0] != 'S') {
printk(KERN_ERR "%d warning: No initial \'S\'\n", line);
return 1;
}
- if ( buf[1] == '7' ) { /* S7 record, start address */
+ if (buf[1] == '7') { /* S7 record, start address */
buf[12] = '\0';
- startaddr = simple_strtoul(buf+4, NULL, 16);
+ startaddr = simple_strtoul(buf + 4, NULL, 16);
pr_debug(" S7 start addr, line=%d "
- " addr=0x%08x\n",
- line,
- startaddr);
+ " addr=0x%08x\n", line, startaddr);
continue;
- } else if ( buf[1] == '3') {
+ } else if (buf[1] == '3') {
/* Ok, it's an S3, parse and put it in the right array */
/* Record Length field (we only want datalen) */
- memcpy(tmpbuf, buf+S3LEN_TXTOFFSET, S3LEN_TXTLEN);
+ memcpy(tmpbuf, buf + S3LEN_TXTOFFSET, S3LEN_TXTLEN);
tmpbuf[S3LEN_TXTLEN] = '\0';
- tmprec.len = simple_strtoul( tmpbuf, NULL, 16) - 4 - 1; /* 4=addr, 1=cksum */
+ tmprec.len = simple_strtoul(tmpbuf, NULL, 16) - 4 - 1; /* 4=addr, 1=cksum */
/* Address field */
- memcpy(tmpbuf, buf+S3ADDR_TXTOFFSET, S3ADDR_TXTLEN);
+ memcpy(tmpbuf, buf + S3ADDR_TXTOFFSET, S3ADDR_TXTLEN);
tmpbuf[S3ADDR_TXTLEN] = '\0';
- tmprec.addr = simple_strtoul( tmpbuf, NULL, 16);
+ tmprec.addr = simple_strtoul(tmpbuf, NULL, 16);
/* Checksum field */
- tmprec.checksum = simple_strtoul( buf+strlen(buf)-2, NULL, 16);
+ tmprec.checksum =
+ simple_strtoul(buf + strlen(buf) - 2, NULL, 16);
- switch( tmprec.addr )
- {
+ switch (tmprec.addr) {
case S3ADDR_PLUG:
- memcpy(tmpbuf, buf+S3PLUG_ITEMCODE_TXTOFFSET, S3PLUG_ITEMCODE_TXTLEN);
+ memcpy(tmpbuf, buf + S3PLUG_ITEMCODE_TXTOFFSET,
+ S3PLUG_ITEMCODE_TXTLEN);
tmpbuf[S3PLUG_ITEMCODE_TXTLEN] = '\0';
- s3plug[ns3plug].itemcode = simple_strtoul(tmpbuf,NULL,16);
- s3plug[ns3plug].itemcode = bswap_32(s3plug[ns3plug].itemcode);
+ s3plug[ns3plug].itemcode =
+ simple_strtoul(tmpbuf, NULL, 16);
+ s3plug[ns3plug].itemcode =
+ bswap_32(s3plug[ns3plug].itemcode);
- memcpy(tmpbuf, buf+S3PLUG_ADDR_TXTOFFSET, S3PLUG_ADDR_TXTLEN);
+ memcpy(tmpbuf, buf + S3PLUG_ADDR_TXTOFFSET,
+ S3PLUG_ADDR_TXTLEN);
tmpbuf[S3PLUG_ADDR_TXTLEN] = '\0';
- s3plug[ns3plug].addr = simple_strtoul(tmpbuf,NULL,16);
- s3plug[ns3plug].addr = bswap_32(s3plug[ns3plug].addr);
+ s3plug[ns3plug].addr =
+ simple_strtoul(tmpbuf, NULL, 16);
+ s3plug[ns3plug].addr =
+ bswap_32(s3plug[ns3plug].addr);
- memcpy(tmpbuf, buf+S3PLUG_LEN_TXTOFFSET, S3PLUG_LEN_TXTLEN);
+ memcpy(tmpbuf, buf + S3PLUG_LEN_TXTOFFSET,
+ S3PLUG_LEN_TXTLEN);
tmpbuf[S3PLUG_LEN_TXTLEN] = '\0';
- s3plug[ns3plug].len = simple_strtoul(tmpbuf,NULL,16);
- s3plug[ns3plug].len = bswap_32(s3plug[ns3plug].len);
+ s3plug[ns3plug].len =
+ simple_strtoul(tmpbuf, NULL, 16);
+ s3plug[ns3plug].len =
+ bswap_32(s3plug[ns3plug].len);
pr_debug(" S3 plugrec, line=%d "
- "itemcode=0x%04x addr=0x%08x len=%d\n",
- line,
- s3plug[ns3plug].itemcode,
- s3plug[ns3plug].addr,
- s3plug[ns3plug].len);
+ "itemcode=0x%04x addr=0x%08x len=%d\n",
+ line,
+ s3plug[ns3plug].itemcode,
+ s3plug[ns3plug].addr,
+ s3plug[ns3plug].len);
ns3plug++;
- if ( ns3plug == S3PLUG_MAX ) {
- printk(KERN_ERR "S3 plugrec limit reached - aborting\n");
+ if (ns3plug == S3PLUG_MAX) {
+ printk(KERN_ERR
+ "S3 plugrec limit reached - aborting\n");
return 1;
}
break;
case S3ADDR_CRC:
- memcpy(tmpbuf, buf+S3CRC_ADDR_TXTOFFSET, S3CRC_ADDR_TXTLEN);
+ memcpy(tmpbuf, buf + S3CRC_ADDR_TXTOFFSET,
+ S3CRC_ADDR_TXTLEN);
tmpbuf[S3CRC_ADDR_TXTLEN] = '\0';
- s3crc[ns3crc].addr = simple_strtoul(tmpbuf,NULL,16);
- s3crc[ns3crc].addr = bswap_32(s3crc[ns3crc].addr);
+ s3crc[ns3crc].addr =
+ simple_strtoul(tmpbuf, NULL, 16);
+ s3crc[ns3crc].addr =
+ bswap_32(s3crc[ns3crc].addr);
- memcpy(tmpbuf, buf+S3CRC_LEN_TXTOFFSET, S3CRC_LEN_TXTLEN);
+ memcpy(tmpbuf, buf + S3CRC_LEN_TXTOFFSET,
+ S3CRC_LEN_TXTLEN);
tmpbuf[S3CRC_LEN_TXTLEN] = '\0';
- s3crc[ns3crc].len = simple_strtoul(tmpbuf,NULL,16);
+ s3crc[ns3crc].len =
+ simple_strtoul(tmpbuf, NULL, 16);
s3crc[ns3crc].len = bswap_32(s3crc[ns3crc].len);
- memcpy(tmpbuf, buf+S3CRC_DOWRITE_TXTOFFSET, S3CRC_DOWRITE_TXTLEN);
+ memcpy(tmpbuf, buf + S3CRC_DOWRITE_TXTOFFSET,
+ S3CRC_DOWRITE_TXTLEN);
tmpbuf[S3CRC_DOWRITE_TXTLEN] = '\0';
- s3crc[ns3crc].dowrite = simple_strtoul(tmpbuf,NULL,16);
- s3crc[ns3crc].dowrite = bswap_32(s3crc[ns3crc].dowrite);
+ s3crc[ns3crc].dowrite =
+ simple_strtoul(tmpbuf, NULL, 16);
+ s3crc[ns3crc].dowrite =
+ bswap_32(s3crc[ns3crc].dowrite);
pr_debug(" S3 crcrec, line=%d "
- "addr=0x%08x len=%d write=0x%08x\n",
- line,
- s3crc[ns3crc].addr,
- s3crc[ns3crc].len,
- s3crc[ns3crc].dowrite);
+ "addr=0x%08x len=%d write=0x%08x\n",
+ line,
+ s3crc[ns3crc].addr,
+ s3crc[ns3crc].len,
+ s3crc[ns3crc].dowrite);
ns3crc++;
- if ( ns3crc == S3CRC_MAX ) {
- printk(KERN_ERR "S3 crcrec limit reached - aborting\n");
+ if (ns3crc == S3CRC_MAX) {
+ printk(KERN_ERR
+ "S3 crcrec limit reached - aborting\n");
return 1;
}
break;
case S3ADDR_INFO:
- memcpy(tmpbuf, buf+S3INFO_LEN_TXTOFFSET, S3INFO_LEN_TXTLEN);
+ memcpy(tmpbuf, buf + S3INFO_LEN_TXTOFFSET,
+ S3INFO_LEN_TXTLEN);
tmpbuf[S3INFO_LEN_TXTLEN] = '\0';
- s3info[ns3info].len = simple_strtoul(tmpbuf,NULL,16);
- s3info[ns3info].len = bswap_16(s3info[ns3info].len);
+ s3info[ns3info].len =
+ simple_strtoul(tmpbuf, NULL, 16);
+ s3info[ns3info].len =
+ bswap_16(s3info[ns3info].len);
- memcpy(tmpbuf, buf+S3INFO_TYPE_TXTOFFSET, S3INFO_TYPE_TXTLEN);
+ memcpy(tmpbuf, buf + S3INFO_TYPE_TXTOFFSET,
+ S3INFO_TYPE_TXTLEN);
tmpbuf[S3INFO_TYPE_TXTLEN] = '\0';
- s3info[ns3info].type = simple_strtoul(tmpbuf,NULL,16);
- s3info[ns3info].type = bswap_16(s3info[ns3info].type);
+ s3info[ns3info].type =
+ simple_strtoul(tmpbuf, NULL, 16);
+ s3info[ns3info].type =
+ bswap_16(s3info[ns3info].type);
pr_debug(" S3 inforec, line=%d "
- "len=0x%04x type=0x%04x\n",
- line,
- s3info[ns3info].len,
- s3info[ns3info].type);
- if ( ((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info) ) {
- printk(KERN_ERR " S3 inforec length too long - aborting\n");
+ "len=0x%04x type=0x%04x\n",
+ line,
+ s3info[ns3info].len,
+ s3info[ns3info].type);
+ if (((s3info[ns3info].len - 1) * sizeof(u16)) >
+ sizeof(s3info[ns3info].info)) {
+ printk(KERN_ERR
+ " S3 inforec length too long - aborting\n");
return 1;
}
- tmpinfo = (u16*)&(s3info[ns3info].info.version);
+ tmpinfo =
+ (u16 *) & (s3info[ns3info].info.version);
for (i = 0; i < s3info[ns3info].len - 1; i++) {
- memcpy( tmpbuf, buf+S3INFO_DATA_TXTOFFSET+(i*4), 4);
+ memcpy(tmpbuf,
+ buf + S3INFO_DATA_TXTOFFSET +
+ (i * 4), 4);
tmpbuf[4] = '\0';
- tmpinfo[i] = simple_strtoul(tmpbuf,NULL,16);
+ tmpinfo[i] =
+ simple_strtoul(tmpbuf, NULL, 16);
tmpinfo[i] = bswap_16(tmpinfo[i]);
}
pr_debug(" info=");
@@ -1098,8 +1099,9 @@ int read_srecfile(char *rfptr, int rfsize)
pr_debug("\n");
ns3info++;
- if ( ns3info == S3INFO_MAX ) {
- printk(KERN_ERR "S3 inforec limit reached - aborting\n");
+ if (ns3info == S3INFO_MAX) {
+ printk(KERN_ERR
+ "S3 inforec limit reached - aborting\n");
return 1;
}
break;
@@ -1107,27 +1109,33 @@ int read_srecfile(char *rfptr, int rfsize)
s3data[ns3data].addr = tmprec.addr;
s3data[ns3data].len = tmprec.len;
s3data[ns3data].checksum = tmprec.checksum;
- s3data[ns3data].data = kmalloc(tmprec.len, GFP_KERNEL);
- for ( i = 0; i < tmprec.len; i++) {
- memcpy(tmpbuf, buf+S3DATA_TXTOFFSET+(i*2), 2);
+ s3data[ns3data].data =
+ kmalloc(tmprec.len, GFP_KERNEL);
+ for (i = 0; i < tmprec.len; i++) {
+ memcpy(tmpbuf,
+ buf + S3DATA_TXTOFFSET + (i * 2),
+ 2);
tmpbuf[2] = '\0';
- s3data[ns3data].data[i] = simple_strtoul(tmpbuf, NULL, 16);
+ s3data[ns3data].data[i] =
+ simple_strtoul(tmpbuf, NULL, 16);
}
ns3data++;
- if ( ns3data == S3DATA_MAX ) {
- printk(KERN_ERR "S3 datarec limit reached - aborting\n");
+ if (ns3data == S3DATA_MAX) {
+ printk(KERN_ERR
+ "S3 datarec limit reached - aborting\n");
return 1;
}
break;
}
} else {
- printk(KERN_WARNING "%d warning: Unknown S-record detected.\n", line);
+ printk(KERN_WARNING
+ "%d warning: Unknown S-record detected.\n",
+ line);
}
}
return result;
}
-
/*----------------------------------------------------------------
* s3datarec_compare
*
@@ -1143,14 +1151,15 @@ int read_srecfile(char *rfptr, int rfsize)
----------------------------------------------------------------*/
int s3datarec_compare(const void *p1, const void *p2)
{
- const s3datarec_t *s1 = p1;
- const s3datarec_t *s2 = p2;
- if ( s1->addr == s2->addr ) return 0;
- if ( s1->addr < s2->addr ) return -1;
+ const s3datarec_t *s1 = p1;
+ const s3datarec_t *s2 = p2;
+ if (s1->addr == s2->addr)
+ return 0;
+ if (s1->addr < s2->addr)
+ return -1;
return 1;
}
-
/*----------------------------------------------------------------
* writeimage
*
@@ -1166,113 +1175,114 @@ int s3datarec_compare(const void *p1, const void *p2)
* 0 success
* ~0 failure
----------------------------------------------------------------*/
-int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, unsigned int nfchunks)
+int writeimage(wlandevice_t * wlandev, imgchunk_t * fchunk,
+ unsigned int nfchunks)
{
- int result = 0;
- p80211msg_p2req_ramdl_state_t rstatemsg;
- p80211msg_p2req_ramdl_write_t rwritemsg;
- p80211msg_t *msgp;
- u32 resultcode;
- int i;
- int j;
- unsigned int nwrites;
- u32 curroff;
- u32 currlen;
- u32 currdaddr;
+ int result = 0;
+ p80211msg_p2req_ramdl_state_t rstatemsg;
+ p80211msg_p2req_ramdl_write_t rwritemsg;
+ p80211msg_t *msgp;
+ u32 resultcode;
+ int i;
+ int j;
+ unsigned int nwrites;
+ u32 curroff;
+ u32 currlen;
+ u32 currdaddr;
/* Initialize the messages */
memset(&rstatemsg, 0, sizeof(rstatemsg));
strcpy(rstatemsg.devname, wlandev->name);
- rstatemsg.msgcode = DIDmsg_p2req_ramdl_state;
- rstatemsg.msglen = sizeof(rstatemsg);
- rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable;
- rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
- rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
- rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok;
- rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok;
- rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
- rstatemsg.enable.len = sizeof(u32);
- rstatemsg.exeaddr.len = sizeof(u32);
- rstatemsg.resultcode.len = sizeof(u32);
+ rstatemsg.msgcode = DIDmsg_p2req_ramdl_state;
+ rstatemsg.msglen = sizeof(rstatemsg);
+ rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable;
+ rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
+ rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
+ rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok;
+ rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok;
+ rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
+ rstatemsg.enable.len = sizeof(u32);
+ rstatemsg.exeaddr.len = sizeof(u32);
+ rstatemsg.resultcode.len = sizeof(u32);
memset(&rwritemsg, 0, sizeof(rwritemsg));
strcpy(rwritemsg.devname, wlandev->name);
- rwritemsg.msgcode = DIDmsg_p2req_ramdl_write;
- rwritemsg.msglen = sizeof(rwritemsg);
- rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr;
- rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len;
- rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data;
- rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
- rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok;
- rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok;
- rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok;
- rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
- rwritemsg.addr.len = sizeof(u32);
- rwritemsg.len.len = sizeof(u32);
- rwritemsg.data.len = WRITESIZE_MAX;
- rwritemsg.resultcode.len = sizeof(u32);
+ rwritemsg.msgcode = DIDmsg_p2req_ramdl_write;
+ rwritemsg.msglen = sizeof(rwritemsg);
+ rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr;
+ rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len;
+ rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data;
+ rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
+ rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok;
+ rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok;
+ rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok;
+ rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
+ rwritemsg.addr.len = sizeof(u32);
+ rwritemsg.len.len = sizeof(u32);
+ rwritemsg.data.len = WRITESIZE_MAX;
+ rwritemsg.resultcode.len = sizeof(u32);
/* Send xxx_state(enable) */
pr_debug("Sending dl_state(enable) message.\n");
rstatemsg.enable.data = P80211ENUM_truth_true;
rstatemsg.exeaddr.data = startaddr;
- msgp = (p80211msg_t*)&rstatemsg;
+ msgp = (p80211msg_t *) & rstatemsg;
result = prism2mgmt_ramdl_state(wlandev, msgp);
- if ( result ) {
+ if (result) {
printk(KERN_ERR
- "writeimage state enable failed w/ result=%d, "
- "aborting download\n", result);
+ "writeimage state enable failed w/ result=%d, "
+ "aborting download\n", result);
return result;
}
resultcode = rstatemsg.resultcode.data;
- if ( resultcode != P80211ENUM_resultcode_success ) {
+ if (resultcode != P80211ENUM_resultcode_success) {
printk(KERN_ERR
- "writeimage()->xxxdl_state msg indicates failure, "
- "w/ resultcode=%d, aborting download.\n",
- resultcode);
+ "writeimage()->xxxdl_state msg indicates failure, "
+ "w/ resultcode=%d, aborting download.\n", resultcode);
return 1;
}
/* Now, loop through the data chunks and send WRITESIZE_MAX data */
- for ( i = 0; i < nfchunks; i++) {
+ for (i = 0; i < nfchunks; i++) {
nwrites = fchunk[i].len / WRITESIZE_MAX;
nwrites += (fchunk[i].len % WRITESIZE_MAX) ? 1 : 0;
curroff = 0;
- for ( j = 0; j < nwrites; j++) {
+ for (j = 0; j < nwrites; j++) {
currlen =
- (fchunk[i].len - (WRITESIZE_MAX * j)) > WRITESIZE_MAX ?
- WRITESIZE_MAX :
- (fchunk[i].len - (WRITESIZE_MAX * j));
+ (fchunk[i].len - (WRITESIZE_MAX * j)) >
+ WRITESIZE_MAX ? WRITESIZE_MAX : (fchunk[i].len -
+ (WRITESIZE_MAX *
+ j));
curroff = j * WRITESIZE_MAX;
currdaddr = fchunk[i].addr + curroff;
/* Setup the message */
rwritemsg.addr.data = currdaddr;
rwritemsg.len.data = currlen;
memcpy(rwritemsg.data.data,
- fchunk[i].data + curroff,
- currlen);
+ fchunk[i].data + curroff, currlen);
/* Send flashdl_write(pda) */
- pr_debug("Sending xxxdl_write message addr=%06x len=%d.\n",
- currdaddr, currlen);
+ pr_debug
+ ("Sending xxxdl_write message addr=%06x len=%d.\n",
+ currdaddr, currlen);
- msgp = (p80211msg_t*)&rwritemsg;
+ msgp = (p80211msg_t *) & rwritemsg;
result = prism2mgmt_ramdl_write(wlandev, msgp);
/* Check the results */
- if ( result ) {
+ if (result) {
printk(KERN_ERR
- "writeimage chunk write failed w/ result=%d, "
- "aborting download\n", result);
+ "writeimage chunk write failed w/ result=%d, "
+ "aborting download\n", result);
return result;
}
resultcode = rstatemsg.resultcode.data;
- if ( resultcode != P80211ENUM_resultcode_success ) {
+ if (resultcode != P80211ENUM_resultcode_success) {
printk(KERN_ERR
- "writeimage()->xxxdl_write msg indicates failure, "
- "w/ resultcode=%d, aborting download.\n",
- resultcode);
+ "writeimage()->xxxdl_write msg indicates failure, "
+ "w/ resultcode=%d, aborting download.\n",
+ resultcode);
return 1;
}
@@ -1284,69 +1294,54 @@ int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, unsigned int nfchunks)
rstatemsg.enable.data = P80211ENUM_truth_false;
rstatemsg.exeaddr.data = 0;
- msgp = (p80211msg_t*)&rstatemsg;
+ msgp = (p80211msg_t *) & rstatemsg;
result = prism2mgmt_ramdl_state(wlandev, msgp);
- if ( result ) {
+ if (result) {
printk(KERN_ERR
- "writeimage state disable failed w/ result=%d, "
- "aborting download\n", result);
+ "writeimage state disable failed w/ result=%d, "
+ "aborting download\n", result);
return result;
}
resultcode = rstatemsg.resultcode.data;
- if ( resultcode != P80211ENUM_resultcode_success ) {
+ if (resultcode != P80211ENUM_resultcode_success) {
printk(KERN_ERR
- "writeimage()->xxxdl_state msg indicates failure, "
- "w/ resultcode=%d, aborting download.\n",
- resultcode);
+ "writeimage()->xxxdl_state msg indicates failure, "
+ "w/ resultcode=%d, aborting download.\n", resultcode);
return 1;
}
return result;
}
-
-
int validate_identity(void)
{
int i;
int result = 1;
pr_debug("NIC ID: %#x v%d.%d.%d\n",
- nicid.id,
- nicid.major,
- nicid.minor,
- nicid.variant);
+ nicid.id, nicid.major, nicid.minor, nicid.variant);
pr_debug("MFI ID: %#x v%d %d->%d\n",
- rfid.id,
- rfid.variant,
- rfid.bottom,
- rfid.top);
+ rfid.id, rfid.variant, rfid.bottom, rfid.top);
pr_debug("CFI ID: %#x v%d %d->%d\n",
- macid.id,
- macid.variant,
- macid.bottom,
- macid.top);
+ macid.id, macid.variant, macid.bottom, macid.top);
pr_debug("PRI ID: %#x v%d %d->%d\n",
- priid.id,
- priid.variant,
- priid.bottom,
- priid.top);
+ priid.id, priid.variant, priid.bottom, priid.top);
- for (i = 0 ; i < ns3info ; i ++) {
+ for (i = 0; i < ns3info; i++) {
switch (s3info[i].type) {
case 1:
pr_debug("Version: ID %#x %d.%d.%d\n",
- s3info[i].info.version.id,
- s3info[i].info.version.major,
- s3info[i].info.version.minor,
- s3info[i].info.version.variant);
+ s3info[i].info.version.id,
+ s3info[i].info.version.major,
+ s3info[i].info.version.minor,
+ s3info[i].info.version.variant);
break;
case 2:
pr_debug("Compat: Role %#x Id %#x v%d %d->%d\n",
- s3info[i].info.compat.role,
- s3info[i].info.compat.id,
- s3info[i].info.compat.variant,
- s3info[i].info.compat.bottom,
- s3info[i].info.compat.top);
+ s3info[i].info.compat.role,
+ s3info[i].info.compat.id,
+ s3info[i].info.compat.variant,
+ s3info[i].info.compat.bottom,
+ s3info[i].info.compat.top);
/* MAC compat range */
if ((s3info[i].info.compat.role == 1) &&
@@ -1360,8 +1355,9 @@ int validate_identity(void)
/* PRI compat range */
if ((s3info[i].info.compat.role == 1) &&
(s3info[i].info.compat.id == 3)) {
- if ((s3info[i].info.compat.bottom > priid.top) ||
- (s3info[i].info.compat.top < priid.bottom)){
+ if ((s3info[i].info.compat.bottom > priid.top)
+ || (s3info[i].info.compat.top <
+ priid.bottom)) {
result = 3;
}
}
@@ -1373,15 +1369,15 @@ int validate_identity(void)
break;
case 3:
- pr_debug("Seq: %#x\n", s3info[i].info.buildseq);
+ pr_debug("Seq: %#x\n", s3info[i].info.buildseq);
- break;
+ break;
case 4:
pr_debug("Platform: ID %#x %d.%d.%d\n",
- s3info[i].info.version.id,
- s3info[i].info.version.major,
- s3info[i].info.version.minor,
- s3info[i].info.version.variant);
+ s3info[i].info.version.id,
+ s3info[i].info.version.major,
+ s3info[i].info.version.minor,
+ s3info[i].info.version.variant);
if (nicid.id != s3info[i].info.version.id)
continue;