aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/eisa/eisa-bus.c
diff options
context:
space:
mode:
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>2010-03-05 16:42:48 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 14:26:32 -0500
commit33fd797b3e2c6a7663b9331150da0acdb31990a2 (patch)
tree50f465fa034f4a5f819ec5e60d8ea3eca920e66e /drivers/eisa/eisa-bus.c
parent08d9e7363b87a4c5fb3fc17070607a75a9eb4cc8 (diff)
eisa: fix coding style for eisa bus code
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Greg Kroah-Hartman <gregkh@suse.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/eisa/eisa-bus.c')
-rw-r--r--drivers/eisa/eisa-bus.c240
1 files changed, 128 insertions, 112 deletions
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 66958b3f10b4..806c77bfd434 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -39,10 +39,10 @@ static unsigned int enable_dev_count;
39static int disable_dev[EISA_MAX_FORCED_DEV]; 39static int disable_dev[EISA_MAX_FORCED_DEV];
40static unsigned int disable_dev_count; 40static unsigned int disable_dev_count;
41 41
42static int is_forced_dev (int *forced_tab, 42static int is_forced_dev(int *forced_tab,
43 int forced_count, 43 int forced_count,
44 struct eisa_root_device *root, 44 struct eisa_root_device *root,
45 struct eisa_device *edev) 45 struct eisa_device *edev)
46{ 46{
47 int i, x; 47 int i, x;
48 48
@@ -55,21 +55,21 @@ static int is_forced_dev (int *forced_tab,
55 return 0; 55 return 0;
56} 56}
57 57
58static void __init eisa_name_device (struct eisa_device *edev) 58static void __init eisa_name_device(struct eisa_device *edev)
59{ 59{
60#ifdef CONFIG_EISA_NAMES 60#ifdef CONFIG_EISA_NAMES
61 int i; 61 int i;
62 for (i = 0; i < EISA_INFOS; i++) { 62 for (i = 0; i < EISA_INFOS; i++) {
63 if (!strcmp (edev->id.sig, eisa_table[i].id.sig)) { 63 if (!strcmp(edev->id.sig, eisa_table[i].id.sig)) {
64 strlcpy (edev->pretty_name, 64 strlcpy(edev->pretty_name,
65 eisa_table[i].name, 65 eisa_table[i].name,
66 sizeof(edev->pretty_name)); 66 sizeof(edev->pretty_name));
67 return; 67 return;
68 } 68 }
69 } 69 }
70 70
71 /* No name was found */ 71 /* No name was found */
72 sprintf (edev->pretty_name, "EISA device %.7s", edev->id.sig); 72 sprintf(edev->pretty_name, "EISA device %.7s", edev->id.sig);
73#endif 73#endif
74} 74}
75 75
@@ -91,7 +91,7 @@ static char __init *decode_eisa_sig(unsigned long addr)
91 */ 91 */
92 outb(0x80 + i, addr); 92 outb(0x80 + i, addr);
93#endif 93#endif
94 sig[i] = inb (addr + i); 94 sig[i] = inb(addr + i);
95 95
96 if (!i && (sig[0] & 0x80)) 96 if (!i && (sig[0] & 0x80))
97 return NULL; 97 return NULL;
@@ -106,17 +106,17 @@ static char __init *decode_eisa_sig(unsigned long addr)
106 return sig_str; 106 return sig_str;
107} 107}
108 108
109static int eisa_bus_match (struct device *dev, struct device_driver *drv) 109static int eisa_bus_match(struct device *dev, struct device_driver *drv)
110{ 110{
111 struct eisa_device *edev = to_eisa_device (dev); 111 struct eisa_device *edev = to_eisa_device(dev);
112 struct eisa_driver *edrv = to_eisa_driver (drv); 112 struct eisa_driver *edrv = to_eisa_driver(drv);
113 const struct eisa_device_id *eids = edrv->id_table; 113 const struct eisa_device_id *eids = edrv->id_table;
114 114
115 if (!eids) 115 if (!eids)
116 return 0; 116 return 0;
117 117
118 while (strlen (eids->sig)) { 118 while (strlen(eids->sig)) {
119 if (!strcmp (eids->sig, edev->id.sig) && 119 if (!strcmp(eids->sig, edev->id.sig) &&
120 edev->state & EISA_CONFIG_ENABLED) { 120 edev->state & EISA_CONFIG_ENABLED) {
121 edev->id.driver_data = eids->driver_data; 121 edev->id.driver_data = eids->driver_data;
122 return 1; 122 return 1;
@@ -141,61 +141,71 @@ struct bus_type eisa_bus_type = {
141 .match = eisa_bus_match, 141 .match = eisa_bus_match,
142 .uevent = eisa_bus_uevent, 142 .uevent = eisa_bus_uevent,
143}; 143};
144EXPORT_SYMBOL(eisa_bus_type);
144 145
145int eisa_driver_register (struct eisa_driver *edrv) 146int eisa_driver_register(struct eisa_driver *edrv)
146{ 147{
147 edrv->driver.bus = &eisa_bus_type; 148 edrv->driver.bus = &eisa_bus_type;
148 return driver_register (&edrv->driver); 149 return driver_register(&edrv->driver);
149} 150}
151EXPORT_SYMBOL(eisa_driver_register);
150 152
151void eisa_driver_unregister (struct eisa_driver *edrv) 153void eisa_driver_unregister(struct eisa_driver *edrv)
152{ 154{
153 driver_unregister (&edrv->driver); 155 driver_unregister(&edrv->driver);
154} 156}
157EXPORT_SYMBOL(eisa_driver_unregister);
155 158
156static ssize_t eisa_show_sig (struct device *dev, struct device_attribute *attr, char *buf) 159static ssize_t eisa_show_sig(struct device *dev, struct device_attribute *attr,
160 char *buf)
157{ 161{
158 struct eisa_device *edev = to_eisa_device (dev); 162 struct eisa_device *edev = to_eisa_device(dev);
159 return sprintf (buf,"%s\n", edev->id.sig); 163 return sprintf(buf, "%s\n", edev->id.sig);
160} 164}
161 165
162static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL); 166static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL);
163 167
164static ssize_t eisa_show_state (struct device *dev, struct device_attribute *attr, char *buf) 168static ssize_t eisa_show_state(struct device *dev,
169 struct device_attribute *attr,
170 char *buf)
165{ 171{
166 struct eisa_device *edev = to_eisa_device (dev); 172 struct eisa_device *edev = to_eisa_device(dev);
167 return sprintf (buf,"%d\n", edev->state & EISA_CONFIG_ENABLED); 173 return sprintf(buf, "%d\n", edev->state & EISA_CONFIG_ENABLED);
168} 174}
169 175
170static DEVICE_ATTR(enabled, S_IRUGO, eisa_show_state, NULL); 176static DEVICE_ATTR(enabled, S_IRUGO, eisa_show_state, NULL);
171 177
172static ssize_t eisa_show_modalias (struct device *dev, struct device_attribute *attr, char *buf) 178static ssize_t eisa_show_modalias(struct device *dev,
179 struct device_attribute *attr,
180 char *buf)
173{ 181{
174 struct eisa_device *edev = to_eisa_device (dev); 182 struct eisa_device *edev = to_eisa_device(dev);
175 return sprintf (buf, EISA_DEVICE_MODALIAS_FMT "\n", edev->id.sig); 183 return sprintf(buf, EISA_DEVICE_MODALIAS_FMT "\n", edev->id.sig);
176} 184}
177 185
178static DEVICE_ATTR(modalias, S_IRUGO, eisa_show_modalias, NULL); 186static DEVICE_ATTR(modalias, S_IRUGO, eisa_show_modalias, NULL);
179 187
180static int __init eisa_init_device (struct eisa_root_device *root, 188static int __init eisa_init_device(struct eisa_root_device *root,
181 struct eisa_device *edev, 189 struct eisa_device *edev,
182 int slot) 190 int slot)
183{ 191{
184 char *sig; 192 char *sig;
185 unsigned long sig_addr; 193 unsigned long sig_addr;
186 int i; 194 int i;
187 195
188 sig_addr = SLOT_ADDRESS (root, slot) + EISA_VENDOR_ID_OFFSET; 196 sig_addr = SLOT_ADDRESS(root, slot) + EISA_VENDOR_ID_OFFSET;
189 197
190 if (!(sig = decode_eisa_sig (sig_addr))) 198 sig = decode_eisa_sig(sig_addr);
199 if (!sig)
191 return -1; /* No EISA device here */ 200 return -1; /* No EISA device here */
192 201
193 memcpy (edev->id.sig, sig, EISA_SIG_LEN); 202 memcpy(edev->id.sig, sig, EISA_SIG_LEN);
194 edev->slot = slot; 203 edev->slot = slot;
195 edev->state = inb (SLOT_ADDRESS (root, slot) + EISA_CONFIG_OFFSET) & EISA_CONFIG_ENABLED; 204 edev->state = inb(SLOT_ADDRESS(root, slot) + EISA_CONFIG_OFFSET)
196 edev->base_addr = SLOT_ADDRESS (root, slot); 205 & EISA_CONFIG_ENABLED;
206 edev->base_addr = SLOT_ADDRESS(root, slot);
197 edev->dma_mask = root->dma_mask; /* Default DMA mask */ 207 edev->dma_mask = root->dma_mask; /* Default DMA mask */
198 eisa_name_device (edev); 208 eisa_name_device(edev);
199 edev->dev.parent = root->dev; 209 edev->dev.parent = root->dev;
200 edev->dev.bus = &eisa_bus_type; 210 edev->dev.bus = &eisa_bus_type;
201 edev->dev.dma_mask = &edev->dma_mask; 211 edev->dev.dma_mask = &edev->dma_mask;
@@ -210,42 +220,45 @@ static int __init eisa_init_device (struct eisa_root_device *root,
210#endif 220#endif
211 } 221 }
212 222
213 if (is_forced_dev (enable_dev, enable_dev_count, root, edev)) 223 if (is_forced_dev(enable_dev, enable_dev_count, root, edev))
214 edev->state = EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED; 224 edev->state = EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED;
215 225
216 if (is_forced_dev (disable_dev, disable_dev_count, root, edev)) 226 if (is_forced_dev(disable_dev, disable_dev_count, root, edev))
217 edev->state = EISA_CONFIG_FORCED; 227 edev->state = EISA_CONFIG_FORCED;
218 228
219 return 0; 229 return 0;
220} 230}
221 231
222static int __init eisa_register_device (struct eisa_device *edev) 232static int __init eisa_register_device(struct eisa_device *edev)
223{ 233{
224 int rc = device_register (&edev->dev); 234 int rc = device_register(&edev->dev);
225 if (rc) 235 if (rc)
226 return rc; 236 return rc;
227 237
228 rc = device_create_file (&edev->dev, &dev_attr_signature); 238 rc = device_create_file(&edev->dev, &dev_attr_signature);
229 if (rc) goto err_devreg; 239 if (rc)
230 rc = device_create_file (&edev->dev, &dev_attr_enabled); 240 goto err_devreg;
231 if (rc) goto err_sig; 241 rc = device_create_file(&edev->dev, &dev_attr_enabled);
232 rc = device_create_file (&edev->dev, &dev_attr_modalias); 242 if (rc)
233 if (rc) goto err_enab; 243 goto err_sig;
244 rc = device_create_file(&edev->dev, &dev_attr_modalias);
245 if (rc)
246 goto err_enab;
234 247
235 return 0; 248 return 0;
236 249
237err_enab: 250err_enab:
238 device_remove_file (&edev->dev, &dev_attr_enabled); 251 device_remove_file(&edev->dev, &dev_attr_enabled);
239err_sig: 252err_sig:
240 device_remove_file (&edev->dev, &dev_attr_signature); 253 device_remove_file(&edev->dev, &dev_attr_signature);
241err_devreg: 254err_devreg:
242 device_unregister(&edev->dev); 255 device_unregister(&edev->dev);
243 return rc; 256 return rc;
244} 257}
245 258
246static int __init eisa_request_resources (struct eisa_root_device *root, 259static int __init eisa_request_resources(struct eisa_root_device *root,
247 struct eisa_device *edev, 260 struct eisa_device *edev,
248 int slot) 261 int slot)
249{ 262{
250 int i; 263 int i;
251 264
@@ -263,17 +276,19 @@ static int __init eisa_request_resources (struct eisa_root_device *root,
263 276
264 if (slot) { 277 if (slot) {
265 edev->res[i].name = NULL; 278 edev->res[i].name = NULL;
266 edev->res[i].start = SLOT_ADDRESS (root, slot) + (i * 0x400); 279 edev->res[i].start = SLOT_ADDRESS(root, slot)
280 + (i * 0x400);
267 edev->res[i].end = edev->res[i].start + 0xff; 281 edev->res[i].end = edev->res[i].start + 0xff;
268 edev->res[i].flags = IORESOURCE_IO; 282 edev->res[i].flags = IORESOURCE_IO;
269 } else { 283 } else {
270 edev->res[i].name = NULL; 284 edev->res[i].name = NULL;
271 edev->res[i].start = SLOT_ADDRESS (root, slot) + EISA_VENDOR_ID_OFFSET; 285 edev->res[i].start = SLOT_ADDRESS(root, slot)
286 + EISA_VENDOR_ID_OFFSET;
272 edev->res[i].end = edev->res[i].start + 3; 287 edev->res[i].end = edev->res[i].start + 3;
273 edev->res[i].flags = IORESOURCE_BUSY; 288 edev->res[i].flags = IORESOURCE_BUSY;
274 } 289 }
275 290
276 if (request_resource (root->res, &edev->res[i])) 291 if (request_resource(root->res, &edev->res[i]))
277 goto failed; 292 goto failed;
278 } 293 }
279 294
@@ -281,99 +296,100 @@ static int __init eisa_request_resources (struct eisa_root_device *root,
281 296
282 failed: 297 failed:
283 while (--i >= 0) 298 while (--i >= 0)
284 release_resource (&edev->res[i]); 299 release_resource(&edev->res[i]);
285 300
286 return -1; 301 return -1;
287} 302}
288 303
289static void __init eisa_release_resources (struct eisa_device *edev) 304static void __init eisa_release_resources(struct eisa_device *edev)
290{ 305{
291 int i; 306 int i;
292 307
293 for (i = 0; i < EISA_MAX_RESOURCES; i++) 308 for (i = 0; i < EISA_MAX_RESOURCES; i++)
294 if (edev->res[i].start || edev->res[i].end) 309 if (edev->res[i].start || edev->res[i].end)
295 release_resource (&edev->res[i]); 310 release_resource(&edev->res[i]);
296} 311}
297 312
298static int __init eisa_probe (struct eisa_root_device *root) 313static int __init eisa_probe(struct eisa_root_device *root)
299{ 314{
300 int i, c; 315 int i, c;
301 struct eisa_device *edev; 316 struct eisa_device *edev;
302 317
303 printk (KERN_INFO "EISA: Probing bus %d at %s\n", 318 printk(KERN_INFO "EISA: Probing bus %d at %s\n",
304 root->bus_nr, dev_name(root->dev)); 319 root->bus_nr, dev_name(root->dev));
305 320
306 /* First try to get hold of slot 0. If there is no device 321 /* First try to get hold of slot 0. If there is no device
307 * here, simply fail, unless root->force_probe is set. */ 322 * here, simply fail, unless root->force_probe is set. */
308 323
309 if (!(edev = kzalloc (sizeof (*edev), GFP_KERNEL))) { 324 edev = kzalloc(sizeof(*edev), GFP_KERNEL);
310 printk (KERN_ERR "EISA: Couldn't allocate mainboard slot\n"); 325 if (!edev) {
326 printk(KERN_ERR "EISA: Couldn't allocate mainboard slot\n");
311 return -ENOMEM; 327 return -ENOMEM;
312 } 328 }
313 329
314 if (eisa_request_resources (root, edev, 0)) { 330 if (eisa_request_resources(root, edev, 0)) {
315 printk (KERN_WARNING \ 331 printk(KERN_WARNING \
316 "EISA: Cannot allocate resource for mainboard\n"); 332 "EISA: Cannot allocate resource for mainboard\n");
317 kfree (edev); 333 kfree(edev);
318 if (!root->force_probe) 334 if (!root->force_probe)
319 return -EBUSY; 335 return -EBUSY;
320 goto force_probe; 336 goto force_probe;
321 } 337 }
322 338
323 if (eisa_init_device (root, edev, 0)) { 339 if (eisa_init_device(root, edev, 0)) {
324 eisa_release_resources (edev); 340 eisa_release_resources(edev);
325 kfree (edev); 341 kfree(edev);
326 if (!root->force_probe) 342 if (!root->force_probe)
327 return -ENODEV; 343 return -ENODEV;
328 goto force_probe; 344 goto force_probe;
329 } 345 }
330 346
331 printk (KERN_INFO "EISA: Mainboard %s detected.\n", edev->id.sig); 347 printk(KERN_INFO "EISA: Mainboard %s detected.\n", edev->id.sig);
332 348
333 if (eisa_register_device (edev)) { 349 if (eisa_register_device(edev)) {
334 printk (KERN_ERR "EISA: Failed to register %s\n", 350 printk(KERN_ERR "EISA: Failed to register %s\n",
335 edev->id.sig); 351 edev->id.sig);
336 eisa_release_resources (edev); 352 eisa_release_resources(edev);
337 kfree (edev); 353 kfree(edev);
338 } 354 }
339 355
340 force_probe: 356 force_probe:
341 357
342 for (c = 0, i = 1; i <= root->slots; i++) { 358 for (c = 0, i = 1; i <= root->slots; i++) {
343 if (!(edev = kzalloc (sizeof (*edev), GFP_KERNEL))) { 359 edev = kzalloc(sizeof(*edev), GFP_KERNEL);
344 printk (KERN_ERR "EISA: Out of memory for slot %d\n", 360 if (!edev) {
345 i); 361 printk(KERN_ERR "EISA: Out of memory for slot %d\n", i);
346 continue; 362 continue;
347 } 363 }
348 364
349 if (eisa_request_resources (root, edev, i)) { 365 if (eisa_request_resources(root, edev, i)) {
350 printk (KERN_WARNING \ 366 printk(KERN_WARNING \
351 "Cannot allocate resource for EISA slot %d\n", 367 "Cannot allocate resource for EISA slot %d\n",
352 i); 368 i);
353 kfree (edev); 369 kfree(edev);
354 continue; 370 continue;
355 } 371 }
356 372
357 if (eisa_init_device (root, edev, i)) { 373 if (eisa_init_device(root, edev, i)) {
358 eisa_release_resources (edev); 374 eisa_release_resources(edev);
359 kfree (edev); 375 kfree(edev);
360 continue; 376 continue;
361 } 377 }
362 378
363 printk (KERN_INFO "EISA: slot %d : %s detected", 379 printk(KERN_INFO "EISA: slot %d : %s detected",
364 i, edev->id.sig); 380 i, edev->id.sig);
365 381
366 switch (edev->state) { 382 switch (edev->state) {
367 case EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED: 383 case EISA_CONFIG_ENABLED | EISA_CONFIG_FORCED:
368 printk (" (forced enabled)"); 384 printk(" (forced enabled)");
369 break; 385 break;
370 386
371 case EISA_CONFIG_FORCED: 387 case EISA_CONFIG_FORCED:
372 printk (" (forced disabled)"); 388 printk(" (forced disabled)");
373 break; 389 break;
374 390
375 case 0: 391 case 0:
376 printk (" (disabled)"); 392 printk(" (disabled)");
377 break; 393 break;
378 } 394 }
379 395
@@ -381,15 +397,15 @@ static int __init eisa_probe (struct eisa_root_device *root)
381 397
382 c++; 398 c++;
383 399
384 if (eisa_register_device (edev)) { 400 if (eisa_register_device(edev)) {
385 printk (KERN_ERR "EISA: Failed to register %s\n", 401 printk(KERN_ERR "EISA: Failed to register %s\n",
386 edev->id.sig); 402 edev->id.sig);
387 eisa_release_resources (edev); 403 eisa_release_resources(edev);
388 kfree (edev); 404 kfree(edev);
389 } 405 }
390 } 406 }
391 407
392 printk (KERN_INFO "EISA: Detected %d card%s.\n", c, c == 1 ? "" : "s"); 408 printk(KERN_INFO "EISA: Detected %d card%s.\n", c, c == 1 ? "" : "s");
393 409
394 return 0; 410 return 0;
395} 411}
@@ -403,7 +419,7 @@ static struct resource eisa_root_res = {
403 419
404static int eisa_bus_count; 420static int eisa_bus_count;
405 421
406int __init eisa_root_register (struct eisa_root_device *root) 422int __init eisa_root_register(struct eisa_root_device *root)
407{ 423{
408 int err; 424 int err;
409 425
@@ -417,35 +433,35 @@ int __init eisa_root_register (struct eisa_root_device *root)
417 root->eisa_root_res.end = root->res->end; 433 root->eisa_root_res.end = root->res->end;
418 root->eisa_root_res.flags = IORESOURCE_BUSY; 434 root->eisa_root_res.flags = IORESOURCE_BUSY;
419 435
420 if ((err = request_resource (&eisa_root_res, &root->eisa_root_res))) 436 err = request_resource(&eisa_root_res, &root->eisa_root_res);
437 if (err)
421 return err; 438 return err;
422 439
423 root->bus_nr = eisa_bus_count++; 440 root->bus_nr = eisa_bus_count++;
424 441
425 if ((err = eisa_probe (root))) 442 err = eisa_probe(root);
426 release_resource (&root->eisa_root_res); 443 if (err)
444 release_resource(&root->eisa_root_res);
427 445
428 return err; 446 return err;
429} 447}
430 448
431static int __init eisa_init (void) 449static int __init eisa_init(void)
432{ 450{
433 int r; 451 int r;
434 452
435 if ((r = bus_register (&eisa_bus_type))) 453 r = bus_register(&eisa_bus_type);
454 if (r)
436 return r; 455 return r;
437 456
438 printk (KERN_INFO "EISA bus registered\n"); 457 printk(KERN_INFO "EISA bus registered\n");
439 return 0; 458 return 0;
440} 459}
441 460
442module_param_array(enable_dev, int, &enable_dev_count, 0444); 461module_param_array(enable_dev, int, &enable_dev_count, 0444);
443module_param_array(disable_dev, int, &disable_dev_count, 0444); 462module_param_array(disable_dev, int, &disable_dev_count, 0444);
444 463
445postcore_initcall (eisa_init); 464postcore_initcall(eisa_init);
446 465
447int EISA_bus; /* for legacy drivers */ 466int EISA_bus; /* for legacy drivers */
448EXPORT_SYMBOL (EISA_bus); 467EXPORT_SYMBOL(EISA_bus);
449EXPORT_SYMBOL (eisa_bus_type);
450EXPORT_SYMBOL (eisa_driver_register);
451EXPORT_SYMBOL (eisa_driver_unregister);