summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2012-02-24 21:55:03 -0600
committerDave Airlie <airlied@redhat.com>2012-03-09 09:38:11 +0000
commit7ea646985afb9eab22df863328f75c90346a0997 (patch)
tree71ed91963695908fb502e4c47df73eaa810c0473
parent41c8d48f9657573a8067cd151ac82cc9d830eb67 (diff)
exit "for each PCI device" loop as soon as Radeon device is found
This just unindents the code some more. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--avivotool.c30
-rw-r--r--radeonreg.c24
-rw-r--r--radeontool.c44
3 files changed, 48 insertions, 50 deletions
diff --git a/avivotool.c b/avivotool.c
index ab41286..9c35fc7 100644
--- a/avivotool.c
+++ b/avivotool.c
@@ -1850,26 +1850,26 @@ static int map_radeon_mem(void)
if (skip--)
continue;
-
- for (i = 0; i < 6; i++) {
- if (device->regions[i].size == 64 * 1024)
- ctrl_region = i;
- else if (device->regions[i].size == 128 * 1024)
- ctrl_region = i;
- else if (device->regions[i].size == 256 * 1024)
- ctrl_region = i;
- else if (device->regions[i].size >= 128 * 1024 * 1024)
- fb_region = i;
- }
- avivo_device = device;
break;
}
- if (!avivo_device){
- printf("cannot find Radeon device\n");
- return -1;
+ if (!device) {
+ printf("cannot find Radeon device\n");
+ return -1;
}
+ for (i = 0; i < 6; i++) {
+ if (device->regions[i].size == 64 * 1024)
+ ctrl_region = i;
+ else if (device->regions[i].size == 128 * 1024)
+ ctrl_region = i;
+ else if (device->regions[i].size == 256 * 1024)
+ ctrl_region = i;
+ else if (device->regions[i].size >= 128 * 1024 * 1024)
+ fb_region = i;
+ }
+ avivo_device = device;
+
if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0) {
fprintf(stderr, "error: mapping ctrl region\n");
return -1;
diff --git a/radeonreg.c b/radeonreg.c
index 14e8b0a..2223cee 100644
--- a/radeonreg.c
+++ b/radeonreg.c
@@ -398,23 +398,23 @@ static int map_radeon_mem(void)
continue;
if (skip--)
continue;
-
- for (i = 0; i < sizeof(RADEONCards) / sizeof(RADEONCardInfo); i++) {
- if (RADEONCards[i].pci_device_id == device->device_id)
- card_info = &RADEONCards[i];
- }
-
- fb_region = 0;
- ctrl_region = 2;
- avivo_device = device;
break;
}
- if (!avivo_device){
- printf("cannot find Radeon device\n");
- return -1;
+ if (!device) {
+ printf("cannot find Radeon device\n");
+ return -1;
}
+ for (i = 0; i < sizeof(RADEONCards) / sizeof(RADEONCardInfo); i++) {
+ if (RADEONCards[i].pci_device_id == device->device_id)
+ card_info = &RADEONCards[i];
+ }
+
+ fb_region = 0;
+ ctrl_region = 2;
+ avivo_device = device;
+
if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0)
die("mapping ctrl region");
ctrl_mem = avivo_device->regions[ctrl_region].memory;
diff --git a/radeontool.c b/radeontool.c
index ecf13d1..9ed92c2 100644
--- a/radeontool.c
+++ b/radeontool.c
@@ -937,37 +937,35 @@ static void map_radeon_cntl_mem(void)
if ((device->device_class & 0x00ffff00) != 0x00030000)
continue;
- if (debug) {
+ if (debug)
printf("Found card %x:%x (%x)\n", device->vendor_id,
device->device_id, device->device_class);
- }
-
- if (skip-- != 0) {
+ if (skip--)
continue;
- }
- for (i = 0; i < 6; i++) {
- if (device->regions[i].size >= 16 * 1024 &&
- device->regions[i].size <= 64 * 1024) {
- if (ctrl_region != -1)
- die("cannot distinguish ctrl region");
- ctrl_region = i;
- } else if (device->regions[i].size >= 64 * 1024 * 1024) {
- if (fb_region != -1)
- die("cannot distinguish fb region");
- fb_region = i;
- }
- }
- if (ctrl_region == -1)
- die("cannot find ctrl region");
- if (fb_region == -1)
- die("cannot find fb region");
- avivo_device = device;
break;
}
- if (!avivo_device)
+ if (!device)
die("cannot find Radeon device");
+ for (i = 0; i < 6; i++) {
+ if (device->regions[i].size >= 16 * 1024 &&
+ device->regions[i].size <= 64 * 1024) {
+ if (ctrl_region != -1)
+ die("cannot distinguish ctrl region");
+ ctrl_region = i;
+ } else if (device->regions[i].size >= 64 * 1024 * 1024) {
+ if (fb_region != -1)
+ die("cannot distinguish fb region");
+ fb_region = i;
+ }
+ }
+ if (ctrl_region == -1)
+ die("cannot find ctrl region");
+ if (fb_region == -1)
+ die("cannot find fb region");
+ avivo_device = device;
+
if (pci_device_map_region(avivo_device, ctrl_region, 1) != 0)
die("mapping ctrl region");
ctrl_mem = avivo_device->regions[ctrl_region].memory;