diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-driver-st | 12 | ||||
-rw-r--r-- | Documentation/scsi/st.txt | 4 | ||||
-rw-r--r-- | drivers/scsi/st.c | 30 |
3 files changed, 45 insertions, 1 deletions
diff --git a/Documentation/ABI/testing/sysfs-driver-st b/Documentation/ABI/testing/sysfs-driver-st new file mode 100644 index 000000000000..ba5d77008a85 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-st | |||
@@ -0,0 +1,12 @@ | |||
1 | What: /sys/bus/scsi/drivers/st/debug_flag | ||
2 | Date: October 2015 | ||
3 | Kernel Version: ?.? | ||
4 | Contact: shane.seymour@hpe.com | ||
5 | Description: | ||
6 | This file allows you to turn debug output from the st driver | ||
7 | off if you write a '0' to the file or on if you write a '1'. | ||
8 | Note that debug output requires that the module be compiled | ||
9 | with the #define DEBUG set to a non-zero value (this is the | ||
10 | default). If DEBUG is set to 0 then this file will not | ||
11 | appear in sysfs as its presence is conditional upon debug | ||
12 | output support being compiled into the module. | ||
diff --git a/Documentation/scsi/st.txt b/Documentation/scsi/st.txt index f29fa550665a..b3211af63b79 100644 --- a/Documentation/scsi/st.txt +++ b/Documentation/scsi/st.txt | |||
@@ -569,7 +569,9 @@ Debugging code is now compiled in by default but debugging is turned off | |||
569 | with the kernel module parameter debug_flag defaulting to 0. Debugging | 569 | with the kernel module parameter debug_flag defaulting to 0. Debugging |
570 | can still be switched on and off with an ioctl. To enable debug at | 570 | can still be switched on and off with an ioctl. To enable debug at |
571 | module load time add debug_flag=1 to the module load options, the | 571 | module load time add debug_flag=1 to the module load options, the |
572 | debugging output is not voluminous. | 572 | debugging output is not voluminous. Debugging can also be enabled |
573 | and disabled by writing a '0' (disable) or '1' (enable) to the sysfs | ||
574 | file /sys/bus/scsi/drivers/st/debug_flag. | ||
573 | 575 | ||
574 | If the tape seems to hang, I would be very interested to hear where | 576 | If the tape seems to hang, I would be very interested to hear where |
575 | the driver is waiting. With the command 'ps -l' you can see the state | 577 | the driver is waiting. With the command 'ps -l' you can see the state |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index b37b9b00c4b4..e0a1e52a04e7 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -4452,11 +4452,41 @@ static ssize_t version_show(struct device_driver *ddd, char *buf) | |||
4452 | } | 4452 | } |
4453 | static DRIVER_ATTR_RO(version); | 4453 | static DRIVER_ATTR_RO(version); |
4454 | 4454 | ||
4455 | #if DEBUG | ||
4456 | static ssize_t debug_flag_store(struct device_driver *ddp, | ||
4457 | const char *buf, size_t count) | ||
4458 | { | ||
4459 | /* We only care what the first byte of the data is the rest is unused. | ||
4460 | * if it's a '1' we turn on debug and if it's a '0' we disable it. All | ||
4461 | * other values have -EINVAL returned if they are passed in. | ||
4462 | */ | ||
4463 | if (count > 0) { | ||
4464 | if (buf[0] == '0') { | ||
4465 | debugging = NO_DEBUG; | ||
4466 | return count; | ||
4467 | } else if (buf[0] == '1') { | ||
4468 | debugging = 1; | ||
4469 | return count; | ||
4470 | } | ||
4471 | } | ||
4472 | return -EINVAL; | ||
4473 | } | ||
4474 | |||
4475 | static ssize_t debug_flag_show(struct device_driver *ddp, char *buf) | ||
4476 | { | ||
4477 | return scnprintf(buf, PAGE_SIZE, "%d\n", debugging); | ||
4478 | } | ||
4479 | static DRIVER_ATTR_RW(debug_flag); | ||
4480 | #endif | ||
4481 | |||
4455 | static struct attribute *st_drv_attrs[] = { | 4482 | static struct attribute *st_drv_attrs[] = { |
4456 | &driver_attr_try_direct_io.attr, | 4483 | &driver_attr_try_direct_io.attr, |
4457 | &driver_attr_fixed_buffer_size.attr, | 4484 | &driver_attr_fixed_buffer_size.attr, |
4458 | &driver_attr_max_sg_segs.attr, | 4485 | &driver_attr_max_sg_segs.attr, |
4459 | &driver_attr_version.attr, | 4486 | &driver_attr_version.attr, |
4487 | #if DEBUG | ||
4488 | &driver_attr_debug_flag.attr, | ||
4489 | #endif | ||
4460 | NULL, | 4490 | NULL, |
4461 | }; | 4491 | }; |
4462 | ATTRIBUTE_GROUPS(st_drv); | 4492 | ATTRIBUTE_GROUPS(st_drv); |