aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/fusion/mptscsih.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/fusion/mptscsih.c')
-rw-r--r--drivers/message/fusion/mptscsih.c98
1 files changed, 7 insertions, 91 deletions
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 164afa71bba7..727819cc7034 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1284,101 +1284,17 @@ mptscsih_info(struct Scsi_Host *SChost)
1284 return h->info_kbuf; 1284 return h->info_kbuf;
1285} 1285}
1286 1286
1287struct info_str { 1287int mptscsih_show_info(struct seq_file *m, struct Scsi_Host *host)
1288 char *buffer;
1289 int length;
1290 int offset;
1291 int pos;
1292};
1293
1294static void
1295mptscsih_copy_mem_info(struct info_str *info, char *data, int len)
1296{
1297 if (info->pos + len > info->length)
1298 len = info->length - info->pos;
1299
1300 if (info->pos + len < info->offset) {
1301 info->pos += len;
1302 return;
1303 }
1304
1305 if (info->pos < info->offset) {
1306 data += (info->offset - info->pos);
1307 len -= (info->offset - info->pos);
1308 }
1309
1310 if (len > 0) {
1311 memcpy(info->buffer + info->pos, data, len);
1312 info->pos += len;
1313 }
1314}
1315
1316static int
1317mptscsih_copy_info(struct info_str *info, char *fmt, ...)
1318{
1319 va_list args;
1320 char buf[81];
1321 int len;
1322
1323 va_start(args, fmt);
1324 len = vsprintf(buf, fmt, args);
1325 va_end(args);
1326
1327 mptscsih_copy_mem_info(info, buf, len);
1328 return len;
1329}
1330
1331static int
1332mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
1333{
1334 struct info_str info;
1335
1336 info.buffer = pbuf;
1337 info.length = len;
1338 info.offset = offset;
1339 info.pos = 0;
1340
1341 mptscsih_copy_info(&info, "%s: %s, ", ioc->name, ioc->prod_name);
1342 mptscsih_copy_info(&info, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word);
1343 mptscsih_copy_info(&info, "Ports=%d, ", ioc->facts.NumberOfPorts);
1344 mptscsih_copy_info(&info, "MaxQ=%d\n", ioc->req_depth);
1345
1346 return ((info.pos > info.offset) ? info.pos - info.offset : 0);
1347}
1348
1349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1350/**
1351 * mptscsih_proc_info - Return information about MPT adapter
1352 * @host: scsi host struct
1353 * @buffer: if write, user data; if read, buffer for user
1354 * @start: returns the buffer address
1355 * @offset: if write, 0; if read, the current offset into the buffer from
1356 * the previous read.
1357 * @length: if write, return length;
1358 * @func: write = 1; read = 0
1359 *
1360 * (linux scsi_host_template.info routine)
1361 */
1362int
1363mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
1364 int length, int func)
1365{ 1288{
1366 MPT_SCSI_HOST *hd = shost_priv(host); 1289 MPT_SCSI_HOST *hd = shost_priv(host);
1367 MPT_ADAPTER *ioc = hd->ioc; 1290 MPT_ADAPTER *ioc = hd->ioc;
1368 int size = 0;
1369 1291
1370 if (func) { 1292 seq_printf(m, "%s: %s, ", ioc->name, ioc->prod_name);
1371 /* 1293 seq_printf(m, "%s%08xh, ", MPT_FW_REV_MAGIC_ID_STRING, ioc->facts.FWVersion.Word);
1372 * write is not supported 1294 seq_printf(m, "Ports=%d, ", ioc->facts.NumberOfPorts);
1373 */ 1295 seq_printf(m, "MaxQ=%d\n", ioc->req_depth);
1374 } else {
1375 if (start)
1376 *start = buffer;
1377
1378 size = mptscsih_host_info(ioc, buffer, offset, length);
1379 }
1380 1296
1381 return size; 1297 return 0;
1382} 1298}
1383 1299
1384/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1300/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -3348,7 +3264,7 @@ EXPORT_SYMBOL(mptscsih_shutdown);
3348EXPORT_SYMBOL(mptscsih_suspend); 3264EXPORT_SYMBOL(mptscsih_suspend);
3349EXPORT_SYMBOL(mptscsih_resume); 3265EXPORT_SYMBOL(mptscsih_resume);
3350#endif 3266#endif
3351EXPORT_SYMBOL(mptscsih_proc_info); 3267EXPORT_SYMBOL(mptscsih_show_info);
3352EXPORT_SYMBOL(mptscsih_info); 3268EXPORT_SYMBOL(mptscsih_info);
3353EXPORT_SYMBOL(mptscsih_qcmd); 3269EXPORT_SYMBOL(mptscsih_qcmd);
3354EXPORT_SYMBOL(mptscsih_slave_destroy); 3270EXPORT_SYMBOL(mptscsih_slave_destroy);