diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-31 01:46:06 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 14:13:18 -0400 |
| commit | c8ed555aba11236ff973fa937f38d5af87bfb18e (patch) | |
| tree | 35c2fffbbe65866f26b0006d6a362a4f9676e4ab /drivers | |
| parent | cac197031ce274efff8a5abea811b9d69ae3d740 (diff) | |
scsi_debug: switch to ->show_info()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/scsi/scsi_debug.c | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 5cda11c07c68..5add6f4e7928 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
| @@ -2823,31 +2823,27 @@ static const char * scsi_debug_info(struct Scsi_Host * shp) | |||
| 2823 | /* scsi_debug_proc_info | 2823 | /* scsi_debug_proc_info |
| 2824 | * Used if the driver currently has no own support for /proc/scsi | 2824 | * Used if the driver currently has no own support for /proc/scsi |
| 2825 | */ | 2825 | */ |
| 2826 | static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, | 2826 | static int scsi_debug_write_info(struct Scsi_Host *host, char *buffer, int length) |
| 2827 | int length, int inout) | ||
| 2828 | { | 2827 | { |
| 2829 | int len, pos, begin; | 2828 | char arr[16]; |
| 2830 | int orig_length; | 2829 | int opts; |
| 2830 | int minLen = length > 15 ? 15 : length; | ||
| 2831 | 2831 | ||
| 2832 | orig_length = length; | 2832 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) |
| 2833 | 2833 | return -EACCES; | |
| 2834 | if (inout == 1) { | 2834 | memcpy(arr, buffer, minLen); |
| 2835 | char arr[16]; | 2835 | arr[minLen] = '\0'; |
| 2836 | int minLen = length > 15 ? 15 : length; | 2836 | if (1 != sscanf(arr, "%d", &opts)) |
| 2837 | return -EINVAL; | ||
| 2838 | scsi_debug_opts = opts; | ||
| 2839 | if (scsi_debug_every_nth != 0) | ||
| 2840 | scsi_debug_cmnd_count = 0; | ||
| 2841 | return length; | ||
| 2842 | } | ||
| 2837 | 2843 | ||
| 2838 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | 2844 | static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host) |
| 2839 | return -EACCES; | 2845 | { |
| 2840 | memcpy(arr, buffer, minLen); | 2846 | seq_printf(m, "scsi_debug adapter driver, version " |
| 2841 | arr[minLen] = '\0'; | ||
| 2842 | if (1 != sscanf(arr, "%d", &pos)) | ||
| 2843 | return -EINVAL; | ||
| 2844 | scsi_debug_opts = pos; | ||
| 2845 | if (scsi_debug_every_nth != 0) | ||
| 2846 | scsi_debug_cmnd_count = 0; | ||
| 2847 | return length; | ||
| 2848 | } | ||
| 2849 | begin = 0; | ||
| 2850 | pos = len = sprintf(buffer, "scsi_debug adapter driver, version " | ||
| 2851 | "%s [%s]\n" | 2847 | "%s [%s]\n" |
| 2852 | "num_tgts=%d, shared (ram) size=%d MB, opts=0x%x, " | 2848 | "num_tgts=%d, shared (ram) size=%d MB, opts=0x%x, " |
| 2853 | "every_nth=%d(curr:%d)\n" | 2849 | "every_nth=%d(curr:%d)\n" |
| @@ -2862,15 +2858,7 @@ static int scsi_debug_proc_info(struct Scsi_Host *host, char *buffer, char **sta | |||
| 2862 | scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads, | 2858 | scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads, |
| 2863 | sdebug_sectors_per, num_aborts, num_dev_resets, num_bus_resets, | 2859 | sdebug_sectors_per, num_aborts, num_dev_resets, num_bus_resets, |
| 2864 | num_host_resets, dix_reads, dix_writes, dif_errors); | 2860 | num_host_resets, dix_reads, dix_writes, dif_errors); |
| 2865 | if (pos < offset) { | 2861 | return 0; |
| 2866 | len = 0; | ||
| 2867 | begin = pos; | ||
| 2868 | } | ||
| 2869 | *start = buffer + (offset - begin); /* Start of wanted data */ | ||
| 2870 | len -= (offset - begin); | ||
| 2871 | if (len > length) | ||
| 2872 | len = length; | ||
| 2873 | return len; | ||
| 2874 | } | 2862 | } |
| 2875 | 2863 | ||
| 2876 | static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf) | 2864 | static ssize_t sdebug_delay_show(struct device_driver * ddp, char * buf) |
| @@ -3957,7 +3945,8 @@ write: | |||
| 3957 | static DEF_SCSI_QCMD(scsi_debug_queuecommand) | 3945 | static DEF_SCSI_QCMD(scsi_debug_queuecommand) |
| 3958 | 3946 | ||
| 3959 | static struct scsi_host_template sdebug_driver_template = { | 3947 | static struct scsi_host_template sdebug_driver_template = { |
| 3960 | .proc_info = scsi_debug_proc_info, | 3948 | .show_info = scsi_debug_show_info, |
| 3949 | .write_info = scsi_debug_write_info, | ||
| 3961 | .proc_name = sdebug_proc_name, | 3950 | .proc_name = sdebug_proc_name, |
| 3962 | .name = "SCSI DEBUG", | 3951 | .name = "SCSI DEBUG", |
| 3963 | .info = scsi_debug_info, | 3952 | .info = scsi_debug_info, |
