Commit 1be9ad65 authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Paul Mackerras

[POWERPC] iSeries: Clean up and simplify vdpinfo.c

Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent cd9afb34
...@@ -82,62 +82,56 @@ struct slot_map { ...@@ -82,62 +82,56 @@ struct slot_map {
static void __init iseries_parse_slot_area(struct slot_map *map, int len, static void __init iseries_parse_slot_area(struct slot_map *map, int len,
HvAgentId agent, u8 *phb, char card[4]) HvAgentId agent, u8 *phb, char card[4])
{ {
int slot_map_len = len;
struct slot_map *slot_map = map;
/* /*
* Parse Slot label until we find the one requested * Parse Slot label until we find the one requested
*/ */
while (slot_map_len > 0) { while (len > 0) {
if (slot_map->agent == agent) { if (map->agent == agent) {
/* /*
* If Phb wasn't found, grab the entry first one found. * If Phb wasn't found, grab the entry first one found.
*/ */
if (*phb == 0xff) if (*phb == 0xff)
*phb = slot_map->phb; *phb = map->phb;
/* Found it, extract the data. */ /* Found it, extract the data. */
if (slot_map->phb == *phb) { if (map->phb == *phb) {
memcpy(card, &slot_map->card_location, 3); memcpy(card, &map->card_location, 3);
card[3] = 0; card[3] = 0;
break; break;
} }
} }
/* Point to the next Slot */ /* Point to the next Slot */
slot_map = (struct slot_map *)((char *)slot_map + SLOT_ENTRY_SIZE); map = (struct slot_map *)((char *)map + SLOT_ENTRY_SIZE);
slot_map_len -= SLOT_ENTRY_SIZE; len -= SLOT_ENTRY_SIZE;
} }
} }
/* /*
* Parse the Mfg Area * Parse the Mfg Area
*/ */
static void __init iseries_parse_mfg_area(u8 *area, int len, static void __init iseries_parse_mfg_area(struct mfg_vpd_area *area, int len,
HvAgentId agent, u8 *phb, HvAgentId agent, u8 *phb, u8 *frame, char card[4])
u8 *frame, char card[4])
{ {
struct mfg_vpd_area *mfg_area = (struct mfg_vpd_area *)area;
int mfg_area_len = len;
u16 slot_map_fmt = 0; u16 slot_map_fmt = 0;
/* Parse Mfg Data */ /* Parse Mfg Data */
while (mfg_area_len > 0) { while (len > 0) {
int mfg_tag_len = mfg_area->length; int mfg_tag_len = area->length;
/* Frame ID (FI 4649020310 ) */ /* Frame ID (FI 4649020310 ) */
if (mfg_area->tag == VPD_FRU_FRAME_ID) if (area->tag == VPD_FRU_FRAME_ID)
*frame = mfg_area->data1; *frame = area->data1;
/* Slot Map Format (MF 4D46020004 ) */ /* Slot Map Format (MF 4D46020004 ) */
else if (mfg_area->tag == VPD_SLOT_MAP_FORMAT) else if (area->tag == VPD_SLOT_MAP_FORMAT)
slot_map_fmt = (mfg_area->data1 * 256) slot_map_fmt = (area->data1 * 256)
+ mfg_area->data2; + area->data2;
/* Slot Map (SM 534D90 */ /* Slot Map (SM 534D90 */
else if (mfg_area->tag == VPD_SLOT_MAP) { else if (area->tag == VPD_SLOT_MAP) {
struct slot_map *slot_map; struct slot_map *slot_map;
if (slot_map_fmt == 0x1004) if (slot_map_fmt == 0x1004)
slot_map = (struct slot_map *)((char *)mfg_area slot_map = (struct slot_map *)((char *)area
+ MFG_ENTRY_SIZE + 1); + MFG_ENTRY_SIZE + 1);
else else
slot_map = (struct slot_map *)((char *)mfg_area slot_map = (struct slot_map *)((char *)area
+ MFG_ENTRY_SIZE); + MFG_ENTRY_SIZE);
iseries_parse_slot_area(slot_map, mfg_tag_len, iseries_parse_slot_area(slot_map, mfg_tag_len,
agent, phb, card); agent, phb, card);
...@@ -146,9 +140,9 @@ static void __init iseries_parse_mfg_area(u8 *area, int len, ...@@ -146,9 +140,9 @@ static void __init iseries_parse_mfg_area(u8 *area, int len,
* Point to the next Mfg Area * Point to the next Mfg Area
* Use defined size, sizeof give wrong answer * Use defined size, sizeof give wrong answer
*/ */
mfg_area = (struct mfg_vpd_area *)((char *)mfg_area + mfg_tag_len area = (struct mfg_vpd_area *)((char *)area + mfg_tag_len
+ MFG_ENTRY_SIZE); + MFG_ENTRY_SIZE);
mfg_area_len -= (mfg_tag_len + MFG_ENTRY_SIZE); len -= (mfg_tag_len + MFG_ENTRY_SIZE);
} }
} }
...@@ -156,48 +150,46 @@ static void __init iseries_parse_mfg_area(u8 *area, int len, ...@@ -156,48 +150,46 @@ static void __init iseries_parse_mfg_area(u8 *area, int len,
* Look for "BUS".. Data is not Null terminated. * Look for "BUS".. Data is not Null terminated.
* PHBID of 0xFF indicates PHB was not found in VPD Data. * PHBID of 0xFF indicates PHB was not found in VPD Data.
*/ */
static int __init iseries_parse_phbid(u8 *area, int len) static u8 __init iseries_parse_phbid(u8 *area, int len)
{ {
u8 *phb_ptr = area; while (len > 0) {
int data_len = len; if ((*area == 'B') && (*(area + 1) == 'U')
char phb = 0xFF; && (*(area + 2) == 'S')) {
area += 3;
while (data_len > 0) { while (*area == ' ')
if ((*phb_ptr == 'B') && (*(phb_ptr + 1) == 'U') area++;
&& (*(phb_ptr + 2) == 'S')) { return *area & 0x0F;
phb_ptr += 3;
while (*phb_ptr == ' ')
++phb_ptr;
phb = (*phb_ptr & 0x0F);
break;
} }
++phb_ptr; area++;
--data_len; len--;
} }
return phb; return 0xff;
} }
/* /*
* Parse out the VPD Areas * Parse out the VPD Areas
*/ */
static void __init iseries_parse_vpd(u8 *data, int vpd_data_len, static void __init iseries_parse_vpd(u8 *data, int data_len,
HvAgentId agent, u8 *frame, char card[4]) HvAgentId agent, u8 *frame, char card[4])
{ {
u8 *tag_ptr = data;
int data_len = vpd_data_len - 3;
u8 phb = 0xff; u8 phb = 0xff;
while ((*tag_ptr != VPD_END_OF_AREA) && (data_len > 0)) { while (data_len > 0) {
int len = *(tag_ptr + 1) + (*(tag_ptr + 2) * 256); int len;
u8 *area = tag_ptr + 3; u8 tag = *data;
if (*tag_ptr == VPD_ID_STRING) if (tag == VPD_END_OF_AREA)
phb = iseries_parse_phbid(area, len); break;
else if (*tag_ptr == VPD_VENDOR_AREA) len = *(data + 1) + (*(data + 2) * 256);
iseries_parse_mfg_area(area, len, data += 3;
data_len -= 3;
if (tag == VPD_ID_STRING)
phb = iseries_parse_phbid(data, len);
else if (tag == VPD_VENDOR_AREA)
iseries_parse_mfg_area((struct mfg_vpd_area *)data, len,
agent, &phb, frame, card); agent, &phb, frame, card);
/* Point to next Area. */ /* Point to next Area. */
tag_ptr = area + len; data += len;
data_len -= len; data_len -= len;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment