# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.1198 -> 1.1199 # drivers/scsi/53c700.c 1.29 -> 1.30 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 03/05/03 jejb@raven.il.steeleye.com 1.1199 # SCSI: implement properties in the 53c700 driver # # Add a store for the queue_depth setting, and a show for a new # property called outstanding tags (this is the information currently # shown by the drivers procfs routine). # -------------------------------------------- # diff -Nru a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c --- a/drivers/scsi/53c700.c Sat May 3 14:27:29 2003 +++ b/drivers/scsi/53c700.c Sat May 3 14:27:29 2003 @@ -172,6 +172,17 @@ STATIC void NCR_700_chip_reset(struct Scsi_Host *host); STATIC int NCR_700_slave_configure(Scsi_Device *SDpnt); STATIC void NCR_700_slave_destroy(Scsi_Device *SDpnt); +STATIC ssize_t NCR_700_device_property_show(struct scsi_device * dev, + char * buf, + struct attribute *attr); +STATIC ssize_t NCR_700_device_property_store(struct scsi_device * dev, + const char * buf, + size_t count, + struct attribute *attr); + +struct device_attribute NCR_700_sdev_attrs[] = { + { .attr = { .name = "outstanding_tags", .mode = S_IRUGO }, }, +}; static char *NCR_700_phase[] = { "", @@ -278,6 +289,8 @@ tpnt->proc_info = NCR_700_proc_directory_info; tpnt->slave_configure = NCR_700_slave_configure; tpnt->slave_destroy = NCR_700_slave_destroy; + tpnt->device_property_show = NCR_700_device_property_show; + tpnt->device_property_store = NCR_700_device_property_store; tpnt->use_blk_tcq = 1; tpnt->highmem_io = 1; @@ -2007,6 +2020,8 @@ STATIC int NCR_700_slave_configure(Scsi_Device *SDp) { + int i; + /* to do here: allocate memory; build a queue_full list */ if(SDp->tagged_supported) { /* do TCQ stuff here */ @@ -2014,14 +2029,63 @@ /* initialise to default depth */ scsi_adjust_queue_depth(SDp, 0, SDp->host->cmd_per_lun); } + + for (i = 0; i < ARRAY_SIZE(NCR_700_sdev_attrs); i++) + device_create_file(&SDp->sdev_driverfs_dev, + &NCR_700_sdev_attrs[i]); return 0; } STATIC void NCR_700_slave_destroy(Scsi_Device *SDp) { - /* to do here: deallocate memory */ + int i; + + /* FIXME: slave_destroy can be called if no driverfs entry + * has been created. We really need a slave_unconfigure for + * this type of thing */ + if(SDp->sdev_driverfs_dev.node.next != NULL) + for (i = 0; i < ARRAY_SIZE(NCR_700_sdev_attrs); i++) + device_remove_file(&SDp->sdev_driverfs_dev, + &NCR_700_sdev_attrs[i]); + +} + +STATIC ssize_t +NCR_700_device_property_show(struct scsi_device * sdev, char * buf, + struct attribute *attr) +{ + char *name = attr->name; + int ret = 0; + + if (strcmp(name, "outstanding_tags") == 0) { + ret = snprintf(buf, 20, "%d\n", NCR_700_get_depth(sdev)); + } + return ret; } + +STATIC ssize_t +NCR_700_device_property_store(struct scsi_device * sdev, const char * buf, + size_t count, struct attribute *attr) +{ + char *name = attr->name; + + if (strcmp(name, "queue_depth") == 0) { + long new_depth = simple_strtol(buf, NULL, 0); + if (new_depth > NCR_700_MAX_TAGS) { + return -EINVAL; + } else if (new_depth < 0) { + /* FIXME: turn off tags need to quiesce the + * device to do this */ + return -EINVAL; + } else { + scsi_adjust_queue_depth(sdev, 0, new_depth); + } + } + return 0; +} + + EXPORT_SYMBOL(NCR_700_detect); EXPORT_SYMBOL(NCR_700_release);