board/w7o/vpd.c: make (mostly) checkpatch clean

Accept 2 warnings "externs should be avoided".

Signed-off-by: Wolfgang Denk <wd@denx.de>
This commit is contained in:
Wolfgang Denk 2011-12-07 12:19:27 +00:00
parent fc86bbf692
commit 1da8dba9b6

View file

@ -37,8 +37,8 @@ extern ulong_t crc32( unsigned char *, unsigned long );
* vpd_reader() - reads VPD data from I2C EEPROMS.
* returns pointer to buffer or NULL.
*/
static unsigned char *
vpd_reader(unsigned char *buf, unsigned dev_addr, unsigned off, unsigned count)
static unsigned char *vpd_reader(unsigned char *buf, unsigned dev_addr,
unsigned off, unsigned count)
{
unsigned offset = off; /* Calculated offset */
@ -54,10 +54,10 @@ vpd_reader(unsigned char *buf, unsigned dev_addr, unsigned off, unsigned count)
#if defined(VXWORKS)
{
int i;
for( i = 0; i < count; ++i ) {
for (i = 0; i < count; ++i)
buf[i] = iicReadByte(dev_addr, offset + i);
}
}
#else
if (eeprom_read(dev_addr, offset, buf, count)) {
printf("Failed to read %d bytes from VPD EEPROM 0x%x @ 0x%x\n",
@ -67,7 +67,7 @@ vpd_reader(unsigned char *buf, unsigned dev_addr, unsigned off, unsigned count)
#endif
return buf;
} /* vpd_reader() */
}
/*
@ -81,11 +81,12 @@ static vpd_packet_t *vpd_get_packet(vpd_packet_t *vpd_packet)
if (packet->identifier == VPD_PID_TERM)
return NULL;
else
packet = (vpd_packet_t *)((char *)packet + packet->size + 2);
packet = (vpd_packet_t *) ((char *) packet +
packet->size + 2);
}
return packet;
} /* vpd_get_packet() */
}
/*
@ -125,11 +126,15 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf)
unsigned short stored_crc16, calc_crc16 = 0xffff;
/* Check Eyecatcher */
if (strncmp((char *)(vpd->header.eyecatcher), VPD_EYECATCHER, VPD_EYE_SIZE) != 0) {
if (strncmp
((char *) (vpd->header.eyecatcher), VPD_EYECATCHER,
VPD_EYE_SIZE) != 0) {
unsigned offset = 0;
if (dev_addr == CONFIG_SYS_DEF_EEPROM_ADDR)
offset += SDRAM_SPD_DATA_SIZE;
printf("Error: VPD EEPROM 0x%x corrupt @ 0x%x\n", dev_addr, offset);
printf("Error: VPD EEPROM 0x%x corrupt @ 0x%x\n", dev_addr,
offset);
return 0;
}
@ -142,7 +147,8 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf)
}
/* Now find the termination packet */
if ((packet = vpd_find_packet(vpd, VPD_PID_TERM)) == NULL) {
packet = vpd_find_packet(vpd, VPD_PID_TERM);
if (packet == NULL) {
printf("Error: VPD EEPROM 0x%x missing termination packet\n",
dev_addr);
return 0;
@ -150,10 +156,12 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf)
/* Calculate data size */
num_bytes = (unsigned long) ((unsigned char *) packet -
(unsigned char *)vpd + sizeof(vpd_packet_t));
(unsigned char *) vpd +
sizeof(vpd_packet_t));
/* Find stored CRC and clear it */
if ((packet = vpd_find_packet(vpd, VPD_PID_CRC)) == NULL) {
packet = vpd_find_packet(vpd, VPD_PID_CRC);
if (packet == NULL) {
printf("Error: VPD EEPROM 0x%x missing CRC\n", dev_addr);
return 0;
}
@ -166,7 +174,8 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf)
#else
calc_crc16 = (0xffff & crc32(0, buf, num_bytes));
#endif
*(ushort *)packet->data = stored_crc16; /* Now restore the CRC */
/* Now restore the CRC */
*(ushort *) packet->data = stored_crc16;
if (stored_crc16 != calc_crc16) {
printf("Error: VPD EEPROM 0x%x has bad CRC 0x%x\n",
dev_addr, stored_crc16);
@ -174,7 +183,7 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf)
}
return 1;
} /* vpd_is_valid() */
}
/*
@ -189,7 +198,7 @@ static int size_ok(vpd_packet_t *packet, unsigned long size)
return 0;
}
return 1;
} /* size_ok() */
}
/*
@ -204,7 +213,7 @@ static int strlen_ok(vpd_packet_t *packet, unsigned long length)
return 0;
}
return 1;
} /* strlen_ok() */
}
/*
@ -236,9 +245,8 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo)
vpdInfo->_devAddr = dev_addr;
/* Read the minimum size first */
if (vpd_reader(buf, dev_addr, 0, VPD_EEPROM_SIZE) == NULL) {
if (vpd_reader(buf, dev_addr, 0, VPD_EEPROM_SIZE) == NULL)
return 1;
}
/* Check validity of VPD data */
if (!vpd_is_valid(dev_addr, buf)) {
@ -259,7 +267,8 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo)
case VPD_PID_PID:
if (strlen_ok(packet, MAX_PROD_ID)) {
strncpy(vpdInfo->productId,
(char *)(packet->data), packet->size);
(char *) (packet->data),
packet->size);
}
break;
case VPD_PID_REV:
@ -284,11 +293,13 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo)
break;
case VPD_PID_SYSCLK:
if (size_ok(packet, sizeof(unsigned long)))
vpdInfo->sysClk = *(unsigned long *)packet->data;
vpdInfo->sysClk =
*(unsigned long *) packet->data;
break;
case VPD_PID_SERCLK:
if (size_ok(packet, sizeof(unsigned long)))
vpdInfo->serClk = *(unsigned long *)packet->data;
vpdInfo->serClk =
*(unsigned long *) packet->data;
break;
case VPD_PID_FLASH:
if (size_ok(packet, 9)) { /* XXX - hardcoded,
@ -318,7 +329,7 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo)
} while ((packet = vpd_get_packet(packet)));
return 0;
} /* end get_vpd_data() */
}
/*
@ -326,8 +337,8 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo)
*/
int vpd_init(unsigned char dev_addr)
{
return (0);
} /* vpd_init() */
return 0;
}
/*
@ -364,10 +375,12 @@ void vpd_print(VPD *vpdInfo)
printf(hfmt, sp, "Configuration", vpdInfo->configOpt);
if (vpdInfo->sysClk)
printf(dhfmt, sp, "System Clock", vpdInfo->sysClk, vpdInfo->sysClk);
printf(dhfmt, sp, "System Clock", vpdInfo->sysClk,
vpdInfo->sysClk);
if (vpdInfo->serClk)
printf(dhfmt, sp, "Serial Clock", vpdInfo->serClk, vpdInfo->serClk);
printf(dhfmt, sp, "Serial Clock", vpdInfo->serClk,
vpdInfo->serClk);
if (vpdInfo->numPOTS)
printf(dfmt, sp, "Number of POTS lines", vpdInfo->numPOTS);
@ -378,17 +391,20 @@ void vpd_print(VPD *vpdInfo)
/* Print Ethernet Addresses */
if (vpdInfo->ethAddrs[0][0] != 0xff) {
int i, j;
printf("%4sEtherNet Address(es): ", sp);
for (i = 0; i < MAX_ETH_ADDRS; i++) {
if (vpdInfo->ethAddrs[i][0] != 0xff) {
for (j = 0; j < 6; j++) {
printf("%02X", vpdInfo->ethAddrs[i][j]);
printf("%02X",
vpdInfo->ethAddrs[i][j]);
if (((j + 1) % 6) != 0)
printf(":");
else
printf(" ");
}
if (((i + 1) % 3) == 0) printf("\n%24s: ", sp);
if (((i + 1) % 3) == 0)
printf("\n%24s: ", sp);
}
}
printf("\n");
@ -402,6 +418,7 @@ void vpd_print(VPD *vpdInfo)
printf(dsfmt, sp, "Num. Devices", vpdInfo->flashCfg.numDevs);
printf(dsfmt, sp, "Num. Columns", vpdInfo->flashCfg.numCols);
printf(dsfmt, sp, "Column Width", vpdInfo->flashCfg.colWidth);
printf(dsfmt, sp, "WE Data Width", vpdInfo->flashCfg.weDataWidth);
printf(dsfmt, sp, "WE Data Width",
vpdInfo->flashCfg.weDataWidth);
}
}
} /* vpd_print() */