diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-31 00:10:16 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 14:13:15 -0400 |
commit | ee127fec448bb066b549d516af5fe5a596b6ad6c (patch) | |
tree | 2102bcab1a4764af4a680680dd801393deda6831 /drivers/scsi/sym53c8xx_2 | |
parent | 0ffddfbb834557b8babc7f050b83d11dbcbb1008 (diff) |
sym53c8xx_2: switch to ->show_info()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/scsi/sym53c8xx_2')
-rw-r--r-- | drivers/scsi/sym53c8xx_2/sym_glue.c | 115 |
1 files changed, 21 insertions, 94 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 599568299fbe..bac55f7f69f9 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c | |||
@@ -1171,112 +1171,36 @@ printk("sym_user_command: data=%ld\n", uc->data); | |||
1171 | #endif /* SYM_LINUX_USER_COMMAND_SUPPORT */ | 1171 | #endif /* SYM_LINUX_USER_COMMAND_SUPPORT */ |
1172 | 1172 | ||
1173 | 1173 | ||
1174 | #ifdef SYM_LINUX_USER_INFO_SUPPORT | ||
1175 | /* | ||
1176 | * Informations through the proc file system. | ||
1177 | */ | ||
1178 | struct info_str { | ||
1179 | char *buffer; | ||
1180 | int length; | ||
1181 | int offset; | ||
1182 | int pos; | ||
1183 | }; | ||
1184 | |||
1185 | static void copy_mem_info(struct info_str *info, char *data, int len) | ||
1186 | { | ||
1187 | if (info->pos + len > info->length) | ||
1188 | len = info->length - info->pos; | ||
1189 | |||
1190 | if (info->pos + len < info->offset) { | ||
1191 | info->pos += len; | ||
1192 | return; | ||
1193 | } | ||
1194 | if (info->pos < info->offset) { | ||
1195 | data += (info->offset - info->pos); | ||
1196 | len -= (info->offset - info->pos); | ||
1197 | } | ||
1198 | |||
1199 | if (len > 0) { | ||
1200 | memcpy(info->buffer + info->pos, data, len); | ||
1201 | info->pos += len; | ||
1202 | } | ||
1203 | } | ||
1204 | |||
1205 | static int copy_info(struct info_str *info, char *fmt, ...) | ||
1206 | { | ||
1207 | va_list args; | ||
1208 | char buf[81]; | ||
1209 | int len; | ||
1210 | |||
1211 | va_start(args, fmt); | ||
1212 | len = vsprintf(buf, fmt, args); | ||
1213 | va_end(args); | ||
1214 | |||
1215 | copy_mem_info(info, buf, len); | ||
1216 | return len; | ||
1217 | } | ||
1218 | |||
1219 | /* | 1174 | /* |
1220 | * Copy formatted information into the input buffer. | 1175 | * Copy formatted information into the input buffer. |
1221 | */ | 1176 | */ |
1222 | static int sym_host_info(struct Scsi_Host *shost, char *ptr, off_t offset, int len) | 1177 | static int sym_show_info(struct seq_file *m, struct Scsi_Host *shost) |
1223 | { | 1178 | { |
1179 | #ifdef SYM_LINUX_USER_INFO_SUPPORT | ||
1224 | struct sym_data *sym_data = shost_priv(shost); | 1180 | struct sym_data *sym_data = shost_priv(shost); |
1225 | struct pci_dev *pdev = sym_data->pdev; | 1181 | struct pci_dev *pdev = sym_data->pdev; |
1226 | struct sym_hcb *np = sym_data->ncb; | 1182 | struct sym_hcb *np = sym_data->ncb; |
1227 | struct info_str info; | ||
1228 | |||
1229 | info.buffer = ptr; | ||
1230 | info.length = len; | ||
1231 | info.offset = offset; | ||
1232 | info.pos = 0; | ||
1233 | 1183 | ||
1234 | copy_info(&info, "Chip " NAME53C "%s, device id 0x%x, " | 1184 | seq_printf(m, "Chip " NAME53C "%s, device id 0x%x, " |
1235 | "revision id 0x%x\n", np->s.chip_name, | 1185 | "revision id 0x%x\n", np->s.chip_name, |
1236 | pdev->device, pdev->revision); | 1186 | pdev->device, pdev->revision); |
1237 | copy_info(&info, "At PCI address %s, IRQ %u\n", | 1187 | seq_printf(m, "At PCI address %s, IRQ %u\n", |
1238 | pci_name(pdev), pdev->irq); | 1188 | pci_name(pdev), pdev->irq); |
1239 | copy_info(&info, "Min. period factor %d, %s SCSI BUS%s\n", | 1189 | seq_printf(m, "Min. period factor %d, %s SCSI BUS%s\n", |
1240 | (int) (np->minsync_dt ? np->minsync_dt : np->minsync), | 1190 | (int) (np->minsync_dt ? np->minsync_dt : np->minsync), |
1241 | np->maxwide ? "Wide" : "Narrow", | 1191 | np->maxwide ? "Wide" : "Narrow", |
1242 | np->minsync_dt ? ", DT capable" : ""); | 1192 | np->minsync_dt ? ", DT capable" : ""); |
1243 | 1193 | ||
1244 | copy_info(&info, "Max. started commands %d, " | 1194 | seq_printf(m, "Max. started commands %d, " |
1245 | "max. commands per LUN %d\n", | 1195 | "max. commands per LUN %d\n", |
1246 | SYM_CONF_MAX_START, SYM_CONF_MAX_TAG); | 1196 | SYM_CONF_MAX_START, SYM_CONF_MAX_TAG); |
1247 | 1197 | ||
1248 | return info.pos > info.offset? info.pos - info.offset : 0; | 1198 | return 0; |
1249 | } | ||
1250 | #endif /* SYM_LINUX_USER_INFO_SUPPORT */ | ||
1251 | |||
1252 | /* | ||
1253 | * Entry point of the scsi proc fs of the driver. | ||
1254 | * - func = 0 means read (returns adapter infos) | ||
1255 | * - func = 1 means write (not yet merget from sym53c8xx) | ||
1256 | */ | ||
1257 | static int sym53c8xx_proc_info(struct Scsi_Host *shost, char *buffer, | ||
1258 | char **start, off_t offset, int length, int func) | ||
1259 | { | ||
1260 | int retv; | ||
1261 | |||
1262 | if (func) { | ||
1263 | #ifdef SYM_LINUX_USER_COMMAND_SUPPORT | ||
1264 | retv = sym_user_command(shost, buffer, length); | ||
1265 | #else | ||
1266 | retv = -EINVAL; | ||
1267 | #endif | ||
1268 | } else { | ||
1269 | if (start) | ||
1270 | *start = buffer; | ||
1271 | #ifdef SYM_LINUX_USER_INFO_SUPPORT | ||
1272 | retv = sym_host_info(shost, buffer, offset, length); | ||
1273 | #else | 1199 | #else |
1274 | retv = -EINVAL; | 1200 | return -EINVAL; |
1275 | #endif | 1201 | #endif /* SYM_LINUX_USER_INFO_SUPPORT */ |
1276 | } | ||
1277 | |||
1278 | return retv; | ||
1279 | } | 1202 | } |
1203 | |||
1280 | #endif /* SYM_LINUX_PROC_INFO_SUPPORT */ | 1204 | #endif /* SYM_LINUX_PROC_INFO_SUPPORT */ |
1281 | 1205 | ||
1282 | /* | 1206 | /* |
@@ -1742,7 +1666,10 @@ static struct scsi_host_template sym2_template = { | |||
1742 | .use_clustering = ENABLE_CLUSTERING, | 1666 | .use_clustering = ENABLE_CLUSTERING, |
1743 | .max_sectors = 0xFFFF, | 1667 | .max_sectors = 0xFFFF, |
1744 | #ifdef SYM_LINUX_PROC_INFO_SUPPORT | 1668 | #ifdef SYM_LINUX_PROC_INFO_SUPPORT |
1745 | .proc_info = sym53c8xx_proc_info, | 1669 | .show_info = sym_show_info, |
1670 | #ifdef SYM_LINUX_USER_COMMAND_SUPPORT | ||
1671 | .write_info = sym_user_command, | ||
1672 | #endif | ||
1746 | .proc_name = NAME53C8XX, | 1673 | .proc_name = NAME53C8XX, |
1747 | #endif | 1674 | #endif |
1748 | }; | 1675 | }; |