diff options
author | Markus Lidel <Markus.Lidel@shadowconnect.com> | 2006-01-06 03:19:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 11:33:53 -0500 |
commit | 793fd15d9fafe5b1c71e50d3c041f1463895dbde (patch) | |
tree | a19f3f17b435a3600d19f5a5ee2136b2d3646987 /drivers/message/i2o/device.c | |
parent | a1a5ea70a6e9db6332b27fe2d96666e17aa1436b (diff) |
[PATCH] I2O: SPARC fixes
Fix lot of BE <-> LE bugs which prevent it from working on SPARC.
Signed-off-by: Markus Lidel <Markus.Lidel@shadowconnect.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/message/i2o/device.c')
-rw-r--r-- | drivers/message/i2o/device.c | 130 |
1 files changed, 61 insertions, 69 deletions
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 002ae0ed8966..1db26215937f 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c | |||
@@ -341,56 +341,83 @@ int i2o_device_parse_lct(struct i2o_controller *c) | |||
341 | { | 341 | { |
342 | struct i2o_device *dev, *tmp; | 342 | struct i2o_device *dev, *tmp; |
343 | i2o_lct *lct; | 343 | i2o_lct *lct; |
344 | int i; | 344 | u32 *dlct = c->dlct.virt; |
345 | int max; | 345 | int max = 0, i = 0; |
346 | u16 table_size; | ||
347 | u32 buf; | ||
346 | 348 | ||
347 | down(&c->lct_lock); | 349 | down(&c->lct_lock); |
348 | 350 | ||
349 | kfree(c->lct); | 351 | kfree(c->lct); |
350 | 352 | ||
351 | lct = c->dlct.virt; | 353 | buf = le32_to_cpu(*dlct++); |
354 | table_size = buf & 0xffff; | ||
352 | 355 | ||
353 | c->lct = kmalloc(lct->table_size * 4, GFP_KERNEL); | 356 | lct = c->lct = kmalloc(table_size * 4, GFP_KERNEL); |
354 | if (!c->lct) { | 357 | if (!lct) { |
355 | up(&c->lct_lock); | 358 | up(&c->lct_lock); |
356 | return -ENOMEM; | 359 | return -ENOMEM; |
357 | } | 360 | } |
358 | 361 | ||
359 | if (lct->table_size * 4 > c->dlct.len) { | 362 | lct->lct_ver = buf >> 28; |
360 | memcpy(c->lct, c->dlct.virt, c->dlct.len); | 363 | lct->boot_tid = buf >> 16 & 0xfff; |
361 | up(&c->lct_lock); | 364 | lct->table_size = table_size; |
362 | return -EAGAIN; | 365 | lct->change_ind = le32_to_cpu(*dlct++); |
363 | } | 366 | lct->iop_flags = le32_to_cpu(*dlct++); |
364 | |||
365 | memcpy(c->lct, c->dlct.virt, lct->table_size * 4); | ||
366 | 367 | ||
367 | lct = c->lct; | 368 | table_size -= 3; |
368 | |||
369 | max = (lct->table_size - 3) / 9; | ||
370 | 369 | ||
371 | pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max, | 370 | pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max, |
372 | lct->table_size); | 371 | lct->table_size); |
373 | 372 | ||
374 | /* remove devices, which are not in the LCT anymore */ | 373 | while (table_size > 0) { |
375 | list_for_each_entry_safe(dev, tmp, &c->devices, list) { | 374 | i2o_lct_entry *entry = &lct->lct_entry[max]; |
376 | int found = 0; | 375 | int found = 0; |
377 | 376 | ||
378 | for (i = 0; i < max; i++) { | 377 | buf = le32_to_cpu(*dlct++); |
379 | if (lct->lct_entry[i].tid == dev->lct_data.tid) { | 378 | entry->entry_size = buf & 0xffff; |
379 | entry->tid = buf >> 16 & 0xfff; | ||
380 | |||
381 | entry->change_ind = le32_to_cpu(*dlct++); | ||
382 | entry->device_flags = le32_to_cpu(*dlct++); | ||
383 | |||
384 | buf = le32_to_cpu(*dlct++); | ||
385 | entry->class_id = buf & 0xfff; | ||
386 | entry->version = buf >> 12 & 0xf; | ||
387 | entry->vendor_id = buf >> 16; | ||
388 | |||
389 | entry->sub_class = le32_to_cpu(*dlct++); | ||
390 | |||
391 | buf = le32_to_cpu(*dlct++); | ||
392 | entry->user_tid = buf & 0xfff; | ||
393 | entry->parent_tid = buf >> 12 & 0xfff; | ||
394 | entry->bios_info = buf >> 24; | ||
395 | |||
396 | memcpy(&entry->identity_tag, dlct, 8); | ||
397 | dlct += 2; | ||
398 | |||
399 | entry->event_capabilities = le32_to_cpu(*dlct++); | ||
400 | |||
401 | /* add new devices, which are new in the LCT */ | ||
402 | list_for_each_entry_safe(dev, tmp, &c->devices, list) { | ||
403 | if (entry->tid == dev->lct_data.tid) { | ||
380 | found = 1; | 404 | found = 1; |
381 | break; | 405 | break; |
382 | } | 406 | } |
383 | } | 407 | } |
384 | 408 | ||
385 | if (!found) | 409 | if (!found) |
386 | i2o_device_remove(dev); | 410 | i2o_device_add(c, entry); |
411 | |||
412 | table_size -= 9; | ||
413 | max++; | ||
387 | } | 414 | } |
388 | 415 | ||
389 | /* add new devices, which are new in the LCT */ | 416 | /* remove devices, which are not in the LCT anymore */ |
390 | for (i = 0; i < max; i++) { | 417 | list_for_each_entry_safe(dev, tmp, &c->devices, list) { |
391 | int found = 0; | 418 | int found = 0; |
392 | 419 | ||
393 | list_for_each_entry_safe(dev, tmp, &c->devices, list) { | 420 | for (i = 0; i < max; i++) { |
394 | if (lct->lct_entry[i].tid == dev->lct_data.tid) { | 421 | if (lct->lct_entry[i].tid == dev->lct_data.tid) { |
395 | found = 1; | 422 | found = 1; |
396 | break; | 423 | break; |
@@ -398,8 +425,9 @@ int i2o_device_parse_lct(struct i2o_controller *c) | |||
398 | } | 425 | } |
399 | 426 | ||
400 | if (!found) | 427 | if (!found) |
401 | i2o_device_add(c, &lct->lct_entry[i]); | 428 | i2o_device_remove(dev); |
402 | } | 429 | } |
430 | |||
403 | up(&c->lct_lock); | 431 | up(&c->lct_lock); |
404 | 432 | ||
405 | return 0; | 433 | return 0; |
@@ -422,9 +450,6 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, | |||
422 | int oplen, void *reslist, int reslen) | 450 | int oplen, void *reslist, int reslen) |
423 | { | 451 | { |
424 | struct i2o_message *msg; | 452 | struct i2o_message *msg; |
425 | u32 *res32 = (u32 *) reslist; | ||
426 | u32 *restmp = (u32 *) reslist; | ||
427 | int len = 0; | ||
428 | int i = 0; | 453 | int i = 0; |
429 | int rc; | 454 | int rc; |
430 | struct i2o_dma res; | 455 | struct i2o_dma res; |
@@ -448,7 +473,6 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, | |||
448 | msg->body[i++] = cpu_to_le32(0x00000000); | 473 | msg->body[i++] = cpu_to_le32(0x00000000); |
449 | msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */ | 474 | msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */ |
450 | memcpy(&msg->body[i], oplist, oplen); | 475 | memcpy(&msg->body[i], oplist, oplen); |
451 | |||
452 | i += (oplen / 4 + (oplen % 4 ? 1 : 0)); | 476 | i += (oplen / 4 + (oplen % 4 ? 1 : 0)); |
453 | msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */ | 477 | msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */ |
454 | msg->body[i++] = cpu_to_le32(res.phys); | 478 | msg->body[i++] = cpu_to_le32(res.phys); |
@@ -466,36 +490,7 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, | |||
466 | memcpy(reslist, res.virt, res.len); | 490 | memcpy(reslist, res.virt, res.len); |
467 | i2o_dma_free(dev, &res); | 491 | i2o_dma_free(dev, &res); |
468 | 492 | ||
469 | /* Query failed */ | 493 | return rc; |
470 | if (rc) | ||
471 | return rc; | ||
472 | /* | ||
473 | * Calculate number of bytes of Result LIST | ||
474 | * We need to loop through each Result BLOCK and grab the length | ||
475 | */ | ||
476 | restmp = res32 + 1; | ||
477 | len = 1; | ||
478 | for (i = 0; i < (res32[0] & 0X0000FFFF); i++) { | ||
479 | if (restmp[0] & 0x00FF0000) { /* BlockStatus != SUCCESS */ | ||
480 | printk(KERN_WARNING | ||
481 | "%s - Error:\n ErrorInfoSize = 0x%02x, " | ||
482 | "BlockStatus = 0x%02x, BlockSize = 0x%04x\n", | ||
483 | (cmd == | ||
484 | I2O_CMD_UTIL_PARAMS_SET) ? "PARAMS_SET" : | ||
485 | "PARAMS_GET", res32[1] >> 24, | ||
486 | (res32[1] >> 16) & 0xFF, res32[1] & 0xFFFF); | ||
487 | |||
488 | /* | ||
489 | * If this is the only request,than we return an error | ||
490 | */ | ||
491 | if ((res32[0] & 0x0000FFFF) == 1) { | ||
492 | return -((res32[1] >> 16) & 0xFF); /* -BlockStatus */ | ||
493 | } | ||
494 | } | ||
495 | len += restmp[0] & 0x0000FFFF; /* Length of res BLOCK */ | ||
496 | restmp += restmp[0] & 0x0000FFFF; /* Skip to next BLOCK */ | ||
497 | } | ||
498 | return (len << 2); /* bytes used by result list */ | ||
499 | } | 494 | } |
500 | 495 | ||
501 | /* | 496 | /* |
@@ -504,28 +499,25 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, | |||
504 | int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field, | 499 | int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field, |
505 | void *buf, int buflen) | 500 | void *buf, int buflen) |
506 | { | 501 | { |
507 | u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field }; | 502 | u32 opblk[] = { cpu_to_le32(0x00000001), |
503 | cpu_to_le32((u16) group << 16 | I2O_PARAMS_FIELD_GET), | ||
504 | cpu_to_le32((s16) field << 16 | 0x00000001) | ||
505 | }; | ||
508 | u8 *resblk; /* 8 bytes for header */ | 506 | u8 *resblk; /* 8 bytes for header */ |
509 | int size; | 507 | int rc; |
510 | |||
511 | if (field == -1) /* whole group */ | ||
512 | opblk[4] = -1; | ||
513 | 508 | ||
514 | resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC); | 509 | resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC); |
515 | if (!resblk) | 510 | if (!resblk) |
516 | return -ENOMEM; | 511 | return -ENOMEM; |
517 | 512 | ||
518 | size = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk, | 513 | rc = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk, |
519 | sizeof(opblk), resblk, buflen + 8); | 514 | sizeof(opblk), resblk, buflen + 8); |
520 | 515 | ||
521 | memcpy(buf, resblk + 8, buflen); /* cut off header */ | 516 | memcpy(buf, resblk + 8, buflen); /* cut off header */ |
522 | 517 | ||
523 | kfree(resblk); | 518 | kfree(resblk); |
524 | 519 | ||
525 | if (size > buflen) | 520 | return rc; |
526 | return buflen; | ||
527 | |||
528 | return size; | ||
529 | } | 521 | } |
530 | 522 | ||
531 | /* | 523 | /* |