aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2008-07-22 14:37:17 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2008-07-28 18:06:00 -0400
commit362b7077a5546b42131af15ba4776f30c9a72d0c (patch)
tree59639d9cc02288f601cb7b9c3188053916e8d1a3 /drivers
parentd6d385743463f38a0da899cd4607e526ad9a049f (diff)
PCI: fix bogus "'device' may be used uninitialized" warning in pci_slot
I get warnings about 'device' possibly being used uninitialised. While I can deduce this is not true, it seems that GCC can't. This patch changes `check_slot' to return device on success and -1 on error, which shuts GCC up. Acked-by: Alex Chiang <achiang@hp.com> Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/pci_slot.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index dd376f7ad090..d5b4ef898879 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -76,9 +76,9 @@ static struct acpi_pci_driver acpi_pci_slot_driver = {
76}; 76};
77 77
78static int 78static int
79check_slot(acpi_handle handle, int *device, unsigned long *sun) 79check_slot(acpi_handle handle, unsigned long *sun)
80{ 80{
81 int retval = 0; 81 int device = -1;
82 unsigned long adr, sta; 82 unsigned long adr, sta;
83 acpi_status status; 83 acpi_status status;
84 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 84 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -89,32 +89,27 @@ check_slot(acpi_handle handle, int *device, unsigned long *sun)
89 if (check_sta_before_sun) { 89 if (check_sta_before_sun) {
90 /* If SxFy doesn't have _STA, we just assume it's there */ 90 /* If SxFy doesn't have _STA, we just assume it's there */
91 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 91 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
92 if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_PRESENT)) { 92 if (ACPI_SUCCESS(status) && !(sta & ACPI_STA_DEVICE_PRESENT))
93 retval = -1;
94 goto out; 93 goto out;
95 }
96 } 94 }
97 95
98 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 96 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
99 if (ACPI_FAILURE(status)) { 97 if (ACPI_FAILURE(status)) {
100 dbg("_ADR returned %d on %s\n", status, (char *)buffer.pointer); 98 dbg("_ADR returned %d on %s\n", status, (char *)buffer.pointer);
101 retval = -1;
102 goto out; 99 goto out;
103 } 100 }
104 101
105 *device = (adr >> 16) & 0xffff;
106
107 /* No _SUN == not a slot == bail */ 102 /* No _SUN == not a slot == bail */
108 status = acpi_evaluate_integer(handle, "_SUN", NULL, sun); 103 status = acpi_evaluate_integer(handle, "_SUN", NULL, sun);
109 if (ACPI_FAILURE(status)) { 104 if (ACPI_FAILURE(status)) {
110 dbg("_SUN returned %d on %s\n", status, (char *)buffer.pointer); 105 dbg("_SUN returned %d on %s\n", status, (char *)buffer.pointer);
111 retval = -1;
112 goto out; 106 goto out;
113 } 107 }
114 108
109 device = (adr >> 16) & 0xffff;
115out: 110out:
116 kfree(buffer.pointer); 111 kfree(buffer.pointer);
117 return retval; 112 return device;
118} 113}
119 114
120struct callback_args { 115struct callback_args {
@@ -144,7 +139,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
144 struct callback_args *parent_context = context; 139 struct callback_args *parent_context = context;
145 struct pci_bus *pci_bus = parent_context->pci_bus; 140 struct pci_bus *pci_bus = parent_context->pci_bus;
146 141
147 if (check_slot(handle, &device, &sun)) 142 device = check_slot(handle, &sun);
143 if (device < 0)
148 return AE_OK; 144 return AE_OK;
149 145
150 slot = kmalloc(sizeof(*slot), GFP_KERNEL); 146 slot = kmalloc(sizeof(*slot), GFP_KERNEL);