diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2007-12-07 00:09:18 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-12-10 21:46:08 -0500 |
commit | 1be9ad650986a87c25686abda97bdea330359708 (patch) | |
tree | 8a4b98534bdbd9e45f524d5b4990a77822d61f46 /arch/powerpc/platforms/iseries | |
parent | cd9afb34ed7e7fd3d1eb892b606019e032b0888b (diff) |
[POWERPC] iSeries: Clean up and simplify vdpinfo.c
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/iseries')
-rw-r--r-- | arch/powerpc/platforms/iseries/vpdinfo.c | 100 |
1 files changed, 46 insertions, 54 deletions
diff --git a/arch/powerpc/platforms/iseries/vpdinfo.c b/arch/powerpc/platforms/iseries/vpdinfo.c index f9415bf01518..aec82e365576 100644 --- a/arch/powerpc/platforms/iseries/vpdinfo.c +++ b/arch/powerpc/platforms/iseries/vpdinfo.c | |||
@@ -82,62 +82,56 @@ struct slot_map { | |||
82 | static void __init iseries_parse_slot_area(struct slot_map *map, int len, | 82 | static void __init iseries_parse_slot_area(struct slot_map *map, int len, |
83 | HvAgentId agent, u8 *phb, char card[4]) | 83 | HvAgentId agent, u8 *phb, char card[4]) |
84 | { | 84 | { |
85 | int slot_map_len = len; | ||
86 | struct slot_map *slot_map = map; | ||
87 | |||
88 | /* | 85 | /* |
89 | * Parse Slot label until we find the one requested | 86 | * Parse Slot label until we find the one requested |
90 | */ | 87 | */ |
91 | while (slot_map_len > 0) { | 88 | while (len > 0) { |
92 | if (slot_map->agent == agent) { | 89 | if (map->agent == agent) { |
93 | /* | 90 | /* |
94 | * If Phb wasn't found, grab the entry first one found. | 91 | * If Phb wasn't found, grab the entry first one found. |
95 | */ | 92 | */ |
96 | if (*phb == 0xff) | 93 | if (*phb == 0xff) |
97 | *phb = slot_map->phb; | 94 | *phb = map->phb; |
98 | /* Found it, extract the data. */ | 95 | /* Found it, extract the data. */ |
99 | if (slot_map->phb == *phb) { | 96 | if (map->phb == *phb) { |
100 | memcpy(card, &slot_map->card_location, 3); | 97 | memcpy(card, &map->card_location, 3); |
101 | card[3] = 0; | 98 | card[3] = 0; |
102 | break; | 99 | break; |
103 | } | 100 | } |
104 | } | 101 | } |
105 | /* Point to the next Slot */ | 102 | /* Point to the next Slot */ |
106 | slot_map = (struct slot_map *)((char *)slot_map + SLOT_ENTRY_SIZE); | 103 | map = (struct slot_map *)((char *)map + SLOT_ENTRY_SIZE); |
107 | slot_map_len -= SLOT_ENTRY_SIZE; | 104 | len -= SLOT_ENTRY_SIZE; |
108 | } | 105 | } |
109 | } | 106 | } |
110 | 107 | ||
111 | /* | 108 | /* |
112 | * Parse the Mfg Area | 109 | * Parse the Mfg Area |
113 | */ | 110 | */ |
114 | static void __init iseries_parse_mfg_area(u8 *area, int len, | 111 | static void __init iseries_parse_mfg_area(struct mfg_vpd_area *area, int len, |
115 | HvAgentId agent, u8 *phb, | 112 | HvAgentId agent, u8 *phb, u8 *frame, char card[4]) |
116 | u8 *frame, char card[4]) | ||
117 | { | 113 | { |
118 | struct mfg_vpd_area *mfg_area = (struct mfg_vpd_area *)area; | ||
119 | int mfg_area_len = len; | ||
120 | u16 slot_map_fmt = 0; | 114 | u16 slot_map_fmt = 0; |
121 | 115 | ||
122 | /* Parse Mfg Data */ | 116 | /* Parse Mfg Data */ |
123 | while (mfg_area_len > 0) { | 117 | while (len > 0) { |
124 | int mfg_tag_len = mfg_area->length; | 118 | int mfg_tag_len = area->length; |
125 | /* Frame ID (FI 4649020310 ) */ | 119 | /* Frame ID (FI 4649020310 ) */ |
126 | if (mfg_area->tag == VPD_FRU_FRAME_ID) | 120 | if (area->tag == VPD_FRU_FRAME_ID) |
127 | *frame = mfg_area->data1; | 121 | *frame = area->data1; |
128 | /* Slot Map Format (MF 4D46020004 ) */ | 122 | /* Slot Map Format (MF 4D46020004 ) */ |
129 | else if (mfg_area->tag == VPD_SLOT_MAP_FORMAT) | 123 | else if (area->tag == VPD_SLOT_MAP_FORMAT) |
130 | slot_map_fmt = (mfg_area->data1 * 256) | 124 | slot_map_fmt = (area->data1 * 256) |
131 | + mfg_area->data2; | 125 | + area->data2; |
132 | /* Slot Map (SM 534D90 */ | 126 | /* Slot Map (SM 534D90 */ |
133 | else if (mfg_area->tag == VPD_SLOT_MAP) { | 127 | else if (area->tag == VPD_SLOT_MAP) { |
134 | struct slot_map *slot_map; | 128 | struct slot_map *slot_map; |
135 | 129 | ||
136 | if (slot_map_fmt == 0x1004) | 130 | if (slot_map_fmt == 0x1004) |
137 | slot_map = (struct slot_map *)((char *)mfg_area | 131 | slot_map = (struct slot_map *)((char *)area |
138 | + MFG_ENTRY_SIZE + 1); | 132 | + MFG_ENTRY_SIZE + 1); |
139 | else | 133 | else |
140 | slot_map = (struct slot_map *)((char *)mfg_area | 134 | slot_map = (struct slot_map *)((char *)area |
141 | + MFG_ENTRY_SIZE); | 135 | + MFG_ENTRY_SIZE); |
142 | iseries_parse_slot_area(slot_map, mfg_tag_len, | 136 | iseries_parse_slot_area(slot_map, mfg_tag_len, |
143 | agent, phb, card); | 137 | agent, phb, card); |
@@ -146,9 +140,9 @@ static void __init iseries_parse_mfg_area(u8 *area, int len, | |||
146 | * Point to the next Mfg Area | 140 | * Point to the next Mfg Area |
147 | * Use defined size, sizeof give wrong answer | 141 | * Use defined size, sizeof give wrong answer |
148 | */ | 142 | */ |
149 | mfg_area = (struct mfg_vpd_area *)((char *)mfg_area + mfg_tag_len | 143 | area = (struct mfg_vpd_area *)((char *)area + mfg_tag_len |
150 | + MFG_ENTRY_SIZE); | 144 | + MFG_ENTRY_SIZE); |
151 | mfg_area_len -= (mfg_tag_len + MFG_ENTRY_SIZE); | 145 | len -= (mfg_tag_len + MFG_ENTRY_SIZE); |
152 | } | 146 | } |
153 | } | 147 | } |
154 | 148 | ||
@@ -156,48 +150,46 @@ static void __init iseries_parse_mfg_area(u8 *area, int len, | |||
156 | * Look for "BUS".. Data is not Null terminated. | 150 | * Look for "BUS".. Data is not Null terminated. |
157 | * PHBID of 0xFF indicates PHB was not found in VPD Data. | 151 | * PHBID of 0xFF indicates PHB was not found in VPD Data. |
158 | */ | 152 | */ |
159 | static int __init iseries_parse_phbid(u8 *area, int len) | 153 | static u8 __init iseries_parse_phbid(u8 *area, int len) |
160 | { | 154 | { |
161 | u8 *phb_ptr = area; | 155 | while (len > 0) { |
162 | int data_len = len; | 156 | if ((*area == 'B') && (*(area + 1) == 'U') |
163 | char phb = 0xFF; | 157 | && (*(area + 2) == 'S')) { |
164 | 158 | area += 3; | |
165 | while (data_len > 0) { | 159 | while (*area == ' ') |
166 | if ((*phb_ptr == 'B') && (*(phb_ptr + 1) == 'U') | 160 | area++; |
167 | && (*(phb_ptr + 2) == 'S')) { | 161 | return *area & 0x0F; |
168 | phb_ptr += 3; | ||
169 | while (*phb_ptr == ' ') | ||
170 | ++phb_ptr; | ||
171 | phb = (*phb_ptr & 0x0F); | ||
172 | break; | ||
173 | } | 162 | } |
174 | ++phb_ptr; | 163 | area++; |
175 | --data_len; | 164 | len--; |
176 | } | 165 | } |
177 | return phb; | 166 | return 0xff; |
178 | } | 167 | } |
179 | 168 | ||
180 | /* | 169 | /* |
181 | * Parse out the VPD Areas | 170 | * Parse out the VPD Areas |
182 | */ | 171 | */ |
183 | static void __init iseries_parse_vpd(u8 *data, int vpd_data_len, | 172 | static void __init iseries_parse_vpd(u8 *data, int data_len, |
184 | HvAgentId agent, u8 *frame, char card[4]) | 173 | HvAgentId agent, u8 *frame, char card[4]) |
185 | { | 174 | { |
186 | u8 *tag_ptr = data; | ||
187 | int data_len = vpd_data_len - 3; | ||
188 | u8 phb = 0xff; | 175 | u8 phb = 0xff; |
189 | 176 | ||
190 | while ((*tag_ptr != VPD_END_OF_AREA) && (data_len > 0)) { | 177 | while (data_len > 0) { |
191 | int len = *(tag_ptr + 1) + (*(tag_ptr + 2) * 256); | 178 | int len; |
192 | u8 *area = tag_ptr + 3; | 179 | u8 tag = *data; |
193 | 180 | ||
194 | if (*tag_ptr == VPD_ID_STRING) | 181 | if (tag == VPD_END_OF_AREA) |
195 | phb = iseries_parse_phbid(area, len); | 182 | break; |
196 | else if (*tag_ptr == VPD_VENDOR_AREA) | 183 | len = *(data + 1) + (*(data + 2) * 256); |
197 | iseries_parse_mfg_area(area, len, | 184 | data += 3; |
185 | data_len -= 3; | ||
186 | if (tag == VPD_ID_STRING) | ||
187 | phb = iseries_parse_phbid(data, len); | ||
188 | else if (tag == VPD_VENDOR_AREA) | ||
189 | iseries_parse_mfg_area((struct mfg_vpd_area *)data, len, | ||
198 | agent, &phb, frame, card); | 190 | agent, &phb, frame, card); |
199 | /* Point to next Area. */ | 191 | /* Point to next Area. */ |
200 | tag_ptr = area + len; | 192 | data += len; |
201 | data_len -= len; | 193 | data_len -= len; |
202 | } | 194 | } |
203 | } | 195 | } |