Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 154155
b: refs/heads/master
c: f5eebbe
h: refs/heads/master
i:
  154153: 2bbdb31
  154151: 30fc843
v: v3
  • Loading branch information
Bjorn Helgaas authored and Len Brown committed Jun 20, 2009
1 parent 1a9ff3c commit ec246ff
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 63 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fbe2b31b4b6dfa790cbc88e00631f3112c4fc54e
refs/heads/master: f5eebbe119a861b5e4f5c67c886eab0937c686ed
100 changes: 38 additions & 62 deletions trunk/drivers/acpi/pci_root.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,22 @@ get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
return AE_OK;
}

static acpi_status try_get_root_bridge_busnr(acpi_handle handle, int *busnum)
static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
unsigned long long *bus)
{
acpi_status status;
int busnum;

*busnum = -1;
busnum = -1;
status =
acpi_walk_resources(handle, METHOD_NAME__CRS,
get_root_bridge_busnr_callback, busnum);
get_root_bridge_busnr_callback, &busnum);
if (ACPI_FAILURE(status))
return status;
/* Check if we really get a bus number from _CRS */
if (*busnum == -1)
if (busnum == -1)
return AE_ERROR;
*bus = busnum;
return AE_OK;
}

Expand Down Expand Up @@ -363,24 +366,39 @@ EXPORT_SYMBOL(acpi_pci_osc_control_set);

static int __devinit acpi_pci_root_add(struct acpi_device *device)
{
int result = 0;
struct acpi_pci_root *root = NULL;
acpi_status status = AE_OK;
unsigned long long value = 0;
acpi_handle handle = NULL;
unsigned long long segment, bus;
acpi_status status;
int result;
struct acpi_pci_root *root;
acpi_handle handle;
struct acpi_device *child;
u32 flags, base_flags;
int bus;

segment = 0;
status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL,
&segment);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
printk(KERN_ERR PREFIX "can't evaluate _SEG\n");
return -ENODEV;
}

if (!device)
return -EINVAL;
/* Check _CRS first, then _BBN. If no _BBN, default to zero. */
bus = 0;
status = try_get_root_bridge_busnr(device->handle, &bus);
if (ACPI_FAILURE(status)) {
status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, NULL, &bus);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
printk(KERN_ERR PREFIX
"no bus number in _CRS and can't evaluate _BBN\n");
return -ENODEV;
}
}

root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
if (!root)
return -ENOMEM;
INIT_LIST_HEAD(&root->node);

INIT_LIST_HEAD(&root->node);
root->device = device;
strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
Expand All @@ -395,54 +413,13 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
acpi_pci_osc_support(root, flags);

/*
* Segment
* -------
* Obtained via _SEG, if exists, otherwise assumed to be zero (0).
*/
status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL,
&value);
switch (status) {
case AE_OK:
root->id.segment = (u16) value;
break;
case AE_NOT_FOUND:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Assuming segment 0 (no _SEG)\n"));
root->id.segment = 0;
break;
default:
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SEG"));
result = -ENODEV;
goto end;
}

/*
* Bus
* ---
* Check _CRS first, then _BBN. If no _BBN, default to zero.
*/
status = try_get_root_bridge_busnr(device->handle, &bus);
if (ACPI_SUCCESS(status))
root->id.bus = bus;
else {
status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, NULL, &value);
if (ACPI_SUCCESS(status))
root->id.bus = (u16) value;
else if (status == AE_NOT_FOUND)
root->id.bus = 0;
else {
ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BBN"));
result = -ENODEV;
goto end;
}
}

/*
* Device & Function
* -----------------
* Obtained from _ADR (which has already been evaluated for us).
*/
root->id.segment = segment & 0xFFFF;
root->id.bus = bus & 0xFF;
root->id.device = device->pnp.bus_address >> 16;
root->id.function = device->pnp.bus_address & 0xFFFF;

Expand Down Expand Up @@ -509,13 +486,12 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
if (flags != base_flags)
acpi_pci_osc_support(root, flags);

end:
if (result) {
if (!list_empty(&root->node))
list_del(&root->node);
kfree(root);
}
return 0;

end:
if (!list_empty(&root->node))
list_del(&root->node);
kfree(root);
return result;
}

Expand Down

0 comments on commit ec246ff

Please sign in to comment.