aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/pci_bind.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/pci_bind.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/pci_bind.c')
-rw-r--r--drivers/acpi/pci_bind.c219
1 files changed, 103 insertions, 116 deletions
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 5148f3c10b5c..a4955685e4c0 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -35,22 +35,16 @@
35#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 36#include <acpi/acpi_drivers.h>
37 37
38
39#define _COMPONENT ACPI_PCI_COMPONENT 38#define _COMPONENT ACPI_PCI_COMPONENT
40ACPI_MODULE_NAME ("pci_bind") 39ACPI_MODULE_NAME("pci_bind")
41 40
42struct acpi_pci_data { 41struct acpi_pci_data {
43 struct acpi_pci_id id; 42 struct acpi_pci_id id;
44 struct pci_bus *bus; 43 struct pci_bus *bus;
45 struct pci_dev *dev; 44 struct pci_dev *dev;
46}; 45};
47 46
48 47void acpi_pci_data_handler(acpi_handle handle, u32 function, void *context)
49void
50acpi_pci_data_handler (
51 acpi_handle handle,
52 u32 function,
53 void *context)
54{ 48{
55 ACPI_FUNCTION_TRACE("acpi_pci_data_handler"); 49 ACPI_FUNCTION_TRACE("acpi_pci_data_handler");
56 50
@@ -59,7 +53,6 @@ acpi_pci_data_handler (
59 return_VOID; 53 return_VOID;
60} 54}
61 55
62
63/** 56/**
64 * acpi_get_pci_id 57 * acpi_get_pci_id
65 * ------------------ 58 * ------------------
@@ -67,15 +60,12 @@ acpi_pci_data_handler (
67 * to resolve PCI information for ACPI-PCI devices defined in the namespace. 60 * to resolve PCI information for ACPI-PCI devices defined in the namespace.
68 * This typically occurs when resolving PCI operation region information. 61 * This typically occurs when resolving PCI operation region information.
69 */ 62 */
70acpi_status 63acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
71acpi_get_pci_id (
72 acpi_handle handle,
73 struct acpi_pci_id *id)
74{ 64{
75 int result = 0; 65 int result = 0;
76 acpi_status status = AE_OK; 66 acpi_status status = AE_OK;
77 struct acpi_device *device = NULL; 67 struct acpi_device *device = NULL;
78 struct acpi_pci_data *data = NULL; 68 struct acpi_pci_data *data = NULL;
79 69
80 ACPI_FUNCTION_TRACE("acpi_get_pci_id"); 70 ACPI_FUNCTION_TRACE("acpi_get_pci_id");
81 71
@@ -84,52 +74,50 @@ acpi_get_pci_id (
84 74
85 result = acpi_bus_get_device(handle, &device); 75 result = acpi_bus_get_device(handle, &device);
86 if (result) { 76 if (result) {
87 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 77 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
88 "Invalid ACPI Bus context for device %s\n", 78 "Invalid ACPI Bus context for device %s\n",
89 acpi_device_bid(device))); 79 acpi_device_bid(device)));
90 return_ACPI_STATUS(AE_NOT_EXIST); 80 return_ACPI_STATUS(AE_NOT_EXIST);
91 } 81 }
92 82
93 status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data); 83 status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data);
94 if (ACPI_FAILURE(status) || !data) { 84 if (ACPI_FAILURE(status) || !data) {
95 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 85 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
96 "Invalid ACPI-PCI context for device %s\n", 86 "Invalid ACPI-PCI context for device %s\n",
97 acpi_device_bid(device))); 87 acpi_device_bid(device)));
98 return_ACPI_STATUS(status); 88 return_ACPI_STATUS(status);
99 } 89 }
100 90
101 *id = data->id; 91 *id = data->id;
102 92
103 /* 93 /*
104 id->segment = data->id.segment; 94 id->segment = data->id.segment;
105 id->bus = data->id.bus; 95 id->bus = data->id.bus;
106 id->device = data->id.device; 96 id->device = data->id.device;
107 id->function = data->id.function; 97 id->function = data->id.function;
108 */ 98 */
109 99
110 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 100 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
111 "Device %s has PCI address %02x:%02x:%02x.%02x\n", 101 "Device %s has PCI address %02x:%02x:%02x.%02x\n",
112 acpi_device_bid(device), id->segment, id->bus, 102 acpi_device_bid(device), id->segment, id->bus,
113 id->device, id->function)); 103 id->device, id->function));
114 104
115 return_ACPI_STATUS(AE_OK); 105 return_ACPI_STATUS(AE_OK);
116} 106}
107
117EXPORT_SYMBOL(acpi_get_pci_id); 108EXPORT_SYMBOL(acpi_get_pci_id);
118 109
119 110int acpi_pci_bind(struct acpi_device *device)
120int
121acpi_pci_bind (
122 struct acpi_device *device)
123{ 111{
124 int result = 0; 112 int result = 0;
125 acpi_status status = AE_OK; 113 acpi_status status = AE_OK;
126 struct acpi_pci_data *data = NULL; 114 struct acpi_pci_data *data = NULL;
127 struct acpi_pci_data *pdata = NULL; 115 struct acpi_pci_data *pdata = NULL;
128 char *pathname = NULL; 116 char *pathname = NULL;
129 struct acpi_buffer buffer = {0, NULL}; 117 struct acpi_buffer buffer = { 0, NULL };
130 acpi_handle handle = NULL; 118 acpi_handle handle = NULL;
131 struct pci_dev *dev; 119 struct pci_dev *dev;
132 struct pci_bus *bus; 120 struct pci_bus *bus;
133 121
134 ACPI_FUNCTION_TRACE("acpi_pci_bind"); 122 ACPI_FUNCTION_TRACE("acpi_pci_bind");
135 123
@@ -137,34 +125,34 @@ acpi_pci_bind (
137 return_VALUE(-EINVAL); 125 return_VALUE(-EINVAL);
138 126
139 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 127 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
140 if(!pathname) 128 if (!pathname)
141 return_VALUE(-ENOMEM); 129 return_VALUE(-ENOMEM);
142 memset(pathname, 0, ACPI_PATHNAME_MAX); 130 memset(pathname, 0, ACPI_PATHNAME_MAX);
143 buffer.length = ACPI_PATHNAME_MAX; 131 buffer.length = ACPI_PATHNAME_MAX;
144 buffer.pointer = pathname; 132 buffer.pointer = pathname;
145 133
146 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 134 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
147 if (!data){ 135 if (!data) {
148 kfree (pathname); 136 kfree(pathname);
149 return_VALUE(-ENOMEM); 137 return_VALUE(-ENOMEM);
150 } 138 }
151 memset(data, 0, sizeof(struct acpi_pci_data)); 139 memset(data, 0, sizeof(struct acpi_pci_data));
152 140
153 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 141 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 142 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
155 pathname)); 143 pathname));
156 144
157 /* 145 /*
158 * Segment & Bus 146 * Segment & Bus
159 * ------------- 147 * -------------
160 * These are obtained via the parent device's ACPI-PCI context. 148 * These are obtained via the parent device's ACPI-PCI context.
161 */ 149 */
162 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, 150 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
163 (void**) &pdata); 151 (void **)&pdata);
164 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { 152 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
165 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 153 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
166 "Invalid ACPI-PCI context for parent device %s\n", 154 "Invalid ACPI-PCI context for parent device %s\n",
167 acpi_device_bid(device->parent))); 155 acpi_device_bid(device->parent)));
168 result = -ENODEV; 156 result = -ENODEV;
169 goto end; 157 goto end;
170 } 158 }
@@ -181,8 +169,8 @@ acpi_pci_bind (
181 data->id.function = device->pnp.bus_address & 0xFFFF; 169 data->id.function = device->pnp.bus_address & 0xFFFF;
182 170
183 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", 171 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n",
184 data->id.segment, data->id.bus, data->id.device, 172 data->id.segment, data->id.bus, data->id.device,
185 data->id.function)); 173 data->id.function));
186 174
187 /* 175 /*
188 * TBD: Support slot devices (e.g. function=0xFFFF). 176 * TBD: Support slot devices (e.g. function=0xFFFF).
@@ -202,25 +190,25 @@ acpi_pci_bind (
202 if (bus) { 190 if (bus) {
203 list_for_each_entry(dev, &bus->devices, bus_list) { 191 list_for_each_entry(dev, &bus->devices, bus_list) {
204 if (dev->devfn == PCI_DEVFN(data->id.device, 192 if (dev->devfn == PCI_DEVFN(data->id.device,
205 data->id.function)) { 193 data->id.function)) {
206 data->dev = dev; 194 data->dev = dev;
207 break; 195 break;
208 } 196 }
209 } 197 }
210 } 198 }
211 if (!data->dev) { 199 if (!data->dev) {
212 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 200 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
213 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", 201 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
214 data->id.segment, data->id.bus, 202 data->id.segment, data->id.bus,
215 data->id.device, data->id.function)); 203 data->id.device, data->id.function));
216 result = -ENODEV; 204 result = -ENODEV;
217 goto end; 205 goto end;
218 } 206 }
219 if (!data->dev->bus) { 207 if (!data->dev->bus) {
220 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 208 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
221 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 209 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
222 data->id.segment, data->id.bus, 210 data->id.segment, data->id.bus,
223 data->id.device, data->id.function)); 211 data->id.device, data->id.function));
224 result = -ENODEV; 212 result = -ENODEV;
225 goto end; 213 goto end;
226 } 214 }
@@ -232,10 +220,10 @@ acpi_pci_bind (
232 * facilitate callbacks for all of its children. 220 * facilitate callbacks for all of its children.
233 */ 221 */
234 if (data->dev->subordinate) { 222 if (data->dev->subordinate) {
235 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 223 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
236 "Device %02x:%02x:%02x.%02x is a PCI bridge\n", 224 "Device %02x:%02x:%02x.%02x is a PCI bridge\n",
237 data->id.segment, data->id.bus, 225 data->id.segment, data->id.bus,
238 data->id.device, data->id.function)); 226 data->id.device, data->id.function));
239 data->bus = data->dev->subordinate; 227 data->bus = data->dev->subordinate;
240 device->ops.bind = acpi_pci_bind; 228 device->ops.bind = acpi_pci_bind;
241 device->ops.unbind = acpi_pci_unbind; 229 device->ops.unbind = acpi_pci_unbind;
@@ -249,8 +237,8 @@ acpi_pci_bind (
249 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 237 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
250 if (ACPI_FAILURE(status)) { 238 if (ACPI_FAILURE(status)) {
251 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
252 "Unable to attach ACPI-PCI context to device %s\n", 240 "Unable to attach ACPI-PCI context to device %s\n",
253 acpi_device_bid(device))); 241 acpi_device_bid(device)));
254 result = -ENODEV; 242 result = -ENODEV;
255 goto end; 243 goto end;
256 } 244 }
@@ -267,15 +255,15 @@ acpi_pci_bind (
267 */ 255 */
268 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); 256 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
269 if (ACPI_SUCCESS(status)) { 257 if (ACPI_SUCCESS(status)) {
270 if (data->bus) /* PCI-PCI bridge */ 258 if (data->bus) /* PCI-PCI bridge */
271 acpi_pci_irq_add_prt(device->handle, data->id.segment,
272 data->bus->number);
273 else /* non-bridge PCI device */
274 acpi_pci_irq_add_prt(device->handle, data->id.segment, 259 acpi_pci_irq_add_prt(device->handle, data->id.segment,
275 data->id.bus); 260 data->bus->number);
261 else /* non-bridge PCI device */
262 acpi_pci_irq_add_prt(device->handle, data->id.segment,
263 data->id.bus);
276 } 264 }
277 265
278end: 266 end:
279 kfree(pathname); 267 kfree(pathname);
280 if (result) 268 if (result)
281 kfree(data); 269 kfree(data);
@@ -283,22 +271,21 @@ end:
283 return_VALUE(result); 271 return_VALUE(result);
284} 272}
285 273
286int acpi_pci_unbind( 274int acpi_pci_unbind(struct acpi_device *device)
287 struct acpi_device *device)
288{ 275{
289 int result = 0; 276 int result = 0;
290 acpi_status status = AE_OK; 277 acpi_status status = AE_OK;
291 struct acpi_pci_data *data = NULL; 278 struct acpi_pci_data *data = NULL;
292 char *pathname = NULL; 279 char *pathname = NULL;
293 struct acpi_buffer buffer = {0, NULL}; 280 struct acpi_buffer buffer = { 0, NULL };
294 281
295 ACPI_FUNCTION_TRACE("acpi_pci_unbind"); 282 ACPI_FUNCTION_TRACE("acpi_pci_unbind");
296 283
297 if (!device || !device->parent) 284 if (!device || !device->parent)
298 return_VALUE(-EINVAL); 285 return_VALUE(-EINVAL);
299 286
300 pathname = (char *) kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 287 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
301 if(!pathname) 288 if (!pathname)
302 return_VALUE(-ENOMEM); 289 return_VALUE(-ENOMEM);
303 memset(pathname, 0, ACPI_PATHNAME_MAX); 290 memset(pathname, 0, ACPI_PATHNAME_MAX);
304 291
@@ -306,14 +293,16 @@ int acpi_pci_unbind(
306 buffer.pointer = pathname; 293 buffer.pointer = pathname;
307 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 294 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
308 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", 295 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
309 pathname)); 296 pathname));
310 kfree(pathname); 297 kfree(pathname);
311 298
312 status = acpi_get_data(device->handle, acpi_pci_data_handler, (void**)&data); 299 status =
300 acpi_get_data(device->handle, acpi_pci_data_handler,
301 (void **)&data);
313 if (ACPI_FAILURE(status)) { 302 if (ACPI_FAILURE(status)) {
314 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 303 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
315 "Unable to get data from device %s\n", 304 "Unable to get data from device %s\n",
316 acpi_device_bid(device))); 305 acpi_device_bid(device)));
317 result = -ENODEV; 306 result = -ENODEV;
318 goto end; 307 goto end;
319 } 308 }
@@ -321,8 +310,8 @@ int acpi_pci_unbind(
321 status = acpi_detach_data(device->handle, acpi_pci_data_handler); 310 status = acpi_detach_data(device->handle, acpi_pci_data_handler);
322 if (ACPI_FAILURE(status)) { 311 if (ACPI_FAILURE(status)) {
323 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 312 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
324 "Unable to detach data from device %s\n", 313 "Unable to detach data from device %s\n",
325 acpi_device_bid(device))); 314 acpi_device_bid(device)));
326 result = -ENODEV; 315 result = -ENODEV;
327 goto end; 316 goto end;
328 } 317 }
@@ -331,39 +320,37 @@ int acpi_pci_unbind(
331 } 320 }
332 kfree(data); 321 kfree(data);
333 322
334end: 323 end:
335 return_VALUE(result); 324 return_VALUE(result);
336} 325}
337 326
338int 327int
339acpi_pci_bind_root ( 328acpi_pci_bind_root(struct acpi_device *device,
340 struct acpi_device *device, 329 struct acpi_pci_id *id, struct pci_bus *bus)
341 struct acpi_pci_id *id,
342 struct pci_bus *bus)
343{ 330{
344 int result = 0; 331 int result = 0;
345 acpi_status status = AE_OK; 332 acpi_status status = AE_OK;
346 struct acpi_pci_data *data = NULL; 333 struct acpi_pci_data *data = NULL;
347 char *pathname = NULL; 334 char *pathname = NULL;
348 struct acpi_buffer buffer = {0, NULL}; 335 struct acpi_buffer buffer = { 0, NULL };
349 336
350 ACPI_FUNCTION_TRACE("acpi_pci_bind_root"); 337 ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
351 338
352 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 339 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
353 if(!pathname) 340 if (!pathname)
354 return_VALUE(-ENOMEM); 341 return_VALUE(-ENOMEM);
355 memset(pathname, 0, ACPI_PATHNAME_MAX); 342 memset(pathname, 0, ACPI_PATHNAME_MAX);
356 343
357 buffer.length = ACPI_PATHNAME_MAX; 344 buffer.length = ACPI_PATHNAME_MAX;
358 buffer.pointer = pathname; 345 buffer.pointer = pathname;
359 346
360 if (!device || !id || !bus){ 347 if (!device || !id || !bus) {
361 kfree(pathname); 348 kfree(pathname);
362 return_VALUE(-EINVAL); 349 return_VALUE(-EINVAL);
363 } 350 }
364 351
365 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 352 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
366 if (!data){ 353 if (!data) {
367 kfree(pathname); 354 kfree(pathname);
368 return_VALUE(-ENOMEM); 355 return_VALUE(-ENOMEM);
369 } 356 }
@@ -377,18 +364,18 @@ acpi_pci_bind_root (
377 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 364 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
378 365
379 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " 366 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
380 "%02x:%02x\n", pathname, id->segment, id->bus)); 367 "%02x:%02x\n", pathname, id->segment, id->bus));
381 368
382 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 369 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
383 if (ACPI_FAILURE(status)) { 370 if (ACPI_FAILURE(status)) {
384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 371 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
385 "Unable to attach ACPI-PCI context to device %s\n", 372 "Unable to attach ACPI-PCI context to device %s\n",
386 pathname)); 373 pathname));
387 result = -ENODEV; 374 result = -ENODEV;
388 goto end; 375 goto end;
389 } 376 }
390 377
391end: 378 end:
392 kfree(pathname); 379 kfree(pathname);
393 if (result != 0) 380 if (result != 0)
394 kfree(data); 381 kfree(data);