patch-2.4.7 linux/drivers/net/sk98lin/skvpd.c
Next file: linux/drivers/net/sk98lin/skxmac2.c
Previous file: linux/drivers/net/sk98lin/sktimer.c
Back to the patch index
Back to the overall index
- Lines: 1183
- Date:
Wed Jul 4 11:50:39 2001
- Orig file:
v2.4.6/linux/drivers/net/sk98lin/skvpd.c
- Orig date:
Fri Sep 15 14:34:19 2000
diff -u --recursive --new-file v2.4.6/linux/drivers/net/sk98lin/skvpd.c linux/drivers/net/sk98lin/skvpd.c
@@ -2,15 +2,15 @@
*
* Name: skvpd.c
* Project: GEnesis, PCI Gigabit Ethernet Adapter
- * Version: $Revision: 1.27 $
- * Date: $Date: 2000/08/10 11:29:06 $
+ * Version: $Revision: 1.26 $
+ * Date: $Date: 2000/06/13 08:00:01 $
* Purpose: Shared software to read and write VPD data
*
******************************************************************************/
/******************************************************************************
*
- * (C)Copyright 1998-2000 SysKonnect,
+ * (C)Copyright 1998,1999 SysKonnect,
* a business unit of Schneider & Koch & Co. Datensysteme GmbH.
*
* This program is free software; you can redistribute it and/or modify
@@ -27,12 +27,6 @@
* History:
*
* $Log: skvpd.c,v $
- * Revision 1.27 2000/08/10 11:29:06 rassmann
- * Editorial changes.
- * Preserving 32-bit alignment in structs for the adapter context.
- * Removed unused function VpdWriteDword() (#if 0).
- * Made VpdReadKeyword() available for SKDIAG only.
- *
* Revision 1.26 2000/06/13 08:00:01 mkarl
* additional cast to avoid compile problems in 64 bit environment
*
@@ -72,7 +66,7 @@
*
* Revision 1.14 1998/10/28 07:20:38 gklug
* chg: Interface functions to use IoC as parameter as well
- * fix: VpdRead/WriteDWord now returns SK_U32
+ * fix: VpdRead/WriteDWord now return SK_U32
* chg: VPD_IN/OUT names conform to SK_IN/OUT
* add: usage of VPD_IN/OUT8 macros
* add: VpdRead/Write Stream functions to r/w a stream of data
@@ -130,7 +124,7 @@
Please refer skvpd.txt for infomation how to include this module
*/
static const char SysKonnectFileId[] =
- "@(#)$Id: skvpd.c,v 1.27 2000/08/10 11:29:06 rassmann Exp $ (C) SK";
+ "@(#)$Id: skvpd.c,v 1.26 2000/06/13 08:00:01 mkarl Exp $ (C) SK" ;
#include "h/skdrv1st.h"
#include "h/sktypes.h"
@@ -144,9 +138,9 @@
static SK_VPD_PARA *vpd_find_para(
SK_AC *pAC,
char *key,
- SK_VPD_PARA *p);
+ SK_VPD_PARA *p) ;
#else /* SK_KR_PROTO */
-static SK_VPD_PARA *vpd_find_para();
+static SK_VPD_PARA *vpd_find_para() ;
#endif /* SK_KR_PROTO */
/*
@@ -161,29 +155,28 @@
SK_IOC IoC, /* IO Context */
int event) /* event to wait for (VPD_READ / VPD_write) completion*/
{
- SK_U64 start_time;
- SK_U16 state;
+ SK_U64 start_time ;
+ SK_U16 state ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("vpd wait for %s\n",event?"Write":"Read"));
- start_time = SkOsGetTime(pAC);
+ ("vpd wait for %s\n",event?"Write":"Read")) ;
+ start_time = SkOsGetTime(pAC) ;
do {
if (SkOsGetTime(pAC) - start_time > SK_TICKS_PER_SEC/16) {
- VPD_STOP(pAC,IoC);
+ VPD_STOP(pAC,IoC) ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,
SK_DBGCAT_FATAL|SK_DBGCAT_ERR,
- ("ERROR:vpd wait timeout\n"));
- return(1);
+ ("ERROR:vpd wait timeout\n")) ;
+ return(1) ;
}
- VPD_IN16(pAC,IoC,PCI_VPD_ADR_REG,&state);
+ VPD_IN16(pAC,IoC,PCI_VPD_ADR_REG,&state) ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("state = %x, event %x\n",state,event));
- } while((int)(state & PCI_VPD_FLAG) == event);
+ ("state = %x, event %x\n",state,event)) ;
+ } while((int)(state & PCI_VPD_FLAG) == event) ;
- return(0);
+ return(0) ;
}
-#ifdef SKDIAG
/*
* Read the dword at address 'addr' from the VPD EEPROM.
@@ -200,31 +193,27 @@
SK_IOC IoC, /* IO Context */
int addr) /* VPD address */
{
- SK_U32 Rtv;
+ SK_U32 Rtv ;
/* start VPD read */
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("vpd read dword at 0x%x\n",addr));
- addr &= ~VPD_WRITE; /* ensure the R/W bit is set to read */
+ ("vpd read dword at 0x%x\n",addr)) ;
+ addr &= ~VPD_WRITE ; /* ensure the R/W bit is set to read */
- VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16) addr);
+ VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16) addr) ;
/* ignore return code here */
- (void)VpdWait(pAC,IoC,VPD_READ);
+ (void)VpdWait(pAC,IoC,VPD_READ) ;
/* Don't swap here, it's a data stream of bytes */
- Rtv = 0;
+ Rtv = 0 ;
- VPD_IN32(pAC,IoC,PCI_VPD_DAT_REG,&Rtv);
+ VPD_IN32(pAC,IoC,PCI_VPD_DAT_REG,&Rtv) ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("vpd read dword data = 0x%x\n",Rtv));
- return (Rtv);
+ ("vpd read dword data = 0x%x\n",Rtv)) ;
+ return (Rtv) ;
}
-#endif // SKDIAG
-
-#if 0
-
/*
Write the dword 'data' at address 'addr' into the VPD EEPROM, and
verify that the data is written.
@@ -244,8 +233,8 @@
Returns 0: success
- 1: error, I2C transfer does not terminate
- 2: error, data verify error
+ 1: error, I2C transfer does not terminate
+ 2: error, data verify error
*/
static int VpdWriteDWord(
@@ -257,30 +246,28 @@
/* start VPD write */
/* Don't swap here, it's a data stream of bytes */
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("vpd write dword at addr 0x%x, data = 0x%x\n",addr,data));
- VPD_OUT32(pAC,IoC,PCI_VPD_DAT_REG, (SK_U32)data);
+ ("vpd write dword at addr 0x%x, data = 0x%x\n",addr,data)) ;
+ VPD_OUT32(pAC,IoC,PCI_VPD_DAT_REG, (SK_U32)data) ;
/* But do it here */
- addr |= VPD_WRITE;
+ addr |= VPD_WRITE ;
- VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16)(addr | VPD_WRITE));
+ VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, (SK_U16)(addr | VPD_WRITE)) ;
/* this may take up to 10,6 ms */
if (VpdWait(pAC,IoC,VPD_WRITE)) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("Write Timed Out\n"));
- return(1);
- };
+ ("Write Timed Out\n")) ;
+ return(1) ;
+ } ;
/* verify data */
if (VpdReadDWord(pAC,IoC,addr) != data) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR|SK_DBGCAT_FATAL,
- ("Data Verify Error\n"));
- return(2);
+ ("Data Verify Error\n")) ;
+ return(2) ;
}
- return(0);
-} /* VpdWriteDWord */
-
-#endif /* 0 */
+ return(0) ;
+}
/*
* Read one Stream of 'len' bytes of VPD data, starting at 'addr' from
@@ -295,12 +282,12 @@
int Addr, /* VPD start address */
int Len) /* number of bytes to read / to write */
{
- int i;
- int j;
- SK_U16 AdrReg;
- int Rtv;
+ int i ;
+ int j ;
+ SK_U16 AdrReg ;
+ int Rtv ;
SK_U8 * pComp; /* Compare pointer */
- SK_U8 Data; /* Input Data for Compare */
+ SK_U8 Data ; /* Input Data for Compare */
/* Init Compare Pointer */
pComp = (SK_U8 *) buf;
@@ -312,56 +299,56 @@
* So it is initialized even if only a few bytes
* are written.
*/
- AdrReg = (SK_U16) Addr;
- AdrReg &= ~VPD_WRITE; /* READ operation */
+ AdrReg = (SK_U16) Addr ;
+ AdrReg &= ~VPD_WRITE ; /* READ operation */
- VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg);
+ VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ;
/* ignore return code here */
- Rtv = VpdWait(pAC,IoC,VPD_READ);
+ Rtv = VpdWait(pAC,IoC,VPD_READ) ;
if (Rtv != 0) {
- return(i);
+ return(i) ;
}
}
/* Write current Byte */
VPD_OUT8(pAC,IoC,PCI_VPD_DAT_REG+(i%sizeof(SK_U32)),
- *(SK_U8*)buf);
+ *(SK_U8*)buf) ;
if (((i%sizeof(SK_U32)) == 3) || (i == (Len - 1))) {
/* New Address needs to be written to VPD_ADDR reg */
- AdrReg = (SK_U16) Addr;
+ AdrReg = (SK_U16) Addr ;
Addr += sizeof(SK_U32);
- AdrReg |= VPD_WRITE; /* WRITE operation */
+ AdrReg |= VPD_WRITE ; /* WRITE operation */
- VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg);
+ VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ;
/* Wait for termination */
- Rtv = VpdWait(pAC,IoC,VPD_WRITE);
+ Rtv = VpdWait(pAC,IoC,VPD_WRITE) ;
if (Rtv != 0) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("Write Timed Out\n"));
- return(i - (i%sizeof(SK_U32)));
+ ("Write Timed Out\n")) ;
+ return(i - (i%sizeof(SK_U32))) ;
}
/*
* Now re-read to verify
*/
- AdrReg &= ~VPD_WRITE; /* READ operation */
+ AdrReg &= ~VPD_WRITE ; /* READ operation */
- VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg);
+ VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ;
/* Wait for termination */
- Rtv = VpdWait(pAC,IoC,VPD_READ);
+ Rtv = VpdWait(pAC,IoC,VPD_READ) ;
if (Rtv != 0) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("Verify Timed Out\n"));
- return(i - (i%sizeof(SK_U32)));
+ ("Verify Timed Out\n")) ;
+ return(i - (i%sizeof(SK_U32))) ;
}
for (j = 0; j <= (int) (i%sizeof(SK_U32));
j ++, pComp ++ ) {
- VPD_IN8(pAC,IoC,PCI_VPD_DAT_REG+j, &Data);
+ VPD_IN8(pAC,IoC,PCI_VPD_DAT_REG+j, &Data) ;
if (Data != *pComp) {
/* Verify Error */
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,
@@ -391,31 +378,31 @@
int Addr, /* VPD start address */
int Len) /* number of bytes to read / to write */
{
- int i;
- SK_U16 AdrReg;
- int Rtv;
+ int i ;
+ SK_U16 AdrReg ;
+ int Rtv ;
for (i=0; i < Len; i ++, buf++) {
if ((i%sizeof(SK_U32)) == 0) {
/* New Address needs to be written to VPD_ADDR reg */
- AdrReg = (SK_U16) Addr;
+ AdrReg = (SK_U16) Addr ;
Addr += sizeof(SK_U32);
- AdrReg &= ~VPD_WRITE; /* READ operation */
+ AdrReg &= ~VPD_WRITE ; /* READ operation */
- VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg);
+ VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG, AdrReg) ;
/* ignore return code here */
- Rtv = VpdWait(pAC,IoC,VPD_READ);
+ Rtv = VpdWait(pAC,IoC,VPD_READ) ;
if (Rtv != 0) {
- return(i);
+ return(i) ;
}
}
VPD_IN8(pAC,IoC,PCI_VPD_DAT_REG+(i%sizeof(SK_U32)),
- (SK_U8 *)buf);
+ (SK_U8 *)buf) ;
}
- return(Len);
+ return(Len) ;
}
/*
@@ -432,29 +419,29 @@
int len, /* number of bytes to read / to write */
int dir) /* transfer direction may be VPD_READ or VPD_WRITE */
{
- int Rtv; /* Return value */
- int vpd_rom_size;
- SK_U32 our_reg2;
+ int Rtv ; /* Return value */
+ int vpd_rom_size ;
+ SK_U32 our_reg2 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
("vpd %s block, addr = 0x%x, len = %d\n",
- dir?"write":"read",addr,len));
+ dir?"write":"read",addr,len)) ;
if (len == 0)
- return (0);
+ return (0) ;
- VPD_IN32(pAC,IoC,PCI_OUR_REG_2,&our_reg2);
+ VPD_IN32(pAC,IoC,PCI_OUR_REG_2,&our_reg2) ;
vpd_rom_size = 256 << ((our_reg2 & PCI_VPD_ROM_SZ) >> 14);
if (addr > vpd_rom_size - 4) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR|SK_DBGCAT_FATAL,
("Address error: 0x%x, exp. < 0x%x\n",
- addr, vpd_rom_size - 4));
- return (0);
+ addr, vpd_rom_size - 4)) ;
+ return (0) ;
}
if (addr + len > vpd_rom_size) {
- len = vpd_rom_size - addr;
+ len = vpd_rom_size - addr ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("Warning: len was cut to %d\n",len));
+ ("Warning: len was cut to %d\n",len)) ;
}
if (dir == VPD_READ) {
@@ -463,7 +450,7 @@
Rtv = VpdWriteStream(pAC, IoC, buf, addr, len);
}
- return (Rtv);
+ return (Rtv) ;
}
#ifdef SKDIAG
@@ -480,7 +467,7 @@
int addr, /* start reading at the VPD address */
int len) /* number of bytes to read */
{
- return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_READ));
+ return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_READ)) ;
}
/*
@@ -495,7 +482,7 @@
int addr, /* start writing at the VPD address */
int len) /* number of bytes to write */
{
- return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_WRITE));
+ return (VpdTransferBlock(pAC, IoC, buf, addr, len, VPD_WRITE)) ;
}
#endif /* SKDIAG */
@@ -512,64 +499,64 @@
SK_AC *pAC, /* Adapters context */
SK_IOC IoC) /* IO Context */
{
- SK_VPD_PARA *r, rp; /* RW or RV */
- int i;
- unsigned char x;
+ SK_VPD_PARA *r, rp ; /* RW or RV */
+ int i ;
+ unsigned char x ;
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_INIT,("VpdInit .. "));
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_INIT,("VpdInit .. ")) ;
/* read the VPD data into the VPD buffer */
if (VpdTransferBlock(pAC,IoC,pAC->vpd.vpd_buf,0,VPD_SIZE,VPD_READ)
!= VPD_SIZE) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("Block Read Error\n"));
- return(1);
+ ("Block Read Error\n")) ;
+ return(1) ;
}
/* find the end tag of the RO area */
if (!(r = vpd_find_para(pAC,VPD_RV,&rp))) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("Encoding Error: RV Tag not found\n"));
- return (1);
+ ("Encoding Error: RV Tag not found\n")) ;
+ return (1) ;
}
if (r->p_val + r->p_len > pAC->vpd.vpd_buf + VPD_SIZE/2) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("Encoding Error: Invalid VPD struct size\n"));
- return (1);
+ ("Encoding Error: Invalid VPD struct size\n")) ;
+ return (1) ;
}
- pAC->vpd.v.vpd_free_ro = r->p_len - 1;
+ pAC->vpd.v.vpd_free_ro = r->p_len - 1 ;
/* test the checksum */
for (i = 0, x = 0; (unsigned)i<=(unsigned)VPD_SIZE/2 - r->p_len; i++) {
- x += pAC->vpd.vpd_buf[i];
+ x += pAC->vpd.vpd_buf[i] ;
}
if (x != 0) {
/* checksum error */
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("VPD Checksum Error\n"));
- return (1);
+ ("VPD Checksum Error\n")) ;
+ return (1) ;
}
/* find and check the end tag of the RW area */
if (!(r = vpd_find_para(pAC,VPD_RW,&rp))) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("Encoding Error: RV Tag not found\n"));
- return (1);
+ ("Encoding Error: RV Tag not found\n")) ;
+ return (1) ;
}
if (r->p_val < pAC->vpd.vpd_buf + VPD_SIZE/2) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("Encoding Error: Invalid VPD struct size\n"));
- return (1);
+ ("Encoding Error: Invalid VPD struct size\n")) ;
+ return (1) ;
}
- pAC->vpd.v.vpd_free_rw = r->p_len;
+ pAC->vpd.v.vpd_free_rw = r->p_len ;
/* everything seems to be ok */
- pAC->vpd.v.vpd_status |= VPD_VALID;
+ pAC->vpd.v.vpd_status |= VPD_VALID ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_INIT,
("done. Free RO = %d, Free RW = %d\n",
- pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw));
+ pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw)) ;
- return(0);
+ return(0) ;
}
/*
@@ -585,62 +572,62 @@
SK_VPD_PARA *p) /* parameter description struct */
{
char *v ; /* points to vpd buffer */
- int max; /* Maximum Number of Iterations */
+ int max ; /* Maximum Number of Iterations */
- v = pAC->vpd.vpd_buf;
- max = 128;
+ v = pAC->vpd.vpd_buf ;
+ max = 128 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("vpd find para %s .. ",key));
+ ("vpd find para %s .. ",key)) ;
/* check mandatory resource type ID string (Product Name) */
if (*v != (char) RES_ID) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("Error: 0x%x missing\n",RES_ID));
- return (0);
+ ("Error: 0x%x missing\n",RES_ID)) ;
+ return (0) ;
}
if (strcmp(key,VPD_NAME) == 0) {
- p->p_len = VPD_GET_RES_LEN(v);
- p->p_val = VPD_GET_VAL(v);
+ p->p_len = VPD_GET_RES_LEN(v) ;
+ p->p_val = VPD_GET_VAL(v) ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("found, len = %d\n",p->p_len));
- return(p);
+ ("found, len = %d\n",p->p_len)) ;
+ return(p) ;
}
- v += 3 + VPD_GET_RES_LEN(v) + 3;
- for (;; ) {
+ v += 3 + VPD_GET_RES_LEN(v) + 3 ;
+ for ( ; ; ) {
if (SK_MEMCMP(key,v,2) == 0) {
- p->p_len = VPD_GET_VPD_LEN(v);
- p->p_val = VPD_GET_VAL(v);
+ p->p_len = VPD_GET_VPD_LEN(v) ;
+ p->p_val = VPD_GET_VAL(v) ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("found, len = %d\n",p->p_len));
- return (p);
+ ("found, len = %d\n",p->p_len)) ;
+ return (p) ;
}
/* exit when reaching the "RW" Tag or the maximum of itera. */
- max--;
+ max-- ;
if (SK_MEMCMP(VPD_RW,v,2) == 0 || max == 0) {
- break;
+ break ;
}
if (SK_MEMCMP(VPD_RV,v,2) == 0) {
- v += 3 + VPD_GET_VPD_LEN(v) + 3; /* skip VPD-W */
+ v += 3 + VPD_GET_VPD_LEN(v) + 3 ; /* skip VPD-W */
} else {
- v += 3 + VPD_GET_VPD_LEN(v);
+ v += 3 + VPD_GET_VPD_LEN(v) ;
}
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("scanning '%c%c' len = %d\n",v[0],v[1],v[2]));
+ ("scanning '%c%c' len = %d\n",v[0],v[1],v[2])) ;
}
#ifdef DEBUG
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,("not found\n"));
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,("not found\n")) ;
if (max == 0) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("Key/Len Encoding error\n"));
+ ("Key/Len Encoding error\n")) ;
}
#endif
- return (0);
+ return (0) ;
}
/*
@@ -654,24 +641,24 @@
char *end, /* end of memory block to move */
int n) /* number of bytes the memory block has to be moved */
{
- char *p;
- int i; /* number of byte copied */
+ char *p ;
+ int i ; /* number of byte copied */
if (n == 0)
- return;
+ return ;
- i = (int) (end - start + 1);
+ i = (int) (end - start + 1) ;
if (n < 0) {
- p = start + n;
+ p = start + n ;
while (i != 0) {
- *p++ = *start++;
- i--;
+ *p++ = *start++ ;
+ i-- ;
}
} else {
- p = end + n;
+ p = end + n ;
while (i != 0) {
- *p-- = *end--;
- i--;
+ *p-- = *end-- ;
+ i-- ;
}
}
}
@@ -687,13 +674,13 @@
int len, /* length of the value string */
char *ip) /* inseration point */
{
- SK_VPD_KEY *p;
+ SK_VPD_KEY *p ;
- p = (SK_VPD_KEY *) ip;
- p->p_key[0] = key[0];
- p->p_key[1] = key[1];
- p->p_len = (unsigned char) len;
- SK_MEMCPY(&p->p_val,buf,len);
+ p = (SK_VPD_KEY *) ip ;
+ p->p_key[0] = key[0] ;
+ p->p_key[1] = key[1] ;
+ p->p_len = (unsigned char) len ;
+ SK_MEMCPY(&p->p_val,buf,len) ;
}
/*
@@ -707,46 +694,46 @@
SK_AC *pAC, /* common data base */
char *etp) /* end pointer input position */
{
- SK_VPD_KEY *p;
- unsigned char x;
- int i;
+ SK_VPD_KEY *p ;
+ unsigned char x ;
+ int i ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("vpd modify endtag at 0x%x = '%c%c'\n",etp,etp[0],etp[1]));
+ ("vpd modify endtag at 0x%x = '%c%c'\n",etp,etp[0],etp[1])) ;
- p = (SK_VPD_KEY *) etp;
+ p = (SK_VPD_KEY *) etp ;
if (p->p_key[0] != 'R' || (p->p_key[1] != 'V' && p->p_key[1] != 'W')) {
/* something wrong here, encoding error */
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR | SK_DBGCAT_FATAL,
- ("Encoding Error: invalid end tag\n"));
- return(1);
+ ("Encoding Error: invalid end tag\n")) ;
+ return(1) ;
}
if (etp > pAC->vpd.vpd_buf + VPD_SIZE/2) {
/* create "RW" tag */
- p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE-etp-3-1);
- pAC->vpd.v.vpd_free_rw = (int) p->p_len;
- i = pAC->vpd.v.vpd_free_rw;
- etp += 3;
+ p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE-etp-3-1) ;
+ pAC->vpd.v.vpd_free_rw = (int) p->p_len ;
+ i = pAC->vpd.v.vpd_free_rw ;
+ etp += 3 ;
} else {
/* create "RV" tag */
- p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE/2-etp-3);
- pAC->vpd.v.vpd_free_ro = (int) p->p_len - 1;
+ p->p_len = (unsigned char)(pAC->vpd.vpd_buf+VPD_SIZE/2-etp-3) ;
+ pAC->vpd.v.vpd_free_ro = (int) p->p_len - 1 ;
/* setup checksum */
for (i = 0, x = 0; i < VPD_SIZE/2 - p->p_len; i++) {
- x += pAC->vpd.vpd_buf[i];
+ x += pAC->vpd.vpd_buf[i] ;
}
- p->p_val = (char) 0 - x;
- i = pAC->vpd.v.vpd_free_ro;
- etp += 4;
+ p->p_val = (char) 0 - x ;
+ i = pAC->vpd.v.vpd_free_ro ;
+ etp += 4 ;
}
while (i) {
- *etp++ = 0x00;
- i--;
+ *etp++ = 0x00 ;
+ i-- ;
}
- return (0);
+ return (0) ;
}
/*
@@ -771,76 +758,76 @@
int type, /* VPD_RO_KEY or VPD_RW_KEY */
int op) /* operation to do: ADD_KEY or OWR_KEY */
{
- SK_VPD_PARA vp;
- char *etp; /* end tag position */
- int free; /* remaining space in selected area */
- char *ip; /* input position inside the VPD buffer */
- int rtv; /* return code */
- int head; /* additional haeder bytes to move */
- int found; /* additinoal bytes if the keyword was found */
+ SK_VPD_PARA vp ;
+ char *etp ; /* end tag position */
+ int free ; /* remaining space in selected area */
+ char *ip ; /* input position inside the VPD buffer */
+ int rtv ; /* return code */
+ int head ; /* additional haeder bytes to move */
+ int found ; /* additinoal bytes if the keyword was found */
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("vpd setup para key = %s, val = %s\n",key,buf));
+ ("vpd setup para key = %s, val = %s\n",key,buf)) ;
- rtv = 0;
- ip = 0;
+ rtv = 0 ;
+ ip = 0 ;
if (type == VPD_RW_KEY) {
/* end tag is "RW" */
- free = pAC->vpd.v.vpd_free_rw;
- etp = pAC->vpd.vpd_buf + (VPD_SIZE - free - 1 - 3);
+ free = pAC->vpd.v.vpd_free_rw ;
+ etp = pAC->vpd.vpd_buf + (VPD_SIZE - free - 1 - 3) ;
} else {
/* end tag is "RV" */
- free = pAC->vpd.v.vpd_free_ro;
- etp = pAC->vpd.vpd_buf + (VPD_SIZE/2 - free - 4);
+ free = pAC->vpd.v.vpd_free_ro ;
+ etp = pAC->vpd.vpd_buf + (VPD_SIZE/2 - free - 4) ;
}
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
("Free RO = %d, Free RW = %d\n",
- pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw));
+ pAC->vpd.v.vpd_free_ro, pAC->vpd.v.vpd_free_rw)) ;
- head = 0;
- found = 0;
+ head = 0 ;
+ found = 0 ;
if (op == OWR_KEY) {
if (vpd_find_para(pAC,key,&vp)) {
- found = 3;
- ip = vp.p_val - 3;
- free += vp.p_len + 3;
+ found = 3 ;
+ ip = vp.p_val - 3 ;
+ free += vp.p_len + 3 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("Overwrite Key\n"));
+ ("Overwrite Key\n")) ;
} else {
- op = ADD_KEY;
+ op = ADD_KEY ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_CTRL,
- ("Add Key\n"));
+ ("Add Key\n")) ;
}
}
if (op == ADD_KEY) {
- ip = etp;
- vp.p_len = 0;
- head = 3;
+ ip = etp ;
+ vp.p_len = 0 ;
+ head = 3 ;
}
if (len + 3 > free) {
if (free < 7) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
("VPD Buffer Overflow, keyword not written\n"));
- return (4);
+ return (4) ;
}
/* cut it again */
- len = free - 3;
- rtv = 2;
+ len = free - 3 ;
+ rtv = 2 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("VPD Buffer Full, Keyword was cut\n"));
+ ("VPD Buffer Full, Keyword was cut\n")) ;
}
- vpd_move_para(ip + vp.p_len + found, etp+2, len-vp.p_len+head);
- vpd_insert_key(key, buf, len, ip);
+ vpd_move_para(ip + vp.p_len + found, etp+2, len-vp.p_len+head) ;
+ vpd_insert_key(key, buf, len, ip) ;
if (vpd_mod_endtag(pAC, etp + len - vp.p_len + head)) {
- pAC->vpd.v.vpd_status &= ~VPD_VALID;
+ pAC->vpd.v.vpd_status &= ~VPD_VALID ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("VPD Encoding Error\n"));
- return(6);
+ ("VPD Encoding Error\n")) ;
+ return(6) ;
}
- return (rtv);
+ return (rtv) ;
}
@@ -848,7 +835,7 @@
* Read the contents of the VPD EEPROM and copy it to the
* VPD buffer if not already done.
*
- * return: A pointer to the vpd_status structure. The structure contains
+ * return: A pointer to the vpd_status structure. The structure contain
* this fields.
*/
SK_VPD_STATUS *VpdStat(
@@ -856,9 +843,9 @@
SK_IOC IoC) /* IO Context */
{
if (!(pAC->vpd.v.vpd_status & VPD_VALID)) {
- (void)VpdInit(pAC,IoC);
+ (void)VpdInit(pAC,IoC) ;
}
- return(&pAC->vpd.v);
+ return(&pAC->vpd.v) ;
}
@@ -891,67 +878,67 @@
int *len, /* buffer length */
int *elements) /* number of keywords returned */
{
- char *v;
- int n;
+ char *v ;
+ int n ;
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("list vpd keys .. "));
- *elements = 0;
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("list vpd keys .. ")) ;
+ *elements = 0 ;
if (!(pAC->vpd.v.vpd_status & VPD_VALID)) {
if (VpdInit(pAC,IoC) != 0 ) {
- *len = 0;
+ *len = 0 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("VPD Init Error, terminated\n"));
- return(6);
+ ("VPD Init Error, terminated\n")) ;
+ return(6) ;
}
}
if ((signed)strlen(VPD_NAME) + 1 <= *len) {
- v = pAC->vpd.vpd_buf;
- strcpy(buf,VPD_NAME);
- n = strlen(VPD_NAME) + 1;
- buf += n;
- *elements = 1;
+ v = pAC->vpd.vpd_buf ;
+ strcpy(buf,VPD_NAME) ;
+ n = strlen(VPD_NAME) + 1 ;
+ buf += n ;
+ *elements = 1 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,
- ("'%c%c' ",v[0],v[1]));
+ ("'%c%c' ",v[0],v[1])) ;
} else {
- *len = 0;
+ *len = 0 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("buffer overflow\n"));
- return(2);
+ ("buffer overflow\n")) ;
+ return(2) ;
}
- v += 3 + VPD_GET_RES_LEN(v) + 3;
- for (;; ) {
+ v += 3 + VPD_GET_RES_LEN(v) + 3 ;
+ for ( ; ; ) {
/* exit when reaching the "RW" Tag */
if (SK_MEMCMP(VPD_RW,v,2) == 0) {
- break;
+ break ;
}
if (SK_MEMCMP(VPD_RV,v,2) == 0) {
- v += 3 + VPD_GET_VPD_LEN(v) + 3; /* skip VPD-W */
- continue;
+ v += 3 + VPD_GET_VPD_LEN(v) + 3 ; /* skip VPD-W */
+ continue ;
}
if (n+3 <= *len) {
- SK_MEMCPY(buf,v,2);
- buf += 2;
- *buf++ = '\0';
- n += 3;
- v += 3 + VPD_GET_VPD_LEN(v);
- *elements += 1;
+ SK_MEMCPY(buf,v,2) ;
+ buf += 2 ;
+ *buf++ = '\0' ;
+ n += 3 ;
+ v += 3 + VPD_GET_VPD_LEN(v) ;
+ *elements += 1 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,
- ("'%c%c' ",v[0],v[1]));
+ ("'%c%c' ",v[0],v[1])) ;
} else {
- *len = n;
+ *len = n ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("buffer overflow\n"));
- return (2);
+ ("buffer overflow\n")) ;
+ return (2) ;
}
}
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("\n"));
- *len = n;
- return(0);
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("\n")) ;
+ *len = n ;
+ return(0) ;
}
@@ -975,34 +962,34 @@
char *buf, /* buffer where to copy the keyword value */
int *len) /* buffer length */
{
- SK_VPD_PARA *p, vp;
+ SK_VPD_PARA *p, vp ;
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("vpd read %s .. ",key));
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,("vpd read %s .. ",key)) ;
if (!(pAC->vpd.v.vpd_status & VPD_VALID)) {
if (VpdInit(pAC,IoC) != 0 ) {
- *len = 0;
+ *len = 0 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("vpd init error\n"));
- return(6);
+ ("vpd init error\n")) ;
+ return(6) ;
}
}
if ((p = vpd_find_para(pAC,key,&vp))) {
if (p->p_len > (*(unsigned *)len)-1) {
- p->p_len = *len - 1;
+ p->p_len = *len - 1 ;
}
- SK_MEMCPY(buf,p->p_val,p->p_len);
- buf[p->p_len] = '\0';
- *len = p->p_len;
+ SK_MEMCPY(buf,p->p_val,p->p_len) ;
+ buf[p->p_len] = '\0' ;
+ *len = p->p_len ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_RX,
("%c%c%c%c.., len = %d\n",
- buf[0],buf[1],buf[2],buf[3],*len));
+ buf[0],buf[1],buf[2],buf[3],*len)) ;
} else {
- *len = 0;
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,("not found\n"));
- return (1);
+ *len = 0 ;
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,("not found\n")) ;
+ return (1) ;
}
- return (0);
+ return (0) ;
}
@@ -1020,9 +1007,9 @@
key[1] < '0' || key[1] > 'Z' ||
(key[1] > '9' && key[1] < 'A') || strlen(key) != 2) {
- return (SK_FALSE);
+ return (SK_FALSE) ;
}
- return (SK_TRUE);
+ return (SK_TRUE) ;
}
/*
@@ -1044,46 +1031,46 @@
char *key, /* keyword to write (allowed values "Yx", "Vx") */
char *buf) /* buffer where the keyword value can be read from */
{
- int len; /* lenght of the keyword to write */
- int rtv; /* return code */
- int rtv2;
+ int len ; /* lenght of the keyword to write */
+ int rtv ; /* return code */
+ int rtv2 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,
- ("vpd write %s = %s\n",key,buf));
+ ("vpd write %s = %s\n",key,buf)) ;
if ((*key != 'Y' && *key != 'V') ||
key[1] < '0' || key[1] > 'Z' ||
(key[1] > '9' && key[1] < 'A') || strlen(key) != 2) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("illegal key tag, keyword not written\n"));
- return (5);
+ ("illegal key tag, keyword not written\n")) ;
+ return (5) ;
}
if (!(pAC->vpd.v.vpd_status & VPD_VALID)) {
if (VpdInit(pAC,IoC) != 0 ) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("vpd init error\n"));
- return(6);
+ ("vpd init error\n")) ;
+ return(6) ;
}
}
- rtv = 0;
- len = strlen(buf);
+ rtv = 0 ;
+ len = strlen(buf) ;
if (len > VPD_MAX_LEN) {
/* cut it */
- len = VPD_MAX_LEN;
- rtv = 2;
+ len = VPD_MAX_LEN ;
+ rtv = 2 ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("keyword to long, cut after %d bytes\n",VPD_MAX_LEN));
+ ("keyword to long, cut after %d bytes\n",VPD_MAX_LEN)) ;
}
if ((rtv2 = VpdSetupPara(pAC,key,buf,len,VPD_RW_KEY,OWR_KEY)) != 0) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("vpd write error\n"));
- return(rtv2);
+ ("vpd write error\n")) ;
+ return(rtv2) ;
}
- return (rtv);
+ return (rtv) ;
}
/*
@@ -1103,15 +1090,15 @@
SK_IOC IoC, /* IO Context */
char *key) /* keyword to read (e.g. "MN") */
{
- SK_VPD_PARA *p, vp;
- char *etp;
+ SK_VPD_PARA *p, vp ;
+ char *etp ;
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd delete key %s\n",key));
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd delete key %s\n",key)) ;
if (!(pAC->vpd.v.vpd_status & VPD_VALID)) {
if (VpdInit(pAC,IoC) != 0 ) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("vpd init error\n"));
- return(6);
+ ("vpd init error\n")) ;
+ return(6) ;
}
}
@@ -1119,27 +1106,27 @@
if (p->p_val < pAC->vpd.vpd_buf + VPD_SIZE/2) {
/* try to delete read only keyword */
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("cannot delete RO keyword\n"));
- return (5);
+ ("cannot delete RO keyword\n")) ;
+ return (5) ;
}
- etp = pAC->vpd.vpd_buf + (VPD_SIZE-pAC->vpd.v.vpd_free_rw-1-3);
+ etp = pAC->vpd.vpd_buf + (VPD_SIZE-pAC->vpd.v.vpd_free_rw-1-3) ;
vpd_move_para(vp.p_val+vp.p_len, etp+2,
- - ((int)(vp.p_len + 3)));
+ - ((int)(vp.p_len + 3))) ;
if (vpd_mod_endtag(pAC, etp - vp.p_len - 3)) {
- pAC->vpd.v.vpd_status &= ~VPD_VALID;
+ pAC->vpd.v.vpd_status &= ~VPD_VALID ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("vpd encoding error\n"));
- return(6);
+ ("vpd encoding error\n")) ;
+ return(6) ;
}
} else {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("keyword not found\n"));
- return (1);
+ ("keyword not found\n")) ;
+ return (1) ;
}
- return (0);
+ return (0) ;
}
/*
@@ -1153,18 +1140,18 @@
SK_AC *pAC, /* Adapters context */
SK_IOC IoC) /* IO Context */
{
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd update .. "));
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("vpd update .. ")) ;
if (pAC->vpd.v.vpd_status & VPD_VALID) {
if (VpdTransferBlock(pAC,IoC,pAC->vpd.vpd_buf + VPD_SIZE/2,
VPD_SIZE/2, VPD_SIZE/2, VPD_WRITE) != VPD_SIZE/2) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("transfer timed out\n"));
- return(3);
+ ("transfer timed out\n")) ;
+ return(3) ;
}
}
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("done\n"));
- return (0);
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("done\n")) ;
+ return (0) ;
}
@@ -1184,32 +1171,32 @@
SK_IOC IoC, /* IO Context */
char *msg) /* error log message */
{
- SK_VPD_PARA *v, vf; /* VF */
- int len;
+ SK_VPD_PARA *v, vf ; /* VF */
+ int len ;
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,
- ("vpd error log msg %s\n",msg));
+ ("vpd error log msg %s\n",msg)) ;
if (!(pAC->vpd.v.vpd_status & VPD_VALID)) {
if (VpdInit(pAC,IoC) != 0 ) {
SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_ERR,
- ("vpd init error\n"));
- return;
+ ("vpd init error\n")) ;
+ return ;
}
}
- len = strlen(msg);
+ len = strlen(msg) ;
if (len > VPD_MAX_LEN) {
/* cut it */
- len = VPD_MAX_LEN;
+ len = VPD_MAX_LEN ;
}
if ((v = vpd_find_para(pAC,VPD_VF,&vf))) {
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("overwrite VL\n"));
- (void)VpdSetupPara(pAC,VPD_VL,msg,len,VPD_RW_KEY,OWR_KEY);
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("overwrite VL\n")) ;
+ (void)VpdSetupPara(pAC,VPD_VL,msg,len,VPD_RW_KEY,OWR_KEY) ;
} else {
- SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("write VF\n"));
- (void)VpdSetupPara(pAC,VPD_VF,msg,len,VPD_RW_KEY,ADD_KEY);
+ SK_DBG_MSG(pAC,SK_DBGMOD_VPD,SK_DBGCAT_TX,("write VF\n")) ;
+ (void)VpdSetupPara(pAC,VPD_VF,msg,len,VPD_RW_KEY,ADD_KEY) ;
}
- (void)VpdUpdate(pAC,IoC);
+ (void)VpdUpdate(pAC,IoC) ;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)