diff options
Diffstat (limited to 'drivers/scsi/scsi_sysfs.c')
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 8ff62c26a41..9117d0bf408 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -287,7 +287,9 @@ show_shost_eh_deadline(struct device *dev, { struct Scsi_Host *shost = class_to_shost(dev); - return sprintf(buf, "%d\n", shost->eh_deadline / HZ); + if (shost->eh_deadline == -1) + return snprintf(buf, strlen("off") + 2, "off\n"); + return sprintf(buf, "%u\n", shost->eh_deadline / HZ); } static ssize_t @@ -296,22 +298,34 @@ store_shost_eh_deadline(struct device *dev, struct device_attribute *attr, { struct Scsi_Host *shost = class_to_shost(dev); int ret = -EINVAL; - int deadline; - unsigned long flags; + unsigned long deadline, flags; if (shost->transportt && shost->transportt->eh_strategy_handler) return ret; - if (sscanf(buf, "%d\n", &deadline) == 1) { - spin_lock_irqsave(shost->host_lock, flags); - if (scsi_host_in_recovery(shost)) - ret = -EBUSY; - else { + if (!strncmp(buf, "off", strlen("off"))) + deadline = -1; + else { + ret = kstrtoul(buf, 10, &deadline); + if (ret) + return ret; + if (deadline * HZ > UINT_MAX) + return -EINVAL; + } + + spin_lock_irqsave(shost->host_lock, flags); + if (scsi_host_in_recovery(shost)) + ret = -EBUSY; + else { + if (deadline == -1) + shost->eh_deadline = -1; + else shost->eh_deadline = deadline * HZ; - ret = count; - } - spin_unlock_irqrestore(shost->host_lock, flags); + + ret = count; } + spin_unlock_irqrestore(shost->host_lock, flags); + return ret; } |