diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2013-04-10 07:52:09 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-05-04 14:50:16 -0400 |
commit | 9dcc26cf67fb7db7613290e62eeed6c4276c75ce (patch) | |
tree | c447ac027c63604cb7427d2b285f55b0905eef20 /drivers/scsi/sun3_NCR5380.c | |
parent | e765acb4673f377c53505c01279c040906bd706e (diff) |
sun3_scsi: add ->show_info()
Based on Al's changes to atari_scsi.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/scsi/sun3_NCR5380.c')
-rw-r--r-- | drivers/scsi/sun3_NCR5380.c | 183 |
1 files changed, 78 insertions, 105 deletions
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 7e12a2e4e0a3..636bbe0ea84c 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c | |||
@@ -661,121 +661,94 @@ static void __init NCR5380_print_options (struct Scsi_Host *instance) | |||
661 | * Inputs : instance, pointer to this instance. | 661 | * Inputs : instance, pointer to this instance. |
662 | */ | 662 | */ |
663 | 663 | ||
664 | static void NCR5380_print_status (struct Scsi_Host *instance) | 664 | static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd) |
665 | { | 665 | { |
666 | char *pr_bfr; | 666 | int i, s; |
667 | char *start; | 667 | unsigned char *command; |
668 | int len; | 668 | printk("scsi%d: destination target %d, lun %d\n", |
669 | 669 | H_NO(cmd), cmd->device->id, cmd->device->lun); | |
670 | NCR_PRINT(NDEBUG_ANY); | 670 | printk(KERN_CONT " command = "); |
671 | NCR_PRINT_PHASE(NDEBUG_ANY); | 671 | command = cmd->cmnd; |
672 | 672 | printk(KERN_CONT "%2d (0x%02x)", command[0], command[0]); | |
673 | pr_bfr = (char *) __get_free_page(GFP_ATOMIC); | 673 | for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) |
674 | if (!pr_bfr) { | 674 | printk(KERN_CONT " %02x", command[i]); |
675 | printk("NCR5380_print_status: no memory for print buffer\n"); | 675 | printk("\n"); |
676 | return; | ||
677 | } | ||
678 | len = NCR5380_proc_info(instance, pr_bfr, &start, 0, PAGE_SIZE, 0); | ||
679 | pr_bfr[len] = 0; | ||
680 | printk("\n%s\n", pr_bfr); | ||
681 | free_page((unsigned long) pr_bfr); | ||
682 | } | 676 | } |
683 | 677 | ||
684 | 678 | static void NCR5380_print_status(struct Scsi_Host *instance) | |
685 | /******************************************/ | ||
686 | /* | ||
687 | * /proc/scsi/[dtc pas16 t128 generic]/[0-ASC_NUM_BOARD_SUPPORTED] | ||
688 | * | ||
689 | * *buffer: I/O buffer | ||
690 | * **start: if inout == FALSE pointer into buffer where user read should start | ||
691 | * offset: current offset | ||
692 | * length: length of buffer | ||
693 | * hostno: Scsi_Host host_no | ||
694 | * inout: TRUE - user is writing; FALSE - user is reading | ||
695 | * | ||
696 | * Return the number of bytes read from or written | ||
697 | */ | ||
698 | |||
699 | #undef SPRINTF | ||
700 | #define SPRINTF(fmt,args...) \ | ||
701 | do { if (pos + strlen(fmt) + 20 /* slop */ < buffer + length) \ | ||
702 | pos += sprintf(pos, fmt , ## args); } while(0) | ||
703 | static | ||
704 | char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer, | ||
705 | int length); | ||
706 | |||
707 | static int NCR5380_proc_info(struct Scsi_Host *instance, char *buffer, | ||
708 | char **start, off_t offset, int length, int inout) | ||
709 | { | 679 | { |
710 | char *pos = buffer; | 680 | struct NCR5380_hostdata *hostdata; |
711 | struct NCR5380_hostdata *hostdata; | 681 | Scsi_Cmnd *ptr; |
712 | struct scsi_cmnd *ptr; | 682 | unsigned long flags; |
713 | unsigned long flags; | 683 | |
714 | off_t begin = 0; | 684 | NCR_PRINT(NDEBUG_ANY); |
715 | #define check_offset() \ | 685 | NCR_PRINT_PHASE(NDEBUG_ANY); |
716 | do { \ | 686 | |
717 | if (pos - buffer < offset - begin) { \ | 687 | hostdata = (struct NCR5380_hostdata *)instance->hostdata; |
718 | begin += pos - buffer; \ | 688 | |
719 | pos = buffer; \ | 689 | printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); |
720 | } \ | 690 | local_irq_save(flags); |
721 | } while (0) | 691 | printk("NCR5380: coroutine is%s running.\n", |
722 | 692 | main_running ? "" : "n't"); | |
723 | hostdata = (struct NCR5380_hostdata *)instance->hostdata; | 693 | if (!hostdata->connected) |
724 | 694 | printk("scsi%d: no currently connected command\n", HOSTNO); | |
725 | if (inout) { /* Has data been written to the file ? */ | 695 | else |
726 | return(-ENOSYS); /* Currently this is a no-op */ | 696 | lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected); |
727 | } | 697 | printk("scsi%d: issue_queue\n", HOSTNO); |
728 | SPRINTF("NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); | 698 | for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) |
729 | check_offset(); | 699 | lprint_Scsi_Cmnd(ptr); |
730 | local_irq_save(flags); | 700 | |
731 | SPRINTF("NCR5380: coroutine is%s running.\n", main_running ? "" : "n't"); | 701 | printk("scsi%d: disconnected_queue\n", HOSTNO); |
732 | check_offset(); | 702 | for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; |
733 | if (!hostdata->connected) | 703 | ptr = NEXT(ptr)) |
734 | SPRINTF("scsi%d: no currently connected command\n", HOSTNO); | 704 | lprint_Scsi_Cmnd(ptr); |
735 | else | ||
736 | pos = lprint_Scsi_Cmnd ((struct scsi_cmnd *) hostdata->connected, | ||
737 | pos, buffer, length); | ||
738 | SPRINTF("scsi%d: issue_queue\n", HOSTNO); | ||
739 | check_offset(); | ||
740 | for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = NEXT(ptr)) | ||
741 | { | ||
742 | pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); | ||
743 | check_offset(); | ||
744 | } | ||
745 | |||
746 | SPRINTF("scsi%d: disconnected_queue\n", HOSTNO); | ||
747 | check_offset(); | ||
748 | for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; | ||
749 | ptr = NEXT(ptr)) { | ||
750 | pos = lprint_Scsi_Cmnd (ptr, pos, buffer, length); | ||
751 | check_offset(); | ||
752 | } | ||
753 | 705 | ||
754 | local_irq_restore(flags); | 706 | local_irq_restore(flags); |
755 | *start = buffer + (offset - begin); | 707 | printk("\n"); |
756 | if (pos - buffer < offset - begin) | ||
757 | return 0; | ||
758 | else if (pos - buffer - (offset - begin) < length) | ||
759 | return pos - buffer - (offset - begin); | ||
760 | return length; | ||
761 | } | 708 | } |
762 | 709 | ||
763 | static char *lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, char *pos, char *buffer, | 710 | static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m) |
764 | int length) | ||
765 | { | 711 | { |
766 | int i, s; | 712 | int i, s; |
767 | unsigned char *command; | 713 | unsigned char *command; |
768 | SPRINTF("scsi%d: destination target %d, lun %d\n", | 714 | seq_printf(m, "scsi%d: destination target %d, lun %d\n", |
769 | H_NO(cmd), cmd->device->id, cmd->device->lun); | 715 | H_NO(cmd), cmd->device->id, cmd->device->lun); |
770 | SPRINTF(" command = "); | 716 | seq_printf(m, " command = "); |
771 | command = cmd->cmnd; | 717 | command = cmd->cmnd; |
772 | SPRINTF("%2d (0x%02x)", command[0], command[0]); | 718 | seq_printf(m, "%2d (0x%02x)", command[0], command[0]); |
773 | for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) | 719 | for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) |
774 | SPRINTF(" %02x", command[i]); | 720 | seq_printf(m, " %02x", command[i]); |
775 | SPRINTF("\n"); | 721 | seq_printf(m, "\n"); |
776 | return pos; | ||
777 | } | 722 | } |
778 | 723 | ||
724 | static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) | ||
725 | { | ||
726 | struct NCR5380_hostdata *hostdata; | ||
727 | Scsi_Cmnd *ptr; | ||
728 | unsigned long flags; | ||
729 | |||
730 | hostdata = (struct NCR5380_hostdata *)instance->hostdata; | ||
731 | |||
732 | seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE); | ||
733 | local_irq_save(flags); | ||
734 | seq_printf(m, "NCR5380: coroutine is%s running.\n", | ||
735 | main_running ? "" : "n't"); | ||
736 | if (!hostdata->connected) | ||
737 | seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO); | ||
738 | else | ||
739 | show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); | ||
740 | seq_printf(m, "scsi%d: issue_queue\n", HOSTNO); | ||
741 | for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) | ||
742 | show_Scsi_Cmnd(ptr, m); | ||
743 | |||
744 | seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO); | ||
745 | for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; | ||
746 | ptr = NEXT(ptr)) | ||
747 | show_Scsi_Cmnd(ptr, m); | ||
748 | |||
749 | local_irq_restore(flags); | ||
750 | return 0; | ||
751 | } | ||
779 | 752 | ||
780 | /* | 753 | /* |
781 | * Function : void NCR5380_init (struct Scsi_Host *instance) | 754 | * Function : void NCR5380_init (struct Scsi_Host *instance) |