From ca66ca1bce056a674e0299dbd3d1385f9fa6fe13 Mon Sep 17 00:00:00 2001 From: Vikas Chaudhary Date: Fri, 12 Aug 2011 02:51:28 -0700 Subject: [PATCH] --- yaml --- r: 270998 b: refs/heads/master c: 2944369144548432f3a5ffce7a2926bfb4ce4f0a h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/scsi/scsi_sysfs.c | 38 +++++++++++++++++++++++++++++++++ trunk/include/scsi/scsi_host.h | 13 +++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 79d009796cd4..7de5e4bc12d8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 6085491c34b37fa806f70ccd3fb2bf08416e9e98 +refs/heads/master: 2944369144548432f3a5ffce7a2926bfb4ce4f0a diff --git a/trunk/drivers/scsi/scsi_sysfs.c b/trunk/drivers/scsi/scsi_sysfs.c index e0bd3f790fca..04c2a278076e 100644 --- a/trunk/drivers/scsi/scsi_sysfs.c +++ b/trunk/drivers/scsi/scsi_sysfs.c @@ -246,6 +246,43 @@ show_shost_active_mode(struct device *dev, static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); +static int check_reset_type(char *str) +{ + if (strncmp(str, "adapter", 10) == 0) + return SCSI_ADAPTER_RESET; + else if (strncmp(str, "firmware", 10) == 0) + return SCSI_FIRMWARE_RESET; + else + return 0; +} + +static ssize_t +store_host_reset(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct Scsi_Host *shost = class_to_shost(dev); + struct scsi_host_template *sht = shost->hostt; + int ret = -EINVAL; + char str[10]; + int type; + + sscanf(buf, "%s", str); + type = check_reset_type(str); + + if (!type) + goto exit_store_host_reset; + + if (sht->host_reset) + ret = sht->host_reset(shost, type); + +exit_store_host_reset: + if (ret == 0) + ret = count; + return ret; +} + +static DEVICE_ATTR(host_reset, S_IWUSR, NULL, store_host_reset); + shost_rd_attr(unique_id, "%u\n"); shost_rd_attr(host_busy, "%hu\n"); shost_rd_attr(cmd_per_lun, "%hd\n"); @@ -272,6 +309,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { &dev_attr_active_mode.attr, &dev_attr_prot_capabilities.attr, &dev_attr_prot_guard_type.attr, + &dev_attr_host_reset.attr, NULL }; diff --git a/trunk/include/scsi/scsi_host.h b/trunk/include/scsi/scsi_host.h index f1f2644137b8..fc22ad9dba77 100644 --- a/trunk/include/scsi/scsi_host.h +++ b/trunk/include/scsi/scsi_host.h @@ -355,6 +355,19 @@ struct scsi_host_template { */ enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); + /* This is an optional routine that allows transport to initiate + * LLD adapter or firmware reset using sysfs attribute. + * + * Return values: 0 on success, -ve value on failure. + * + * Status: OPTIONAL + */ + + int (*host_reset)(struct Scsi_Host *shost, int reset_type); +#define SCSI_ADAPTER_RESET 1 +#define SCSI_FIRMWARE_RESET 2 + + /* * Name of proc directory */