aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Dufour <ldufour@linux.vnet.ibm.com>2014-04-10 09:02:13 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-04-25 13:48:42 -0400
commit761ce53330a4f02c58768631027d1c1dd0d538f7 (patch)
tree3306d11fa1aa25fb02edc0a52366b84339288692
parent374a91404314cef882b27b293dd34d89e2a3c0b6 (diff)
PCI: rphahp: Fix endianess issues
Numerical values stored in the device tree are encoded in Big Endian and should be byte swapped when running in Little Endian. The RPA hotplug module should convert those values as well. Note that in rpaphp_get_drc_props(), the comparison between indexes[i+1] and *index is done using the BE values (whatever is the current endianess). This doesn't matter since we are checking for equality here. This way only the returned value is byte swapped. RPA also made RTAS calls which implies BE values to be used. According to the patch done in RTAS (http://patchwork.ozlabs.org/patch/336865), no additional conversion is required in RPA. Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 4796c15fba94..984d708552f6 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -223,16 +223,16 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
223 type_tmp = (char *) &types[1]; 223 type_tmp = (char *) &types[1];
224 224
225 /* Iterate through parent properties, looking for my-drc-index */ 225 /* Iterate through parent properties, looking for my-drc-index */
226 for (i = 0; i < indexes[0]; i++) { 226 for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
227 if ((unsigned int) indexes[i + 1] == *my_index) { 227 if ((unsigned int) indexes[i + 1] == *my_index) {
228 if (drc_name) 228 if (drc_name)
229 *drc_name = name_tmp; 229 *drc_name = name_tmp;
230 if (drc_type) 230 if (drc_type)
231 *drc_type = type_tmp; 231 *drc_type = type_tmp;
232 if (drc_index) 232 if (drc_index)
233 *drc_index = *my_index; 233 *drc_index = be32_to_cpu(*my_index);
234 if (drc_power_domain) 234 if (drc_power_domain)
235 *drc_power_domain = domains[i+1]; 235 *drc_power_domain = be32_to_cpu(domains[i+1]);
236 return 0; 236 return 0;
237 } 237 }
238 name_tmp += (strlen(name_tmp) + 1); 238 name_tmp += (strlen(name_tmp) + 1);
@@ -321,16 +321,19 @@ int rpaphp_add_slot(struct device_node *dn)
321 /* register PCI devices */ 321 /* register PCI devices */
322 name = (char *) &names[1]; 322 name = (char *) &names[1];
323 type = (char *) &types[1]; 323 type = (char *) &types[1];
324 for (i = 0; i < indexes[0]; i++) { 324 for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
325 int index;
325 326
326 slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]); 327 index = be32_to_cpu(indexes[i + 1]);
328 slot = alloc_slot_struct(dn, index, name,
329 be32_to_cpu(power_domains[i + 1]));
327 if (!slot) 330 if (!slot)
328 return -ENOMEM; 331 return -ENOMEM;
329 332
330 slot->type = simple_strtoul(type, NULL, 10); 333 slot->type = simple_strtoul(type, NULL, 10);
331 334
332 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n", 335 dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n",
333 indexes[i + 1], name, type); 336 index, name, type);
334 337
335 retval = rpaphp_enable_slot(slot); 338 retval = rpaphp_enable_slot(slot);
336 if (!retval) 339 if (!retval)