[Linux1394-cvslog] rev 795 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <ben...@li...> - 2003-02-18 04:09:02
|
Author: bencollins Date: 2003-02-17 23:08:25 -0500 (Mon, 17 Feb 2003) New Revision: 795 Modified: trunk/sbp2.c Log: New proc file for sbp2. More informative. Modified: trunk/sbp2.c ============================================================================== --- trunk/sbp2.c (original) +++ trunk/sbp2.c 2003-02-17 23:08:26.000000000 -0500 @@ -2952,39 +2952,6 @@ } /* - * Called by scsi stack to get bios parameters (used by fdisk, and at boot). - */ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,43) -static int sbp2scsi_biosparam (struct scsi_device *sdev, - struct block_device *dev, sector_t capacity, int geom[]) -{ -#else -static int sbp2scsi_biosparam (Scsi_Disk *disk, kdev_t dev, int geom[]) -{ - unsigned capacity = disk->capacity; -#endif - int heads, sectors, cylinders; - - SBP2_DEBUG("Request for bios parameters"); - - heads = 64; - sectors = 32; - cylinders = (int)capacity / (heads * sectors); - - if (cylinders > 1024) { - heads = 255; - sectors = 63; - cylinders = (int)capacity / (heads * sectors); - } - - geom[0] = heads; - geom[1] = sectors; - geom[2] = cylinders; - - return(0); -} - -/* * Called by scsi stack after scsi driver is registered */ static int sbp2scsi_detect (Scsi_Host_Template *tpnt) @@ -3010,34 +2977,81 @@ return scsi_driver_template.present; } - -/* - * Called for contents of procfs - */ static const char *sbp2scsi_info (struct Scsi_Host *host) { - struct sbp2scsi_host_info *hi = sbp2_find_host_info_scsi(host); - static char info[1024]; + return "SCSI emulation for for IEEE-1394 Storage Devices"; +} + +/* Called for contents of procfs */ +#define SPRINTF(args...) \ + do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0) +static int sbp2scsi_proc_info(char *buffer, char **start, off_t offset, + int length, int hostno, int inout) +{ + Scsi_Device *scd; + struct Scsi_Host *host; + struct sbp2scsi_host_info *hi; + char *pos = buffer; + + /* if someone is sending us data, just throw it away */ + if (inout) + return length; + + host = scsi_host_hn_get(hostno); + if (!host) /* if we couldn't find it, we return an error */ + return -ESRCH; + + hi = sbp2_find_host_info_scsi(host); if (!hi) /* shouldn't happen, but... */ - return "IEEE-1394 SBP-2 protocol driver"; + return -ESRCH; - sprintf(info, "IEEE-1394 SBP-2 protocol driver (host: %s)\n%s\n" - "SBP-2 module load options:\n" - "- Max speed supported: %s\n" - "- Max sectors per I/O supported: %d\n" - "- Serialized I/O (debug): %s\n" - "- Exclusive login: %s", - hi->host->driver->name, - version, - hpsb_speedto_str[sbp2_max_speed], - sbp2_max_sectors, - sbp2_serialize_io ? "yes" : "no", - sbp2_exclusive_login ? "yes" : "no"); + SPRINTF("Host scsi%d : SBP-2 IEEE-1394 (%s)\n", hostno, + hi->host->driver->name); + SPRINTF("Driver version : %s\n", version); - return info; -} + SPRINTF("\nModule options :\n"); + SPRINTF(" sbp2_max_speed : %s\n", hpsb_speedto_str[sbp2_max_speed]); + SPRINTF(" sbp2_max_sectors : %d\n", sbp2_max_sectors); + SPRINTF(" sbp2_serialize_io : %s\n", sbp2_serialize_io ? "yes" : "no"); + SPRINTF(" sbp2_exclusive_login : %s\n", sbp2_exclusive_login ? "yes" : "no"); + + SPRINTF("\nAttached devices : %s\n", !list_empty(&host->my_devices) ? + "" : "none"); + + list_for_each_entry (scd, &host->my_devices, siblings) { + int i; + + SPRINTF(" [Channel: %02d, Id: %02d, Lun: %02d] ", scd->channel, + scd->id, scd->lun); + SPRINTF("%s ", (scd->type < MAX_SCSI_DEVICE_CODE) ? + scsi_device_types[(short) scd->type] : "Unknown device"); + + for (i = 0; (i < 8) && (scd->vendor[i] >= 0x20); i++) + SPRINTF("%c", scd->vendor[i]); + SPRINTF(" "); + + for (i = 0; (i < 16) && (scd->model[i] >= 0x20); i++) + SPRINTF("%c", scd->model[i]); + + SPRINTF("\n"); + } + + SPRINTF("\n"); + + /* release the reference count on this host */ + scsi_host_put(host); + /* Calculate start of next buffer, and return value. */ + *start = buffer + offset; + + if ((pos - buffer) < offset) + return (0); + else if ((pos - buffer - offset) < length) + return (pos - buffer - offset); + else + return (length); +} MODULE_AUTHOR("James Goodwin <ja...@fi...>"); MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver"); @@ -3046,25 +3060,24 @@ /* SCSI host template */ static Scsi_Host_Template scsi_driver_template = { - .name = "IEEE-1394 SBP-2 protocol driver", - .info = sbp2scsi_info, - .detect = sbp2scsi_detect, - .queuecommand = sbp2scsi_queuecommand, - .eh_abort_handler = sbp2scsi_abort, - .eh_device_reset_handler =sbp2scsi_reset, - .eh_bus_reset_handler = sbp2scsi_reset, - .eh_host_reset_handler =sbp2scsi_reset, - .bios_param = sbp2scsi_biosparam, - .this_id = -1, - .sg_tablesize = SG_ALL, - .use_clustering = ENABLE_CLUSTERING, - .cmd_per_lun = SBP2_MAX_CMDS_PER_LUN, - .can_queue = SBP2_MAX_SCSI_QUEUE, -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - .use_new_eh_code = TRUE, -#endif - .emulated = 1, - .proc_name = SBP2_DEVICE_NAME, + .module = THIS_MODULE, + .name = "SBP-2 IEEE-1394", + .proc_name = SBP2_DEVICE_NAME, + .info = sbp2scsi_info, + .proc_info = sbp2scsi_proc_info, + .detect = sbp2scsi_detect, + .queuecommand = sbp2scsi_queuecommand, + .eh_abort_handler = sbp2scsi_abort, + .eh_device_reset_handler = sbp2scsi_reset, + .eh_bus_reset_handler = sbp2scsi_reset, + .eh_host_reset_handler = sbp2scsi_reset, + .this_id = -1, + .sg_tablesize = SG_ALL, + .use_clustering = ENABLE_CLUSTERING, + .cmd_per_lun = SBP2_MAX_CMDS_PER_LUN, + .can_queue = SBP2_MAX_SCSI_QUEUE, + .emulated = 1, + .highmem_io = 1, }; static int sbp2_module_init(void) |