root/drivers/scsi/eata_pio_proc.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. eata_pio_set_info
  2. eata_pio_proc_info

   1 
   2 #define MAX_SCSI_DEVICE_CODE 10
   3 const char *const pio_scsi_dev_types[MAX_SCSI_DEVICE_CODE] =
   4 {
   5     "Direct-Access    ",
   6     "Sequential-Access",
   7     "Printer          ",
   8     "Processor        ",
   9     "WORM             ",
  10     "CD-ROM           ",
  11     "Scanner          ",
  12     "Optical Device   ",
  13     "Medium Changer   ",
  14     "Communications   "
  15 };
  16 
  17 /*
  18  * eata_set_info
  19  * buffer : pointer to the data that has been written to the hostfile
  20  * length : number of bytes written to the hostfile
  21  * HBA_ptr: pointer to the Scsi_Host struct
  22  */
  23 int eata_pio_set_info(char *buffer, int length, struct Scsi_Host *HBA_ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
  24 {
  25     DBG(DBG_PROC_WRITE, printk("%s\n", buffer));
  26     return(-ENOSYS);  /* Currently this is a no-op */
  27 }
  28 
  29 /*
  30  * eata_proc_info
  31  * inout : decides on the direction of the dataflow and the meaning of the 
  32  *         variables
  33  * buffer: If inout==FALSE data is beeing written to it else read from it
  34  * *start: If inout==FALSE start of the valid data in the buffer
  35  * offset: If inout==FALSE offset from the beginning of the imaginary file 
  36  *         from which we start writing into the buffer
  37  * length: If inout==FALSE max number of bytes to be written into the buffer 
  38  *         else number of bytes in the buffer
  39  */
  40 int eata_pio_proc_info(char *buffer, char **start, off_t offset, int length, 
     /* [previous][next][first][last][top][bottom][index][help] */
  41                        int hostno, int inout)
  42 {
  43 
  44     Scsi_Device *scd;
  45     struct Scsi_Host *HBA_ptr;
  46     static u8 buff[512];
  47     int i; 
  48     int   size, len = 0;
  49     off_t begin = 0;
  50     off_t pos = 0;
  51 
  52     HBA_ptr = first_HBA;
  53     for (i = 1; i <= registered_HBAs; i++) {
  54         if (HBA_ptr->host_no == hostno)
  55             break;
  56         HBA_ptr = SD(HBA_ptr)->next;
  57     }        
  58 
  59     if(inout == TRUE) /* Has data been writen to the file ? */ 
  60         return(eata_pio_set_info(buffer, length, HBA_ptr));
  61 
  62     if (offset == 0)
  63         memset(buff, 0, sizeof(buff));
  64 
  65     size = sprintf(buffer+len, "EATA (Extended Attachment) PIO driver version: "
  66                    "%d.%d%s\n",VER_MAJOR, VER_MINOR, VER_SUB);
  67     len += size; pos = begin + len;
  68     size = sprintf(buffer + len, "queued commands:     %10ld\n"
  69                    "processed interrupts:%10ld\n", queue_counter, int_counter);
  70     len += size; pos = begin + len;
  71     
  72     size = sprintf(buffer + len, "\nscsi%-2d: HBA %.10s\n",
  73                    HBA_ptr->host_no, SD(HBA_ptr)->name);
  74     len += size; 
  75     pos = begin + len;
  76     size = sprintf(buffer + len, "Firmware revision: v%s\n", 
  77                    SD(HBA_ptr)->revision);
  78     len += size;
  79     pos = begin + len;
  80     size = sprintf(buffer + len, "IO: PIO\n");
  81     len += size; 
  82     pos = begin + len;
  83     size = sprintf(buffer + len, "Base IO : %#.4x\n", (u32) HBA_ptr->base);
  84     len += size; 
  85     pos = begin + len;
  86     size = sprintf(buffer + len, "Host Bus: %s\n", 
  87                    (SD(HBA_ptr)->bustype == 'P')?"PCI ":
  88                    (SD(HBA_ptr)->bustype == 'E')?"EISA":"ISA ");
  89     
  90     len += size; 
  91     pos = begin + len;
  92     
  93     if (pos < offset) {
  94         len = 0;
  95         begin = pos;
  96     }
  97     if (pos > offset + length)
  98         goto stop_output;
  99     
 100     scd = scsi_devices;
 101     
 102     size = sprintf(buffer+len,"Attached devices: %s\n", (scd)?"":"none");
 103     len += size; 
 104     pos = begin + len;
 105     
 106     while (scd) {
 107         if (scd->host == HBA_ptr) {
 108             proc_print_scsidevice(scd, buffer, &size, len);
 109             len += size; 
 110             pos = begin + len;
 111             
 112             if (pos < offset) {
 113                 len = 0;
 114                 begin = pos;
 115             }
 116             if (pos > offset + length)
 117                 goto stop_output;
 118         }
 119         scd = scd->next;
 120     }
 121     
 122  stop_output:
 123     DBG(DBG_PROC, printk("2pos: %ld offset: %ld len: %d\n", pos, offset, len));
 124     *start=buffer+(offset-begin);   /* Start of wanted data */
 125     len-=(offset-begin);            /* Start slop */
 126     if(len>length)
 127         len = length;               /* Ending slop */
 128     DBG(DBG_PROC, printk("3pos: %ld offset: %ld len: %d\n", pos, offset, len));
 129     
 130     return (len);     
 131 }
 132 
 133 /*
 134  * Overrides for Emacs so that we follow Linus's tabbing style.
 135  * Emacs will notice this stuff at the end of the file and automatically
 136  * adjust the settings for this buffer only.  This must remain at the end
 137  * of the file.
 138  * ---------------------------------------------------------------------------
 139  * Local variables:
 140  * c-indent-level: 4
 141  * c-brace-imaginary-offset: 0
 142  * c-brace-offset: -4
 143  * c-argdecl-indent: 4
 144  * c-label-offset: -4
 145  * c-continued-statement-offset: 4
 146  * c-continued-brace-offset: 0
 147  * tab-width: 8
 148  * End:
 149  */
 150 

/* [previous][next][first][last][top][bottom][index][help] */