diff options
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 38 | ||||
-rw-r--r-- | include/scsi/scsi_host.h | 13 |
2 files changed, 51 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index e0bd3f790fca..04c2a278076e 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -246,6 +246,43 @@ show_shost_active_mode(struct device *dev, | |||
246 | 246 | ||
247 | static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); | 247 | static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); |
248 | 248 | ||
249 | static int check_reset_type(char *str) | ||
250 | { | ||
251 | if (strncmp(str, "adapter", 10) == 0) | ||
252 | return SCSI_ADAPTER_RESET; | ||
253 | else if (strncmp(str, "firmware", 10) == 0) | ||
254 | return SCSI_FIRMWARE_RESET; | ||
255 | else | ||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | static ssize_t | ||
260 | store_host_reset(struct device *dev, struct device_attribute *attr, | ||
261 | const char *buf, size_t count) | ||
262 | { | ||
263 | struct Scsi_Host *shost = class_to_shost(dev); | ||
264 | struct scsi_host_template *sht = shost->hostt; | ||
265 | int ret = -EINVAL; | ||
266 | char str[10]; | ||
267 | int type; | ||
268 | |||
269 | sscanf(buf, "%s", str); | ||
270 | type = check_reset_type(str); | ||
271 | |||
272 | if (!type) | ||
273 | goto exit_store_host_reset; | ||
274 | |||
275 | if (sht->host_reset) | ||
276 | ret = sht->host_reset(shost, type); | ||
277 | |||
278 | exit_store_host_reset: | ||
279 | if (ret == 0) | ||
280 | ret = count; | ||
281 | return ret; | ||
282 | } | ||
283 | |||
284 | static DEVICE_ATTR(host_reset, S_IWUSR, NULL, store_host_reset); | ||
285 | |||
249 | shost_rd_attr(unique_id, "%u\n"); | 286 | shost_rd_attr(unique_id, "%u\n"); |
250 | shost_rd_attr(host_busy, "%hu\n"); | 287 | shost_rd_attr(host_busy, "%hu\n"); |
251 | shost_rd_attr(cmd_per_lun, "%hd\n"); | 288 | shost_rd_attr(cmd_per_lun, "%hd\n"); |
@@ -272,6 +309,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { | |||
272 | &dev_attr_active_mode.attr, | 309 | &dev_attr_active_mode.attr, |
273 | &dev_attr_prot_capabilities.attr, | 310 | &dev_attr_prot_capabilities.attr, |
274 | &dev_attr_prot_guard_type.attr, | 311 | &dev_attr_prot_guard_type.attr, |
312 | &dev_attr_host_reset.attr, | ||
275 | NULL | 313 | NULL |
276 | }; | 314 | }; |
277 | 315 | ||
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index f1f2644137b8..fc22ad9dba77 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h | |||
@@ -355,6 +355,19 @@ struct scsi_host_template { | |||
355 | */ | 355 | */ |
356 | enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); | 356 | enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); |
357 | 357 | ||
358 | /* This is an optional routine that allows transport to initiate | ||
359 | * LLD adapter or firmware reset using sysfs attribute. | ||
360 | * | ||
361 | * Return values: 0 on success, -ve value on failure. | ||
362 | * | ||
363 | * Status: OPTIONAL | ||
364 | */ | ||
365 | |||
366 | int (*host_reset)(struct Scsi_Host *shost, int reset_type); | ||
367 | #define SCSI_ADAPTER_RESET 1 | ||
368 | #define SCSI_FIRMWARE_RESET 2 | ||
369 | |||
370 | |||
358 | /* | 371 | /* |
359 | * Name of proc directory | 372 | * Name of proc directory |
360 | */ | 373 | */ |