aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2005-11-07 06:31:39 -0500
committerJody McIntyre <scjody@modernduck.com>2005-11-07 06:31:39 -0500
commita237f35fdd81d85037dccdacd2e94028227b59fb (patch)
tree5ca5603e74e9c92464173187c6c84640115a416f
parente309fc6d71d61bb0f049ab6d0da10c845da9513f (diff)
sbp2, ohci1394 cleanups:
sbp2: various code formatting cleanups ohci1394: remove form feed characters Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Jody McIntyre <scjody@modernduck.com>
-rw-r--r--drivers/ieee1394/ohci1394.c5
-rw-r--r--drivers/ieee1394/sbp2.c433
-rw-r--r--drivers/ieee1394/sbp2.h15
3 files changed, 224 insertions, 229 deletions
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 4cf9b8f3e336..dcb5776e5c44 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -3201,8 +3201,6 @@ static struct hpsb_host_driver ohci1394_driver = {
3201 .hw_csr_reg = ohci_hw_csr_reg, 3201 .hw_csr_reg = ohci_hw_csr_reg,
3202}; 3202};
3203 3203
3204
3205
3206/*********************************** 3204/***********************************
3207 * PCI Driver Interface functions * 3205 * PCI Driver Interface functions *
3208 ***********************************/ 3206 ***********************************/
@@ -3606,8 +3604,6 @@ static struct pci_driver ohci1394_pci_driver = {
3606 .suspend = ohci1394_pci_suspend, 3604 .suspend = ohci1394_pci_suspend,
3607}; 3605};
3608 3606
3609
3610
3611/*********************************** 3607/***********************************
3612 * OHCI1394 Video Interface * 3608 * OHCI1394 Video Interface *
3613 ***********************************/ 3609 ***********************************/
@@ -3714,7 +3710,6 @@ EXPORT_SYMBOL(ohci1394_init_iso_tasklet);
3714EXPORT_SYMBOL(ohci1394_register_iso_tasklet); 3710EXPORT_SYMBOL(ohci1394_register_iso_tasklet);
3715EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet); 3711EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet);
3716 3712
3717
3718/*********************************** 3713/***********************************
3719 * General module initialization * 3714 * General module initialization *
3720 ***********************************/ 3715 ***********************************/
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 747dbd1c3c9c..073ede9d3b48 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -151,18 +151,15 @@ static int force_inquiry_hack;
151module_param(force_inquiry_hack, int, 0444); 151module_param(force_inquiry_hack, int, 0444);
152MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); 152MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)");
153 153
154
155/* 154/*
156 * Export information about protocols/devices supported by this driver. 155 * Export information about protocols/devices supported by this driver.
157 */ 156 */
158static struct ieee1394_device_id sbp2_id_table[] = { 157static struct ieee1394_device_id sbp2_id_table[] = {
159 { 158 {
160 .match_flags =IEEE1394_MATCH_SPECIFIER_ID | 159 .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
161 IEEE1394_MATCH_VERSION, 160 .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
162 .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, 161 .version = SBP2_SW_VERSION_ENTRY & 0xffffff},
163 .version = SBP2_SW_VERSION_ENTRY & 0xffffff 162 {}
164 },
165 { }
166}; 163};
167 164
168MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); 165MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
@@ -221,7 +218,6 @@ static u32 global_outstanding_dmas = 0;
221 218
222#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) 219#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
223 220
224
225/* 221/*
226 * Globals 222 * Globals
227 */ 223 */
@@ -254,8 +250,8 @@ static struct hpsb_address_ops sbp2_ops = {
254 250
255#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA 251#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
256static struct hpsb_address_ops sbp2_physdma_ops = { 252static struct hpsb_address_ops sbp2_physdma_ops = {
257 .read = sbp2_handle_physdma_read, 253 .read = sbp2_handle_physdma_read,
258 .write = sbp2_handle_physdma_write, 254 .write = sbp2_handle_physdma_write,
259}; 255};
260#endif 256#endif
261 257
@@ -287,7 +283,6 @@ static u32 sbp2_broken_inquiry_list[] = {
287 * General utility functions 283 * General utility functions
288 **************************************/ 284 **************************************/
289 285
290
291#ifndef __BIG_ENDIAN 286#ifndef __BIG_ENDIAN
292/* 287/*
293 * Converts a buffer from be32 to cpu byte ordering. Length is in bytes. 288 * Converts a buffer from be32 to cpu byte ordering. Length is in bytes.
@@ -324,7 +319,8 @@ static __inline__ void sbp2util_cpu_to_be32_buffer(void *buffer, int length)
324/* 319/*
325 * Debug packet dump routine. Length is in bytes. 320 * Debug packet dump routine. Length is in bytes.
326 */ 321 */
327static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 dump_phys_addr) 322static void sbp2util_packet_dump(void *buffer, int length, char *dump_name,
323 u32 dump_phys_addr)
328{ 324{
329 int i; 325 int i;
330 unsigned char *dump = buffer; 326 unsigned char *dump = buffer;
@@ -345,7 +341,7 @@ static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32
345 printk(" "); 341 printk(" ");
346 if ((i & 0xf) == 0) 342 if ((i & 0xf) == 0)
347 printk("\n "); 343 printk("\n ");
348 printk("%02x ", (int) dump[i]); 344 printk("%02x ", (int)dump[i]);
349 } 345 }
350 printk("\n"); 346 printk("\n");
351 347
@@ -364,9 +360,9 @@ static int sbp2util_down_timeout(atomic_t *done, int timeout)
364 360
365 for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { 361 for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) {
366 if (msleep_interruptible(100)) /* 100ms */ 362 if (msleep_interruptible(100)) /* 100ms */
367 return(1); 363 return 1;
368 } 364 }
369 return ((i > 0) ? 0:1); 365 return (i > 0) ? 0 : 1;
370} 366}
371 367
372/* Free's an allocated packet */ 368/* Free's an allocated packet */
@@ -380,21 +376,22 @@ static void sbp2_free_packet(struct hpsb_packet *packet)
380 * subaction and returns immediately. Can be used from interrupts. 376 * subaction and returns immediately. Can be used from interrupts.
381 */ 377 */
382static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, 378static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr,
383 quadlet_t *buffer, size_t length) 379 quadlet_t *buffer, size_t length)
384{ 380{
385 struct hpsb_packet *packet; 381 struct hpsb_packet *packet;
386 382
387 packet = hpsb_make_writepacket(ne->host, ne->nodeid, 383 packet = hpsb_make_writepacket(ne->host, ne->nodeid,
388 addr, buffer, length); 384 addr, buffer, length);
389 if (!packet) 385 if (!packet)
390 return -ENOMEM; 386 return -ENOMEM;
391 387
392 hpsb_set_packet_complete_task(packet, (void (*)(void*))sbp2_free_packet, 388 hpsb_set_packet_complete_task(packet,
389 (void (*)(void *))sbp2_free_packet,
393 packet); 390 packet);
394 391
395 hpsb_node_fill_packet(ne, packet); 392 hpsb_node_fill_packet(ne, packet);
396 393
397 if (hpsb_send_packet(packet) < 0) { 394 if (hpsb_send_packet(packet) < 0) {
398 sbp2_free_packet(packet); 395 sbp2_free_packet(packet);
399 return -EIO; 396 return -EIO;
400 } 397 }
@@ -420,19 +417,21 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i
420 command = (struct sbp2_command_info *) 417 command = (struct sbp2_command_info *)
421 kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC); 418 kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC);
422 if (!command) { 419 if (!command) {
423 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 420 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock,
424 return(-ENOMEM); 421 flags);
422 return -ENOMEM;
425 } 423 }
426 memset(command, '\0', sizeof(struct sbp2_command_info)); 424 memset(command, '\0', sizeof(struct sbp2_command_info));
427 command->command_orb_dma = 425 command->command_orb_dma =
428 pci_map_single (hi->host->pdev, &command->command_orb, 426 pci_map_single(hi->host->pdev, &command->command_orb,
429 sizeof(struct sbp2_command_orb), 427 sizeof(struct sbp2_command_orb),
430 PCI_DMA_BIDIRECTIONAL); 428 PCI_DMA_BIDIRECTIONAL);
431 SBP2_DMA_ALLOC("single command orb DMA"); 429 SBP2_DMA_ALLOC("single command orb DMA");
432 command->sge_dma = 430 command->sge_dma =
433 pci_map_single (hi->host->pdev, &command->scatter_gather_element, 431 pci_map_single(hi->host->pdev,
434 sizeof(command->scatter_gather_element), 432 &command->scatter_gather_element,
435 PCI_DMA_BIDIRECTIONAL); 433 sizeof(command->scatter_gather_element),
434 PCI_DMA_BIDIRECTIONAL);
436 SBP2_DMA_ALLOC("scatter_gather_element"); 435 SBP2_DMA_ALLOC("scatter_gather_element");
437 INIT_LIST_HEAD(&command->list); 436 INIT_LIST_HEAD(&command->list);
438 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); 437 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed);
@@ -488,7 +487,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb(
488 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { 487 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) {
489 if (command->command_orb_dma == orb) { 488 if (command->command_orb_dma == orb) {
490 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 489 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
491 return (command); 490 return command;
492 } 491 }
493 } 492 }
494 } 493 }
@@ -496,7 +495,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb(
496 495
497 SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb); 496 SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb);
498 497
499 return(NULL); 498 return NULL;
500} 499}
501 500
502/* 501/*
@@ -513,12 +512,12 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_
513 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { 512 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) {
514 if (command->Current_SCpnt == SCpnt) { 513 if (command->Current_SCpnt == SCpnt) {
515 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 514 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
516 return (command); 515 return command;
517 } 516 }
518 } 517 }
519 } 518 }
520 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 519 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
521 return(NULL); 520 return NULL;
522} 521}
523 522
524/* 523/*
@@ -545,7 +544,7 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb(
545 SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); 544 SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!");
546 } 545 }
547 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 546 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
548 return (command); 547 return command;
549} 548}
550 549
551/* Free our DMA's */ 550/* Free our DMA's */
@@ -587,7 +586,8 @@ static void sbp2util_free_command_dma(struct sbp2_command_info *command)
587/* 586/*
588 * This function moves a command to the completed orb list. 587 * This function moves a command to the completed orb list.
589 */ 588 */
590static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, struct sbp2_command_info *command) 589static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id,
590 struct sbp2_command_info *command)
591{ 591{
592 unsigned long flags; 592 unsigned long flags;
593 593
@@ -606,8 +606,6 @@ static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_
606 return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo; 606 return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo;
607} 607}
608 608
609
610
611/********************************************* 609/*********************************************
612 * IEEE-1394 core driver stack related section 610 * IEEE-1394 core driver stack related section
613 *********************************************/ 611 *********************************************/
@@ -627,14 +625,14 @@ static int sbp2_probe(struct device *dev)
627 if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY) 625 if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY)
628 return -ENODEV; 626 return -ENODEV;
629 627
630 scsi_id = sbp2_alloc_device(ud); 628 scsi_id = sbp2_alloc_device(ud);
631 629
632 if (!scsi_id) 630 if (!scsi_id)
633 return -ENOMEM; 631 return -ENOMEM;
634 632
635 sbp2_parse_unit_directory(scsi_id, ud); 633 sbp2_parse_unit_directory(scsi_id, ud);
636 634
637 return sbp2_start_device(scsi_id); 635 return sbp2_start_device(scsi_id);
638} 636}
639 637
640static int sbp2_remove(struct device *dev) 638static int sbp2_remove(struct device *dev)
@@ -769,7 +767,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
769 767
770 /* Register our host with the SCSI stack. */ 768 /* Register our host with the SCSI stack. */
771 scsi_host = scsi_host_alloc(&scsi_driver_template, 769 scsi_host = scsi_host_alloc(&scsi_driver_template,
772 sizeof (unsigned long)); 770 sizeof(unsigned long));
773 if (!scsi_host) { 771 if (!scsi_host) {
774 SBP2_ERR("failed to register scsi host"); 772 SBP2_ERR("failed to register scsi host");
775 goto failed_alloc; 773 goto failed_alloc;
@@ -790,7 +788,6 @@ failed_alloc:
790 return NULL; 788 return NULL;
791} 789}
792 790
793
794static void sbp2_host_reset(struct hpsb_host *host) 791static void sbp2_host_reset(struct hpsb_host *host)
795{ 792{
796 struct sbp2scsi_host_info *hi; 793 struct sbp2scsi_host_info *hi;
@@ -804,7 +801,6 @@ static void sbp2_host_reset(struct hpsb_host *host)
804 } 801 }
805} 802}
806 803
807
808/* 804/*
809 * This function is where we first pull the node unique ids, and then 805 * This function is where we first pull the node unique ids, and then
810 * allocate memory and register a SBP-2 device. 806 * allocate memory and register a SBP-2 device.
@@ -818,7 +814,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
818 814
819 /* Login FIFO DMA */ 815 /* Login FIFO DMA */
820 scsi_id->login_response = 816 scsi_id->login_response =
821 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_response), 817 pci_alloc_consistent(hi->host->pdev,
818 sizeof(struct sbp2_login_response),
822 &scsi_id->login_response_dma); 819 &scsi_id->login_response_dma);
823 if (!scsi_id->login_response) 820 if (!scsi_id->login_response)
824 goto alloc_fail; 821 goto alloc_fail;
@@ -826,7 +823,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
826 823
827 /* Query logins ORB DMA */ 824 /* Query logins ORB DMA */
828 scsi_id->query_logins_orb = 825 scsi_id->query_logins_orb =
829 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_orb), 826 pci_alloc_consistent(hi->host->pdev,
827 sizeof(struct sbp2_query_logins_orb),
830 &scsi_id->query_logins_orb_dma); 828 &scsi_id->query_logins_orb_dma);
831 if (!scsi_id->query_logins_orb) 829 if (!scsi_id->query_logins_orb)
832 goto alloc_fail; 830 goto alloc_fail;
@@ -834,7 +832,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
834 832
835 /* Query logins response DMA */ 833 /* Query logins response DMA */
836 scsi_id->query_logins_response = 834 scsi_id->query_logins_response =
837 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_response), 835 pci_alloc_consistent(hi->host->pdev,
836 sizeof(struct sbp2_query_logins_response),
838 &scsi_id->query_logins_response_dma); 837 &scsi_id->query_logins_response_dma);
839 if (!scsi_id->query_logins_response) 838 if (!scsi_id->query_logins_response)
840 goto alloc_fail; 839 goto alloc_fail;
@@ -842,7 +841,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
842 841
843 /* Reconnect ORB DMA */ 842 /* Reconnect ORB DMA */
844 scsi_id->reconnect_orb = 843 scsi_id->reconnect_orb =
845 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_reconnect_orb), 844 pci_alloc_consistent(hi->host->pdev,
845 sizeof(struct sbp2_reconnect_orb),
846 &scsi_id->reconnect_orb_dma); 846 &scsi_id->reconnect_orb_dma);
847 if (!scsi_id->reconnect_orb) 847 if (!scsi_id->reconnect_orb)
848 goto alloc_fail; 848 goto alloc_fail;
@@ -850,7 +850,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
850 850
851 /* Logout ORB DMA */ 851 /* Logout ORB DMA */
852 scsi_id->logout_orb = 852 scsi_id->logout_orb =
853 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_logout_orb), 853 pci_alloc_consistent(hi->host->pdev,
854 sizeof(struct sbp2_logout_orb),
854 &scsi_id->logout_orb_dma); 855 &scsi_id->logout_orb_dma);
855 if (!scsi_id->logout_orb) 856 if (!scsi_id->logout_orb)
856 goto alloc_fail; 857 goto alloc_fail;
@@ -858,7 +859,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
858 859
859 /* Login ORB DMA */ 860 /* Login ORB DMA */
860 scsi_id->login_orb = 861 scsi_id->login_orb =
861 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_orb), 862 pci_alloc_consistent(hi->host->pdev,
863 sizeof(struct sbp2_login_orb),
862 &scsi_id->login_orb_dma); 864 &scsi_id->login_orb_dma);
863 if (!scsi_id->login_orb) { 865 if (!scsi_id->login_orb) {
864alloc_fail: 866alloc_fail:
@@ -880,25 +882,25 @@ alloc_fail:
880 882
881 if (scsi_id->logout_orb) { 883 if (scsi_id->logout_orb) {
882 pci_free_consistent(hi->host->pdev, 884 pci_free_consistent(hi->host->pdev,
883 sizeof(struct sbp2_logout_orb), 885 sizeof(struct sbp2_logout_orb),
884 scsi_id->logout_orb, 886 scsi_id->logout_orb,
885 scsi_id->logout_orb_dma); 887 scsi_id->logout_orb_dma);
886 SBP2_DMA_FREE("logout ORB DMA"); 888 SBP2_DMA_FREE("logout ORB DMA");
887 } 889 }
888 890
889 if (scsi_id->reconnect_orb) { 891 if (scsi_id->reconnect_orb) {
890 pci_free_consistent(hi->host->pdev, 892 pci_free_consistent(hi->host->pdev,
891 sizeof(struct sbp2_reconnect_orb), 893 sizeof(struct sbp2_reconnect_orb),
892 scsi_id->reconnect_orb, 894 scsi_id->reconnect_orb,
893 scsi_id->reconnect_orb_dma); 895 scsi_id->reconnect_orb_dma);
894 SBP2_DMA_FREE("reconnect ORB DMA"); 896 SBP2_DMA_FREE("reconnect ORB DMA");
895 } 897 }
896 898
897 if (scsi_id->login_response) { 899 if (scsi_id->login_response) {
898 pci_free_consistent(hi->host->pdev, 900 pci_free_consistent(hi->host->pdev,
899 sizeof(struct sbp2_login_response), 901 sizeof(struct sbp2_login_response),
900 scsi_id->login_response, 902 scsi_id->login_response,
901 scsi_id->login_response_dma); 903 scsi_id->login_response_dma);
902 SBP2_DMA_FREE("login FIFO DMA"); 904 SBP2_DMA_FREE("login FIFO DMA");
903 } 905 }
904 906
@@ -906,7 +908,7 @@ alloc_fail:
906 908
907 kfree(scsi_id); 909 kfree(scsi_id);
908 910
909 SBP2_ERR ("Could not allocate memory for scsi_id"); 911 SBP2_ERR("Could not allocate memory for scsi_id");
910 912
911 return -ENOMEM; 913 return -ENOMEM;
912 } 914 }
@@ -935,7 +937,7 @@ alloc_fail:
935 sbp2_remove_device(scsi_id); 937 sbp2_remove_device(scsi_id);
936 return -EINTR; 938 return -EINTR;
937 } 939 }
938 940
939 /* 941 /*
940 * Login to the sbp-2 device 942 * Login to the sbp-2 device
941 */ 943 */
@@ -1054,36 +1056,39 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
1054 * This function deals with physical dma write requests (for adapters that do not support 1056 * This function deals with physical dma write requests (for adapters that do not support
1055 * physical dma in hardware). Mostly just here for debugging... 1057 * physical dma in hardware). Mostly just here for debugging...
1056 */ 1058 */
1057static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data, 1059static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid,
1058 u64 addr, size_t length, u16 flags) 1060 int destid, quadlet_t *data, u64 addr,
1061 size_t length, u16 flags)
1059{ 1062{
1060 1063
1061 /* 1064 /*
1062 * Manually put the data in the right place. 1065 * Manually put the data in the right place.
1063 */ 1066 */
1064 memcpy(bus_to_virt((u32)addr), data, length); 1067 memcpy(bus_to_virt((u32) addr), data, length);
1065 sbp2util_packet_dump(data, length, "sbp2 phys dma write by device", (u32)addr); 1068 sbp2util_packet_dump(data, length, "sbp2 phys dma write by device",
1066 return(RCODE_COMPLETE); 1069 (u32) addr);
1070 return RCODE_COMPLETE;
1067} 1071}
1068 1072
1069/* 1073/*
1070 * This function deals with physical dma read requests (for adapters that do not support 1074 * This function deals with physical dma read requests (for adapters that do not support
1071 * physical dma in hardware). Mostly just here for debugging... 1075 * physical dma in hardware). Mostly just here for debugging...
1072 */ 1076 */
1073static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data, 1077static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
1074 u64 addr, size_t length, u16 flags) 1078 quadlet_t *data, u64 addr, size_t length,
1079 u16 flags)
1075{ 1080{
1076 1081
1077 /* 1082 /*
1078 * Grab data from memory and send a read response. 1083 * Grab data from memory and send a read response.
1079 */ 1084 */
1080 memcpy(data, bus_to_virt((u32)addr), length); 1085 memcpy(data, bus_to_virt((u32) addr), length);
1081 sbp2util_packet_dump(data, length, "sbp2 phys dma read by device", (u32)addr); 1086 sbp2util_packet_dump(data, length, "sbp2 phys dma read by device",
1082 return(RCODE_COMPLETE); 1087 (u32) addr);
1088 return RCODE_COMPLETE;
1083} 1089}
1084#endif 1090#endif
1085 1091
1086
1087/************************************** 1092/**************************************
1088 * SBP-2 protocol related section 1093 * SBP-2 protocol related section
1089 **************************************/ 1094 **************************************/
@@ -1147,12 +1152,12 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1147 1152
1148 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { 1153 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) {
1149 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1154 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1150 return(-EIO); 1155 return -EIO;
1151 } 1156 }
1152 1157
1153 if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) { 1158 if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) {
1154 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1159 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1155 return(-EIO); 1160 return -EIO;
1156 } 1161 }
1157 1162
1158 if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) || 1163 if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) ||
@@ -1160,7 +1165,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1160 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { 1165 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
1161 1166
1162 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1167 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1163 return(-EIO); 1168 return -EIO;
1164 } 1169 }
1165 1170
1166 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response)); 1171 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response));
@@ -1177,7 +1182,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1177 SBP2_DEBUG("Number of active logins: %d", active_logins); 1182 SBP2_DEBUG("Number of active logins: %d", active_logins);
1178 1183
1179 if (active_logins >= max_logins) { 1184 if (active_logins >= max_logins) {
1180 return(-EIO); 1185 return -EIO;
1181 } 1186 }
1182 1187
1183 return 0; 1188 return 0;
@@ -1196,13 +1201,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1196 1201
1197 if (!scsi_id->login_orb) { 1202 if (!scsi_id->login_orb) {
1198 SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!"); 1203 SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!");
1199 return(-EIO); 1204 return -EIO;
1200 } 1205 }
1201 1206
1202 if (!exclusive_login) { 1207 if (!exclusive_login) {
1203 if (sbp2_query_logins(scsi_id)) { 1208 if (sbp2_query_logins(scsi_id)) {
1204 SBP2_INFO("Device does not support any more concurrent logins"); 1209 SBP2_INFO("Device does not support any more concurrent logins");
1205 return(-EIO); 1210 return -EIO;
1206 } 1211 }
1207 } 1212 }
1208 1213
@@ -1269,7 +1274,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1269 */ 1274 */
1270 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) { 1275 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) {
1271 SBP2_ERR("Error logging into SBP-2 device - login timed-out"); 1276 SBP2_ERR("Error logging into SBP-2 device - login timed-out");
1272 return(-EIO); 1277 return -EIO;
1273 } 1278 }
1274 1279
1275 /* 1280 /*
@@ -1277,7 +1282,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1277 */ 1282 */
1278 if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) { 1283 if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) {
1279 SBP2_ERR("Error logging into SBP-2 device - login timed-out"); 1284 SBP2_ERR("Error logging into SBP-2 device - login timed-out");
1280 return(-EIO); 1285 return -EIO;
1281 } 1286 }
1282 1287
1283 /* 1288 /*
@@ -1288,7 +1293,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1288 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { 1293 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
1289 1294
1290 SBP2_ERR("Error logging into SBP-2 device - login failed"); 1295 SBP2_ERR("Error logging into SBP-2 device - login failed");
1291 return(-EIO); 1296 return -EIO;
1292 } 1297 }
1293 1298
1294 /* 1299 /*
@@ -1312,7 +1317,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1312 1317
1313 SBP2_INFO("Logged into SBP-2 device"); 1318 SBP2_INFO("Logged into SBP-2 device");
1314 1319
1315 return(0); 1320 return 0;
1316 1321
1317} 1322}
1318 1323
@@ -1366,8 +1371,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
1366 atomic_set(&scsi_id->sbp2_login_complete, 0); 1371 atomic_set(&scsi_id->sbp2_login_complete, 0);
1367 1372
1368 error = hpsb_node_write(scsi_id->ne, 1373 error = hpsb_node_write(scsi_id->ne,
1369 scsi_id->sbp2_management_agent_addr, 1374 scsi_id->sbp2_management_agent_addr, data, 8);
1370 data, 8);
1371 if (error) 1375 if (error)
1372 return error; 1376 return error;
1373 1377
@@ -1377,7 +1381,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
1377 1381
1378 SBP2_INFO("Logged out of SBP-2 device"); 1382 SBP2_INFO("Logged out of SBP-2 device");
1379 1383
1380 return(0); 1384 return 0;
1381 1385
1382} 1386}
1383 1387
@@ -1437,8 +1441,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1437 atomic_set(&scsi_id->sbp2_login_complete, 0); 1441 atomic_set(&scsi_id->sbp2_login_complete, 0);
1438 1442
1439 error = hpsb_node_write(scsi_id->ne, 1443 error = hpsb_node_write(scsi_id->ne,
1440 scsi_id->sbp2_management_agent_addr, 1444 scsi_id->sbp2_management_agent_addr, data, 8);
1441 data, 8);
1442 if (error) 1445 if (error)
1443 return error; 1446 return error;
1444 1447
@@ -1447,7 +1450,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1447 */ 1450 */
1448 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) { 1451 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) {
1449 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); 1452 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out");
1450 return(-EIO); 1453 return -EIO;
1451 } 1454 }
1452 1455
1453 /* 1456 /*
@@ -1455,7 +1458,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1455 */ 1458 */
1456 if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) { 1459 if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) {
1457 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); 1460 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out");
1458 return(-EIO); 1461 return -EIO;
1459 } 1462 }
1460 1463
1461 /* 1464 /*
@@ -1466,12 +1469,12 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1466 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { 1469 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
1467 1470
1468 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed"); 1471 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed");
1469 return(-EIO); 1472 return -EIO;
1470 } 1473 }
1471 1474
1472 HPSB_DEBUG("Reconnected to SBP-2 device"); 1475 HPSB_DEBUG("Reconnected to SBP-2 device");
1473 1476
1474 return(0); 1477 return 0;
1475 1478
1476} 1479}
1477 1480
@@ -1494,10 +1497,9 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id)
1494 SBP2_ERR("sbp2_set_busy_timeout error"); 1497 SBP2_ERR("sbp2_set_busy_timeout error");
1495 } 1498 }
1496 1499
1497 return(0); 1500 return 0;
1498} 1501}
1499 1502
1500
1501/* 1503/*
1502 * This function is called to parse sbp2 device's config rom unit 1504 * This function is called to parse sbp2 device's config rom unit
1503 * directory. Used to determine things like sbp2 management agent offset, 1505 * directory. Used to determine things like sbp2 management agent offset,
@@ -1510,7 +1512,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1510 struct csr1212_dentry *dentry; 1512 struct csr1212_dentry *dentry;
1511 u64 management_agent_addr; 1513 u64 management_agent_addr;
1512 u32 command_set_spec_id, command_set, unit_characteristics, 1514 u32 command_set_spec_id, command_set, unit_characteristics,
1513 firmware_revision, workarounds; 1515 firmware_revision, workarounds;
1514 int i; 1516 int i;
1515 1517
1516 SBP2_DEBUG("sbp2_parse_unit_directory"); 1518 SBP2_DEBUG("sbp2_parse_unit_directory");
@@ -1528,13 +1530,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1528 if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) { 1530 if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) {
1529 /* Save off the management agent address */ 1531 /* Save off the management agent address */
1530 management_agent_addr = 1532 management_agent_addr =
1531 CSR1212_REGISTER_SPACE_BASE + 1533 CSR1212_REGISTER_SPACE_BASE +
1532 (kv->value.csr_offset << 2); 1534 (kv->value.csr_offset << 2);
1533 1535
1534 SBP2_DEBUG("sbp2_management_agent_addr = %x", 1536 SBP2_DEBUG("sbp2_management_agent_addr = %x",
1535 (unsigned int) management_agent_addr); 1537 (unsigned int)management_agent_addr);
1536 } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { 1538 } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
1537 scsi_id->sbp2_lun = ORB_SET_LUN(kv->value.immediate); 1539 scsi_id->sbp2_lun =
1540 ORB_SET_LUN(kv->value.immediate);
1538 } 1541 }
1539 break; 1542 break;
1540 1543
@@ -1542,14 +1545,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1542 /* Command spec organization */ 1545 /* Command spec organization */
1543 command_set_spec_id = kv->value.immediate; 1546 command_set_spec_id = kv->value.immediate;
1544 SBP2_DEBUG("sbp2_command_set_spec_id = %x", 1547 SBP2_DEBUG("sbp2_command_set_spec_id = %x",
1545 (unsigned int) command_set_spec_id); 1548 (unsigned int)command_set_spec_id);
1546 break; 1549 break;
1547 1550
1548 case SBP2_COMMAND_SET_KEY: 1551 case SBP2_COMMAND_SET_KEY:
1549 /* Command set used by sbp2 device */ 1552 /* Command set used by sbp2 device */
1550 command_set = kv->value.immediate; 1553 command_set = kv->value.immediate;
1551 SBP2_DEBUG("sbp2_command_set = %x", 1554 SBP2_DEBUG("sbp2_command_set = %x",
1552 (unsigned int) command_set); 1555 (unsigned int)command_set);
1553 break; 1556 break;
1554 1557
1555 case SBP2_UNIT_CHARACTERISTICS_KEY: 1558 case SBP2_UNIT_CHARACTERISTICS_KEY:
@@ -1559,7 +1562,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1559 */ 1562 */
1560 unit_characteristics = kv->value.immediate; 1563 unit_characteristics = kv->value.immediate;
1561 SBP2_DEBUG("sbp2_unit_characteristics = %x", 1564 SBP2_DEBUG("sbp2_unit_characteristics = %x",
1562 (unsigned int) unit_characteristics); 1565 (unsigned int)unit_characteristics);
1563 break; 1566 break;
1564 1567
1565 case SBP2_FIRMWARE_REVISION_KEY: 1568 case SBP2_FIRMWARE_REVISION_KEY:
@@ -1567,9 +1570,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1567 firmware_revision = kv->value.immediate; 1570 firmware_revision = kv->value.immediate;
1568 if (force_inquiry_hack) 1571 if (force_inquiry_hack)
1569 SBP2_INFO("sbp2_firmware_revision = %x", 1572 SBP2_INFO("sbp2_firmware_revision = %x",
1570 (unsigned int) firmware_revision); 1573 (unsigned int)firmware_revision);
1571 else SBP2_DEBUG("sbp2_firmware_revision = %x", 1574 else
1572 (unsigned int) firmware_revision); 1575 SBP2_DEBUG("sbp2_firmware_revision = %x",
1576 (unsigned int)firmware_revision);
1573 break; 1577 break;
1574 1578
1575 default: 1579 default:
@@ -1647,8 +1651,9 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
1647 SBP2_DEBUG("sbp2_max_speed_and_size"); 1651 SBP2_DEBUG("sbp2_max_speed_and_size");
1648 1652
1649 /* Initial setting comes from the hosts speed map */ 1653 /* Initial setting comes from the hosts speed map */
1650 scsi_id->speed_code = hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 1654 scsi_id->speed_code =
1651 + NODEID_TO_NODE(scsi_id->ne->nodeid)]; 1655 hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 +
1656 NODEID_TO_NODE(scsi_id->ne->nodeid)];
1652 1657
1653 /* Bump down our speed if the user requested it */ 1658 /* Bump down our speed if the user requested it */
1654 if (scsi_id->speed_code > max_speed) { 1659 if (scsi_id->speed_code > max_speed) {
@@ -1659,15 +1664,16 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
1659 1664
1660 /* Payload size is the lesser of what our speed supports and what 1665 /* Payload size is the lesser of what our speed supports and what
1661 * our host supports. */ 1666 * our host supports. */
1662 scsi_id->max_payload_size = min(sbp2_speedto_max_payload[scsi_id->speed_code], 1667 scsi_id->max_payload_size =
1663 (u8)(hi->host->csr.max_rec - 1)); 1668 min(sbp2_speedto_max_payload[scsi_id->speed_code],
1669 (u8) (hi->host->csr.max_rec - 1));
1664 1670
1665 HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", 1671 HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]",
1666 NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid), 1672 NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid),
1667 hpsb_speedto_str[scsi_id->speed_code], 1673 hpsb_speedto_str[scsi_id->speed_code],
1668 1 << ((u32)scsi_id->max_payload_size + 2)); 1674 1 << ((u32) scsi_id->max_payload_size + 2));
1669 1675
1670 return(0); 1676 return 0;
1671} 1677}
1672 1678
1673/* 1679/*
@@ -1702,7 +1708,7 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
1702 */ 1708 */
1703 scsi_id->last_orb = NULL; 1709 scsi_id->last_orb = NULL;
1704 1710
1705 return(0); 1711 return 0;
1706} 1712}
1707 1713
1708/* 1714/*
@@ -1716,10 +1722,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1716 unsigned int scsi_request_bufflen, 1722 unsigned int scsi_request_bufflen,
1717 void *scsi_request_buffer, 1723 void *scsi_request_buffer,
1718 enum dma_data_direction dma_dir) 1724 enum dma_data_direction dma_dir)
1719
1720{ 1725{
1721 struct sbp2scsi_host_info *hi = scsi_id->hi; 1726 struct sbp2scsi_host_info *hi = scsi_id->hi;
1722 struct scatterlist *sgpnt = (struct scatterlist *) scsi_request_buffer; 1727 struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer;
1723 struct sbp2_command_orb *command_orb = &command->command_orb; 1728 struct sbp2_command_orb *command_orb = &command->command_orb;
1724 struct sbp2_unrestricted_page_table *scatter_gather_element = 1729 struct sbp2_unrestricted_page_table *scatter_gather_element =
1725 &command->scatter_gather_element[0]; 1730 &command->scatter_gather_element[0];
@@ -1739,30 +1744,30 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1739 command_orb->next_ORB_lo = 0x0; 1744 command_orb->next_ORB_lo = 0x0;
1740 command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); 1745 command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size);
1741 command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); 1746 command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code);
1742 command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ 1747 command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */
1743 1748
1744 /* 1749 /*
1745 * Get the direction of the transfer. If the direction is unknown, then use our 1750 * Get the direction of the transfer. If the direction is unknown, then use our
1746 * goofy table as a back-up. 1751 * goofy table as a back-up.
1747 */ 1752 */
1748 switch (dma_dir) { 1753 switch (dma_dir) {
1749 case DMA_NONE: 1754 case DMA_NONE:
1750 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; 1755 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
1751 break; 1756 break;
1752 case DMA_TO_DEVICE: 1757 case DMA_TO_DEVICE:
1753 orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA; 1758 orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA;
1754 break; 1759 break;
1755 case DMA_FROM_DEVICE: 1760 case DMA_FROM_DEVICE:
1756 orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; 1761 orb_direction = ORB_DIRECTION_READ_FROM_MEDIA;
1757 break; 1762 break;
1758 case DMA_BIDIRECTIONAL: 1763 case DMA_BIDIRECTIONAL:
1759 default: 1764 default:
1760 SBP2_ERR("SCSI data transfer direction not specified. " 1765 SBP2_ERR("SCSI data transfer direction not specified. "
1761 "Update the SBP2 direction table in sbp2.h if " 1766 "Update the SBP2 direction table in sbp2.h if "
1762 "necessary for your application"); 1767 "necessary for your application");
1763 __scsi_print_command(scsi_cmd); 1768 __scsi_print_command(scsi_cmd);
1764 orb_direction = sbp2scsi_direction_table[*scsi_cmd]; 1769 orb_direction = sbp2scsi_direction_table[*scsi_cmd];
1765 break; 1770 break;
1766 } 1771 }
1767 1772
1768 /* 1773 /*
@@ -1865,9 +1870,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1865 command->dma_dir = dma_dir; 1870 command->dma_dir = dma_dir;
1866 command->dma_size = scsi_request_bufflen; 1871 command->dma_size = scsi_request_bufflen;
1867 command->dma_type = CMD_DMA_SINGLE; 1872 command->dma_type = CMD_DMA_SINGLE;
1868 command->cmd_dma = pci_map_single (hi->host->pdev, scsi_request_buffer, 1873 command->cmd_dma =
1869 command->dma_size, 1874 pci_map_single(hi->host->pdev, scsi_request_buffer,
1870 command->dma_dir); 1875 command->dma_size, command->dma_dir);
1871 SBP2_DMA_ALLOC("single bulk"); 1876 SBP2_DMA_ALLOC("single bulk");
1872 1877
1873 /* 1878 /*
@@ -1954,7 +1959,7 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1954 memset(command_orb->cdb, 0, 12); 1959 memset(command_orb->cdb, 0, 12);
1955 memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); 1960 memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
1956 1961
1957 return(0); 1962 return 0;
1958} 1963}
1959 1964
1960/* 1965/*
@@ -1970,7 +1975,7 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
1970 1975
1971 outstanding_orb_incr; 1976 outstanding_orb_incr;
1972 SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x", 1977 SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x",
1973 command_orb, global_outstanding_command_orbs); 1978 command_orb, global_outstanding_command_orbs);
1974 1979
1975 pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma, 1980 pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma,
1976 sizeof(struct sbp2_command_orb), 1981 sizeof(struct sbp2_command_orb),
@@ -2015,10 +2020,11 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2015 * both by the sbp2 device and us. 2020 * both by the sbp2 device and us.
2016 */ 2021 */
2017 scsi_id->last_orb->next_ORB_lo = 2022 scsi_id->last_orb->next_ORB_lo =
2018 cpu_to_be32(command->command_orb_dma); 2023 cpu_to_be32(command->command_orb_dma);
2019 /* Tells hardware that this pointer is valid */ 2024 /* Tells hardware that this pointer is valid */
2020 scsi_id->last_orb->next_ORB_hi = 0x0; 2025 scsi_id->last_orb->next_ORB_hi = 0x0;
2021 pci_dma_sync_single_for_device(hi->host->pdev, scsi_id->last_orb_dma, 2026 pci_dma_sync_single_for_device(hi->host->pdev,
2027 scsi_id->last_orb_dma,
2022 sizeof(struct sbp2_command_orb), 2028 sizeof(struct sbp2_command_orb),
2023 PCI_DMA_BIDIRECTIONAL); 2029 PCI_DMA_BIDIRECTIONAL);
2024 2030
@@ -2032,14 +2038,14 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2032 2038
2033 if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) { 2039 if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) {
2034 SBP2_ERR("sbp2util_node_write_no_wait failed"); 2040 SBP2_ERR("sbp2util_node_write_no_wait failed");
2035 return(-EIO); 2041 return -EIO;
2036 } 2042 }
2037 2043
2038 scsi_id->last_orb = command_orb; 2044 scsi_id->last_orb = command_orb;
2039 scsi_id->last_orb_dma = command->command_orb_dma; 2045 scsi_id->last_orb_dma = command->command_orb_dma;
2040 2046
2041 } 2047 }
2042 return(0); 2048 return 0;
2043} 2049}
2044 2050
2045/* 2051/*
@@ -2066,7 +2072,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2066 */ 2072 */
2067 command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done); 2073 command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done);
2068 if (!command) { 2074 if (!command) {
2069 return(-EIO); 2075 return -EIO;
2070 } 2076 }
2071 2077
2072 /* 2078 /*
@@ -2101,10 +2107,9 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2101 */ 2107 */
2102 sbp2_link_orb_command(scsi_id, command); 2108 sbp2_link_orb_command(scsi_id, command);
2103 2109
2104 return(0); 2110 return 0;
2105} 2111}
2106 2112
2107
2108/* 2113/*
2109 * Translates SBP-2 status into SCSI sense data for check conditions 2114 * Translates SBP-2 status into SCSI sense data for check conditions
2110 */ 2115 */
@@ -2132,14 +2137,14 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense
2132 sense_data[14] = sbp2_status[20]; 2137 sense_data[14] = sbp2_status[20];
2133 sense_data[15] = sbp2_status[21]; 2138 sense_data[15] = sbp2_status[21];
2134 2139
2135 return(sbp2_status[8] & 0x3f); /* return scsi status */ 2140 return sbp2_status[8] & 0x3f; /* return scsi status */
2136} 2141}
2137 2142
2138/* 2143/*
2139 * This function is called after a command is completed, in order to do any necessary SBP-2 2144 * This function is called after a command is completed, in order to do any necessary SBP-2
2140 * response data translations for the SCSI stack 2145 * response data translations for the SCSI stack
2141 */ 2146 */
2142static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, 2147static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2143 struct scsi_cmnd *SCpnt) 2148 struct scsi_cmnd *SCpnt)
2144{ 2149{
2145 u8 *scsi_buf = SCpnt->request_buffer; 2150 u8 *scsi_buf = SCpnt->request_buffer;
@@ -2148,24 +2153,24 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2148 2153
2149 switch (SCpnt->cmnd[0]) { 2154 switch (SCpnt->cmnd[0]) {
2150 2155
2151 case INQUIRY: 2156 case INQUIRY:
2152 /* 2157 /*
2153 * Make sure data length is ok. Minimum length is 36 bytes 2158 * Make sure data length is ok. Minimum length is 36 bytes
2154 */ 2159 */
2155 if (scsi_buf[4] == 0) { 2160 if (scsi_buf[4] == 0) {
2156 scsi_buf[4] = 36 - 5; 2161 scsi_buf[4] = 36 - 5;
2157 } 2162 }
2158 2163
2159 /* 2164 /*
2160 * Fix ansi revision and response data format 2165 * Fix ansi revision and response data format
2161 */ 2166 */
2162 scsi_buf[2] |= 2; 2167 scsi_buf[2] |= 2;
2163 scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; 2168 scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2;
2164 2169
2165 break; 2170 break;
2166 2171
2167 default: 2172 default:
2168 break; 2173 break;
2169 } 2174 }
2170 return; 2175 return;
2171} 2176}
@@ -2190,14 +2195,14 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2190 2195
2191 if (!host) { 2196 if (!host) {
2192 SBP2_ERR("host is NULL - this is bad!"); 2197 SBP2_ERR("host is NULL - this is bad!");
2193 return(RCODE_ADDRESS_ERROR); 2198 return RCODE_ADDRESS_ERROR;
2194 } 2199 }
2195 2200
2196 hi = hpsb_get_hostinfo(&sbp2_highlevel, host); 2201 hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
2197 2202
2198 if (!hi) { 2203 if (!hi) {
2199 SBP2_ERR("host info is NULL - this is bad!"); 2204 SBP2_ERR("host info is NULL - this is bad!");
2200 return(RCODE_ADDRESS_ERROR); 2205 return RCODE_ADDRESS_ERROR;
2201 } 2206 }
2202 2207
2203 /* 2208 /*
@@ -2214,7 +2219,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2214 2219
2215 if (!scsi_id) { 2220 if (!scsi_id) {
2216 SBP2_ERR("scsi_id is NULL - device is gone?"); 2221 SBP2_ERR("scsi_id is NULL - device is gone?");
2217 return(RCODE_ADDRESS_ERROR); 2222 return RCODE_ADDRESS_ERROR;
2218 } 2223 }
2219 2224
2220 /* 2225 /*
@@ -2312,10 +2317,9 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2312 SBP2_ORB_DEBUG("command orb completed"); 2317 SBP2_ORB_DEBUG("command orb completed");
2313 } 2318 }
2314 2319
2315 return(RCODE_COMPLETE); 2320 return RCODE_COMPLETE;
2316} 2321}
2317 2322
2318
2319/************************************** 2323/**************************************
2320 * SCSI interface related section 2324 * SCSI interface related section
2321 **************************************/ 2325 **************************************/
@@ -2448,55 +2452,56 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2448 * complete the command, just let it get retried at the end of the 2452 * complete the command, just let it get retried at the end of the
2449 * bus reset. 2453 * bus reset.
2450 */ 2454 */
2451 if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { 2455 if (!hpsb_node_entry_valid(scsi_id->ne)
2456 && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
2452 SBP2_ERR("Bus reset in progress - retry command later"); 2457 SBP2_ERR("Bus reset in progress - retry command later");
2453 return; 2458 return;
2454 } 2459 }
2455 2460
2456 /* 2461 /*
2457 * Switch on scsi status 2462 * Switch on scsi status
2458 */ 2463 */
2459 switch (scsi_status) { 2464 switch (scsi_status) {
2460 case SBP2_SCSI_STATUS_GOOD: 2465 case SBP2_SCSI_STATUS_GOOD:
2461 SCpnt->result = DID_OK; 2466 SCpnt->result = DID_OK;
2462 break; 2467 break;
2463 2468
2464 case SBP2_SCSI_STATUS_BUSY: 2469 case SBP2_SCSI_STATUS_BUSY:
2465 SBP2_ERR("SBP2_SCSI_STATUS_BUSY"); 2470 SBP2_ERR("SBP2_SCSI_STATUS_BUSY");
2466 SCpnt->result = DID_BUS_BUSY << 16; 2471 SCpnt->result = DID_BUS_BUSY << 16;
2467 break; 2472 break;
2468 2473
2469 case SBP2_SCSI_STATUS_CHECK_CONDITION: 2474 case SBP2_SCSI_STATUS_CHECK_CONDITION:
2470 SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); 2475 SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION");
2471 SCpnt->result = CHECK_CONDITION << 1; 2476 SCpnt->result = CHECK_CONDITION << 1;
2472 2477
2473 /* 2478 /*
2474 * Debug stuff 2479 * Debug stuff
2475 */ 2480 */
2476#if CONFIG_IEEE1394_SBP2_DEBUG >= 1 2481#if CONFIG_IEEE1394_SBP2_DEBUG >= 1
2477 scsi_print_command(SCpnt); 2482 scsi_print_command(SCpnt);
2478 scsi_print_sense("bh", SCpnt); 2483 scsi_print_sense("bh", SCpnt);
2479#endif 2484#endif
2480 2485
2481 break; 2486 break;
2482 2487
2483 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: 2488 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT:
2484 SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT"); 2489 SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT");
2485 SCpnt->result = DID_NO_CONNECT << 16; 2490 SCpnt->result = DID_NO_CONNECT << 16;
2486 scsi_print_command(SCpnt); 2491 scsi_print_command(SCpnt);
2487 break; 2492 break;
2488 2493
2489 case SBP2_SCSI_STATUS_CONDITION_MET: 2494 case SBP2_SCSI_STATUS_CONDITION_MET:
2490 case SBP2_SCSI_STATUS_RESERVATION_CONFLICT: 2495 case SBP2_SCSI_STATUS_RESERVATION_CONFLICT:
2491 case SBP2_SCSI_STATUS_COMMAND_TERMINATED: 2496 case SBP2_SCSI_STATUS_COMMAND_TERMINATED:
2492 SBP2_ERR("Bad SCSI status = %x", scsi_status); 2497 SBP2_ERR("Bad SCSI status = %x", scsi_status);
2493 SCpnt->result = DID_ERROR << 16; 2498 SCpnt->result = DID_ERROR << 16;
2494 scsi_print_command(SCpnt); 2499 scsi_print_command(SCpnt);
2495 break; 2500 break;
2496 2501
2497 default: 2502 default:
2498 SBP2_ERR("Unsupported SCSI status = %x", scsi_status); 2503 SBP2_ERR("Unsupported SCSI status = %x", scsi_status);
2499 SCpnt->result = DID_ERROR << 16; 2504 SCpnt->result = DID_ERROR << 16;
2500 } 2505 }
2501 2506
2502 /* 2507 /*
@@ -2510,7 +2515,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2510 * If a bus reset is in progress and there was an error, complete 2515 * If a bus reset is in progress and there was an error, complete
2511 * the command as busy so that it will get retried. 2516 * the command as busy so that it will get retried.
2512 */ 2517 */
2513 if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { 2518 if (!hpsb_node_entry_valid(scsi_id->ne)
2519 && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
2514 SBP2_ERR("Completing command with busy (bus reset)"); 2520 SBP2_ERR("Completing command with busy (bus reset)");
2515 SCpnt->result = DID_BUS_BUSY << 16; 2521 SCpnt->result = DID_BUS_BUSY << 16;
2516 } 2522 }
@@ -2531,17 +2537,15 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2531 /* 2537 /*
2532 * Tell scsi stack that we're done with this command 2538 * Tell scsi stack that we're done with this command
2533 */ 2539 */
2534 done (SCpnt); 2540 done(SCpnt);
2535} 2541}
2536 2542
2537
2538static int sbp2scsi_slave_alloc(struct scsi_device *sdev) 2543static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
2539{ 2544{
2540 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; 2545 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev;
2541 return 0; 2546 return 0;
2542} 2547}
2543 2548
2544
2545static int sbp2scsi_slave_configure(struct scsi_device *sdev) 2549static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2546{ 2550{
2547 blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); 2551 blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
@@ -2550,14 +2554,12 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2550 return 0; 2554 return 0;
2551} 2555}
2552 2556
2553
2554static void sbp2scsi_slave_destroy(struct scsi_device *sdev) 2557static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
2555{ 2558{
2556 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL; 2559 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL;
2557 return; 2560 return;
2558} 2561}
2559 2562
2560
2561/* 2563/*
2562 * Called by scsi stack when something has really gone wrong. Usually 2564 * Called by scsi stack when something has really gone wrong. Usually
2563 * called when a command has timed-out for some reason. 2565 * called when a command has timed-out for some reason.
@@ -2603,7 +2605,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2603 sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY); 2605 sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
2604 } 2606 }
2605 2607
2606 return(SUCCESS); 2608 return SUCCESS;
2607} 2609}
2608 2610
2609/* 2611/*
@@ -2629,12 +2631,14 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
2629 return SUCCESS; 2631 return SUCCESS;
2630} 2632}
2631 2633
2632static const char *sbp2scsi_info (struct Scsi_Host *host) 2634static const char *sbp2scsi_info(struct Scsi_Host *host)
2633{ 2635{
2634 return "SCSI emulation for IEEE-1394 SBP-2 Devices"; 2636 return "SCSI emulation for IEEE-1394 SBP-2 Devices";
2635} 2637}
2636 2638
2637static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, char *buf) 2639static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
2640 struct device_attribute *attr,
2641 char *buf)
2638{ 2642{
2639 struct scsi_device *sdev; 2643 struct scsi_device *sdev;
2640 struct scsi_id_instance_data *scsi_id; 2644 struct scsi_id_instance_data *scsi_id;
@@ -2705,7 +2709,6 @@ static int sbp2_module_init(void)
2705 /* Set max sectors (module load option). Default is 255 sectors. */ 2709 /* Set max sectors (module load option). Default is 255 sectors. */
2706 scsi_driver_template.max_sectors = max_sectors; 2710 scsi_driver_template.max_sectors = max_sectors;
2707 2711
2708
2709 /* Register our high level driver with 1394 stack */ 2712 /* Register our high level driver with 1394 stack */
2710 hpsb_register_highlevel(&sbp2_highlevel); 2713 hpsb_register_highlevel(&sbp2_highlevel);
2711 2714
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index 890be1365523..abc647bae5b1 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -119,8 +119,8 @@ struct sbp2_query_logins_response {
119struct sbp2_reconnect_orb { 119struct sbp2_reconnect_orb {
120 u32 reserved1; 120 u32 reserved1;
121 u32 reserved2; 121 u32 reserved2;
122 u32 reserved3; 122 u32 reserved3;
123 u32 reserved4; 123 u32 reserved4;
124 u32 login_ID_misc; 124 u32 login_ID_misc;
125 u32 reserved5; 125 u32 reserved5;
126 u32 status_FIFO_hi; 126 u32 status_FIFO_hi;
@@ -130,8 +130,8 @@ struct sbp2_reconnect_orb {
130struct sbp2_logout_orb { 130struct sbp2_logout_orb {
131 u32 reserved1; 131 u32 reserved1;
132 u32 reserved2; 132 u32 reserved2;
133 u32 reserved3; 133 u32 reserved3;
134 u32 reserved4; 134 u32 reserved4;
135 u32 login_ID_misc; 135 u32 login_ID_misc;
136 u32 reserved5; 136 u32 reserved5;
137 u32 status_FIFO_hi; 137 u32 status_FIFO_hi;
@@ -188,7 +188,7 @@ struct sbp2_unrestricted_page_table {
188struct sbp2_status_block { 188struct sbp2_status_block {
189 u32 ORB_offset_hi_misc; 189 u32 ORB_offset_hi_misc;
190 u32 ORB_offset_lo; 190 u32 ORB_offset_lo;
191 u8 command_set_dependent[24]; 191 u8 command_set_dependent[24];
192}; 192};
193 193
194/* 194/*
@@ -211,7 +211,7 @@ struct sbp2_status_block {
211 * specified for write posting, where the ohci controller will 211 * specified for write posting, where the ohci controller will
212 * automatically send an ack_complete when the status is written by the 212 * automatically send an ack_complete when the status is written by the
213 * sbp2 device... saving a split transaction. =) 213 * sbp2 device... saving a split transaction. =)
214 */ 214 */
215#define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL 215#define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL
216#define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe 216#define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe
217#define SBP2_STATUS_FIFO_ADDRESS_LO 0x0 217#define SBP2_STATUS_FIFO_ADDRESS_LO 0x0
@@ -333,10 +333,8 @@ struct sbp2_command_info {
333#define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1 333#define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1
334#define SBP2_BREAKAGE_INQUIRY_HACK 0x2 334#define SBP2_BREAKAGE_INQUIRY_HACK 0x2
335 335
336
337struct sbp2scsi_host_info; 336struct sbp2scsi_host_info;
338 337
339
340/* 338/*
341 * Information needed on a per scsi id basis (one for each sbp2 device) 339 * Information needed on a per scsi id basis (one for each sbp2 device)
342 */ 340 */
@@ -406,7 +404,6 @@ struct scsi_id_instance_data {
406 u32 workarounds; 404 u32 workarounds;
407}; 405};
408 406
409
410/* Sbp2 host data structure (one per IEEE1394 host) */ 407/* Sbp2 host data structure (one per IEEE1394 host) */
411struct sbp2scsi_host_info { 408struct sbp2scsi_host_info {
412 struct hpsb_host *host; /* IEEE1394 host */ 409 struct hpsb_host *host; /* IEEE1394 host */