PCI Hotplug: cpqphp: refactor cpqhp_probe
Apply DeMorgan's theorem: if ((pdev->revision > 2) || (vendor_id == PCI_VENDOR_ID_INTEL)) turns into if ((pdev->revision <= 2) && (vendor_id != PCI_VENDOR_ID_INTEL)) Now we can bail out early from the function if the controller is not supported. This allows us to un-indent the remainder of the function quite a bit and make it much more readable. Fix up some extra braces, and un-indent the 'case' labels in the switch statement as per CodingStyle. No functional change. Signed-off-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
committed by
Jesse Barnes
parent
04225fe7e6
commit
867556fe74
@@ -887,7 +887,11 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
* For Intel, each SSID bit identifies a PHP capability.
|
||||
* Also Intel HPC's may have RID=0.
|
||||
*/
|
||||
if ((pdev->revision > 2) || (vendor_id == PCI_VENDOR_ID_INTEL)) {
|
||||
if ((pdev->revision <= 2) && (vendor_id != PCI_VENDOR_ID_INTEL)) {
|
||||
err(msg_HPC_not_supported);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* TODO: This code can be made to support non-Compaq or Intel
|
||||
* subsystem IDs
|
||||
*/
|
||||
@@ -1021,64 +1025,53 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
||||
case PCI_VENDOR_ID_INTEL:
|
||||
/* Check for speed capability (0=33, 1=66) */
|
||||
if (subsystem_deviceid & 0x0001) {
|
||||
if (subsystem_deviceid & 0x0001)
|
||||
ctrl->speed_capability = PCI_SPEED_66MHz;
|
||||
} else {
|
||||
else
|
||||
ctrl->speed_capability = PCI_SPEED_33MHz;
|
||||
}
|
||||
|
||||
/* Check for push button */
|
||||
if (subsystem_deviceid & 0x0002) {
|
||||
/* no push button */
|
||||
if (subsystem_deviceid & 0x0002)
|
||||
ctrl->push_button = 0;
|
||||
} else {
|
||||
/* push button supported */
|
||||
else
|
||||
ctrl->push_button = 1;
|
||||
}
|
||||
|
||||
/* Check for slot switch type (0=mechanical, 1=not mechanical) */
|
||||
if (subsystem_deviceid & 0x0004) {
|
||||
/* no switch */
|
||||
if (subsystem_deviceid & 0x0004)
|
||||
ctrl->slot_switch_type = 0;
|
||||
} else {
|
||||
/* switch */
|
||||
else
|
||||
ctrl->slot_switch_type = 1;
|
||||
}
|
||||
|
||||
/* PHP Status (0=De-feature PHP, 1=Normal operation) */
|
||||
if (subsystem_deviceid & 0x0008) {
|
||||
if (subsystem_deviceid & 0x0008)
|
||||
ctrl->defeature_PHP = 1; /* PHP supported */
|
||||
} else {
|
||||
else
|
||||
ctrl->defeature_PHP = 0; /* PHP not supported */
|
||||
}
|
||||
|
||||
/* Alternate Base Address Register Interface (0=not supported, 1=supported) */
|
||||
if (subsystem_deviceid & 0x0010) {
|
||||
ctrl->alternate_base_address = 1; /* supported */
|
||||
} else {
|
||||
ctrl->alternate_base_address = 0; /* not supported */
|
||||
}
|
||||
/* Alternate Base Address Register Interface
|
||||
* (0=not supported, 1=supported)
|
||||
*/
|
||||
if (subsystem_deviceid & 0x0010)
|
||||
ctrl->alternate_base_address = 1;
|
||||
else
|
||||
ctrl->alternate_base_address = 0;
|
||||
|
||||
/* PCI Config Space Index (0=not supported, 1=supported) */
|
||||
if (subsystem_deviceid & 0x0020) {
|
||||
ctrl->pci_config_space = 1; /* supported */
|
||||
} else {
|
||||
ctrl->pci_config_space = 0; /* not supported */
|
||||
}
|
||||
if (subsystem_deviceid & 0x0020)
|
||||
ctrl->pci_config_space = 1;
|
||||
else
|
||||
ctrl->pci_config_space = 0;
|
||||
|
||||
/* PCI-X support */
|
||||
if (subsystem_deviceid & 0x0080) {
|
||||
/* PCI-X capable */
|
||||
ctrl->pcix_support = 1;
|
||||
/* Frequency of operation in PCI-X mode */
|
||||
if (subsystem_deviceid & 0x0040) {
|
||||
if (subsystem_deviceid & 0x0040)
|
||||
/* 133MHz PCI-X if bit 7 is 1 */
|
||||
ctrl->pcix_speed_capability = 1;
|
||||
} else {
|
||||
else
|
||||
/* 100MHz PCI-X if bit 7 is 1 and bit 0 is 0, */
|
||||
/* 66MHz PCI-X if bit 7 is 1 and bit 0 is 1 */
|
||||
ctrl->pcix_speed_capability = 0;
|
||||
}
|
||||
} else {
|
||||
/* Conventional PCI */
|
||||
ctrl->pcix_support = 0;
|
||||
@@ -1092,11 +1085,6 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
goto err_free_ctrl;
|
||||
}
|
||||
|
||||
} else {
|
||||
err(msg_HPC_not_supported);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Tell the user that we found one. */
|
||||
info("Initializing the PCI hot plug controller residing on PCI bus %d\n",
|
||||
pdev->bus->number);
|
||||
@@ -1164,7 +1152,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
goto err_free_mem_region;
|
||||
}
|
||||
|
||||
// Check for 66Mhz operation
|
||||
/* Check for 66Mhz operation */
|
||||
ctrl->speed = get_controller_speed(ctrl);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user