Skip to content

Commit

Permalink
scsi: replace seq_printf with seq_puts
Browse files Browse the repository at this point in the history
Using seq_printf to print a simple string is a lot more expensive than
it needs to be, since seq_puts exists. Replace seq_printf with
seq_puts when possible.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Rasmus Villemoes authored and James Bottomley committed Feb 2, 2015
1 parent ee7c727 commit 91c40f2
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 138 deletions.
10 changes: 5 additions & 5 deletions drivers/scsi/BusLogic.c
Original file line number Diff line number Diff line change
Expand Up @@ -3485,7 +3485,7 @@ static int blogic_show_info(struct seq_file *m, struct Scsi_Host *shost)
seq_printf(m, "\n\
Current Driver Queue Depth: %d\n\
Currently Allocated CCBs: %d\n", adapter->drvr_qdepth, adapter->alloc_ccbs);
seq_printf(m, "\n\n\
seq_puts(m, "\n\n\
DATA TRANSFER STATISTICS\n\
\n\
Target Tagged Queuing Queue Depth Active Attempted Completed\n\
Expand All @@ -3500,7 +3500,7 @@ Target Tagged Queuing Queue Depth Active Attempted Completed\n\
seq_printf(m,
" %3d %3u %9u %9u\n", adapter->qdepth[tgt], adapter->active_cmds[tgt], tgt_stats[tgt].cmds_tried, tgt_stats[tgt].cmds_complete);
}
seq_printf(m, "\n\
seq_puts(m, "\n\
Target Read Commands Write Commands Total Bytes Read Total Bytes Written\n\
====== ============= ============== =================== ===================\n");
for (tgt = 0; tgt < adapter->maxdev; tgt++) {
Expand All @@ -3517,7 +3517,7 @@ Target Read Commands Write Commands Total Bytes Read Total Bytes Written\
else
seq_printf(m, " %9u\n", tgt_stats[tgt].byteswritten.units);
}
seq_printf(m, "\n\
seq_puts(m, "\n\
Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB\n\
====== ======= ========= ========= ========= ========= =========\n");
for (tgt = 0; tgt < adapter->maxdev; tgt++) {
Expand All @@ -3533,7 +3533,7 @@ Target Command 0-1KB 1-2KB 2-4KB 4-8KB 8-16KB\n\
tgt_stats[tgt].write_sz_buckets[0],
tgt_stats[tgt].write_sz_buckets[1], tgt_stats[tgt].write_sz_buckets[2], tgt_stats[tgt].write_sz_buckets[3], tgt_stats[tgt].write_sz_buckets[4]);
}
seq_printf(m, "\n\
seq_puts(m, "\n\
Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+\n\
====== ======= ========= ========= ========= ========= =========\n");
for (tgt = 0; tgt < adapter->maxdev; tgt++) {
Expand All @@ -3549,7 +3549,7 @@ Target Command 16-32KB 32-64KB 64-128KB 128-256KB 256KB+\n\
tgt_stats[tgt].write_sz_buckets[5],
tgt_stats[tgt].write_sz_buckets[6], tgt_stats[tgt].write_sz_buckets[7], tgt_stats[tgt].write_sz_buckets[8], tgt_stats[tgt].write_sz_buckets[9]);
}
seq_printf(m, "\n\n\
seq_puts(m, "\n\n\
ERROR RECOVERY STATISTICS\n\
\n\
Command Aborts Bus Device Resets Host Adapter Resets\n\
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/NCR5380.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m,
static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
{
seq_printf(m, "scsi%d : destination target %d, lun %llu\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun);
seq_printf(m, " command = ");
seq_puts(m, " command = ");
lprint_command(cmd->cmnd, m);
}

Expand All @@ -764,7 +764,7 @@ static void lprint_command(unsigned char *command, struct seq_file *m)
lprint_opcode(command[0], m);
for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
seq_printf(m, "%02x ", command[i]);
seq_printf(m, "\n");
seq_puts(m, "\n");
}

static void lprint_opcode(int opcode, struct seq_file *m)
Expand Down
38 changes: 18 additions & 20 deletions drivers/scsi/aic7xxx/aic79xx_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ ahd_format_transinfo(struct seq_file *m, struct ahd_transinfo *tinfo)
u_int mb;

if (tinfo->period == AHD_PERIOD_UNKNOWN) {
seq_printf(m, "Renegotiation Pending\n");
seq_puts(m, "Renegotiation Pending\n");
return;
}
speed = 3300;
Expand All @@ -119,40 +119,38 @@ ahd_format_transinfo(struct seq_file *m, struct ahd_transinfo *tinfo)
printed_options = 0;
seq_printf(m, " (%d.%03dMHz", freq / 1000, freq % 1000);
if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
seq_printf(m, " RDSTRM");
seq_puts(m, " RDSTRM");
printed_options++;
}
if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
seq_printf(m, "%s", printed_options ? "|DT" : " DT");
seq_puts(m, printed_options ? "|DT" : " DT");
printed_options++;
}
if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
seq_printf(m, "%s", printed_options ? "|IU" : " IU");
seq_puts(m, printed_options ? "|IU" : " IU");
printed_options++;
}
if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) {
seq_printf(m, "%s",
printed_options ? "|RTI" : " RTI");
seq_puts(m, printed_options ? "|RTI" : " RTI");
printed_options++;
}
if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
seq_printf(m, "%s",
printed_options ? "|QAS" : " QAS");
seq_puts(m, printed_options ? "|QAS" : " QAS");
printed_options++;
}
}

if (tinfo->width > 0) {
if (freq != 0) {
seq_printf(m, ", ");
seq_puts(m, ", ");
} else {
seq_printf(m, " (");
seq_puts(m, " (");
}
seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
} else if (freq != 0) {
seq_printf(m, ")");
seq_puts(m, ")");
}
seq_printf(m, "\n");
seq_puts(m, "\n");
}

static void
Expand All @@ -167,15 +165,15 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct seq_file *m,
tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
target_id, &tstate);
seq_printf(m, "Target %d Negotiation Settings\n", target_id);
seq_printf(m, "\tUser: ");
seq_puts(m, "\tUser: ");
ahd_format_transinfo(m, &tinfo->user);
starget = ahd->platform_data->starget[target_id];
if (starget == NULL)
return;

seq_printf(m, "\tGoal: ");
seq_puts(m, "\tGoal: ");
ahd_format_transinfo(m, &tinfo->goal);
seq_printf(m, "\tCurr: ");
seq_puts(m, "\tCurr: ");
ahd_format_transinfo(m, &tinfo->curr);

for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
Expand Down Expand Up @@ -291,19 +289,19 @@ ahd_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
max_targ = 16;

if (ahd->seep_config == NULL)
seq_printf(m, "No Serial EEPROM\n");
seq_puts(m, "No Serial EEPROM\n");
else {
seq_printf(m, "Serial EEPROM:\n");
seq_puts(m, "Serial EEPROM:\n");
for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
if (((i % 8) == 0) && (i != 0)) {
seq_printf(m, "\n");
seq_puts(m, "\n");
}
seq_printf(m, "0x%.4x ",
((uint16_t*)ahd->seep_config)[i]);
}
seq_printf(m, "\n");
seq_puts(m, "\n");
}
seq_printf(m, "\n");
seq_puts(m, "\n");

if ((ahd->features & AHD_WIDE) == 0)
max_targ = 8;
Expand Down
24 changes: 12 additions & 12 deletions drivers/scsi/aic7xxx/aic7xxx_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ ahc_format_transinfo(struct seq_file *m, struct ahc_transinfo *tinfo)

if (tinfo->width > 0) {
if (freq != 0) {
seq_printf(m, ", ");
seq_puts(m, ", ");
} else {
seq_printf(m, " (");
seq_puts(m, " (");
}
seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
} else if (freq != 0) {
seq_printf(m, ")");
seq_puts(m, ")");
}
seq_printf(m, "\n");
seq_puts(m, "\n");
}

static void
Expand All @@ -145,15 +145,15 @@ ahc_dump_target_state(struct ahc_softc *ahc, struct seq_file *m,
if ((ahc->features & AHC_TWIN) != 0)
seq_printf(m, "Channel %c ", channel);
seq_printf(m, "Target %d Negotiation Settings\n", target_id);
seq_printf(m, "\tUser: ");
seq_puts(m, "\tUser: ");
ahc_format_transinfo(m, &tinfo->user);
starget = ahc->platform_data->starget[target_offset];
if (!starget)
return;

seq_printf(m, "\tGoal: ");
seq_puts(m, "\tGoal: ");
ahc_format_transinfo(m, &tinfo->goal);
seq_printf(m, "\tCurr: ");
seq_puts(m, "\tCurr: ");
ahc_format_transinfo(m, &tinfo->curr);

for (lun = 0; lun < AHC_NUM_LUNS; lun++) {
Expand Down Expand Up @@ -303,19 +303,19 @@ ahc_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)


if (ahc->seep_config == NULL)
seq_printf(m, "No Serial EEPROM\n");
seq_puts(m, "No Serial EEPROM\n");
else {
seq_printf(m, "Serial EEPROM:\n");
seq_puts(m, "Serial EEPROM:\n");
for (i = 0; i < sizeof(*ahc->seep_config)/2; i++) {
if (((i % 8) == 0) && (i != 0)) {
seq_printf(m, "\n");
seq_puts(m, "\n");
}
seq_printf(m, "0x%.4x ",
((uint16_t*)ahc->seep_config)[i]);
}
seq_printf(m, "\n");
seq_puts(m, "\n");
}
seq_printf(m, "\n");
seq_puts(m, "\n");

max_targ = 16;
if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/arm/fas216.c
Original file line number Diff line number Diff line change
Expand Up @@ -2990,7 +2990,7 @@ void fas216_print_devices(FAS216_Info *info, struct seq_file *m)
struct fas216_device *dev;
struct scsi_device *scd;

seq_printf(m, "Device/Lun TaggedQ Parity Sync\n");
seq_puts(m, "Device/Lun TaggedQ Parity Sync\n");

shost_for_each_device(scd, info->host) {
dev = &info->device[scd->id];
Expand All @@ -3000,15 +3000,15 @@ void fas216_print_devices(FAS216_Info *info, struct seq_file *m)
scd->simple_tags ? "en" : "dis",
scd->current_tag);
else
seq_printf(m, "unsupported ");
seq_puts(m, "unsupported ");

seq_printf(m, "%3sabled ", dev->parity_enabled ? "en" : "dis");

if (dev->sof)
seq_printf(m, "offset %d, %d ns\n",
dev->sof, dev->period * 4);
else
seq_printf(m, "async\n");
seq_puts(m, "async\n");
}
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/atari_NCR5380.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,12 +711,12 @@ static void show_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
unsigned char *command;
seq_printf(m, "scsi%d: destination target %d, lun %llu\n",
H_NO(cmd), cmd->device->id, cmd->device->lun);
seq_printf(m, " command = ");
seq_puts(m, " command = ");
command = cmd->cmnd;
seq_printf(m, "%2d (0x%02x)", command[0], command[0]);
for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
seq_printf(m, " %02x", command[i]);
seq_printf(m, "\n");
seq_puts(m, "\n");
}

static int __maybe_unused NCR5380_show_info(struct seq_file *m,
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/atp870u.c
Original file line number Diff line number Diff line change
Expand Up @@ -3101,9 +3101,9 @@ static const char *atp870u_info(struct Scsi_Host *notused)

static int atp870u_show_info(struct seq_file *m, struct Scsi_Host *HBAptr)
{
seq_printf(m, "ACARD AEC-671X Driver Version: 2.6+ac\n");
seq_printf(m, "\n");
seq_printf(m, "Adapter Configuration:\n");
seq_puts(m, "ACARD AEC-671X Driver Version: 2.6+ac\n");
seq_puts(m, "\n");
seq_puts(m, "Adapter Configuration:\n");
seq_printf(m, " Base IO: %#.4lx\n", HBAptr->io_port);
seq_printf(m, " IRQ: %d\n", HBAptr->irq);
return 0;
Expand Down
17 changes: 9 additions & 8 deletions drivers/scsi/dc395x.c
Original file line number Diff line number Diff line change
Expand Up @@ -4623,8 +4623,8 @@ static int dc395x_show_info(struct seq_file *m, struct Scsi_Host *host)
unsigned long flags;
int dev;

seq_printf(m, DC395X_BANNER " PCI SCSI Host Adapter\n");
seq_printf(m, " Driver Version " DC395X_VERSION "\n");
seq_puts(m, DC395X_BANNER " PCI SCSI Host Adapter\n");
seq_puts(m, " Driver Version " DC395X_VERSION "\n");

DC395x_LOCK_IO(acb->scsi_host, flags);

Expand Down Expand Up @@ -4655,7 +4655,8 @@ static int dc395x_show_info(struct seq_file *m, struct Scsi_Host *host)
acb->dcb_map[11], acb->dcb_map[12], acb->dcb_map[13],
acb->dcb_map[14], acb->dcb_map[15]);

seq_printf(m, "Un ID LUN Prty Sync Wide DsCn SndS TagQ nego_period SyncFreq SyncOffs MaxCmd\n");
seq_puts(m,
"Un ID LUN Prty Sync Wide DsCn SndS TagQ nego_period SyncFreq SyncOffs MaxCmd\n");

dev = 0;
list_for_each_entry(dcb, &acb->dcb_list, list) {
Expand All @@ -4681,17 +4682,17 @@ static int dc395x_show_info(struct seq_file *m, struct Scsi_Host *host)
seq_printf(m, " %2i.%1i M %02i ", spd, spd1,
(dcb->sync_offset & 0x0f));
} else
seq_printf(m, " ");
seq_puts(m, " ");

/* Add more info ... */
seq_printf(m, " %02i\n", dcb->max_command);
dev++;
}

if (timer_pending(&acb->waiting_timer))
seq_printf(m, "Waiting queue timer running\n");
seq_puts(m, "Waiting queue timer running\n");
else
seq_printf(m, "\n");
seq_puts(m, "\n");

list_for_each_entry(dcb, &acb->dcb_list, list) {
struct ScsiReqBlk *srb;
Expand All @@ -4708,15 +4709,15 @@ static int dc395x_show_info(struct seq_file *m, struct Scsi_Host *host)
list_for_each_entry(srb, &dcb->srb_going_list, list)
seq_printf(m, " %p", srb->cmd);
if (!list_empty(&dcb->srb_waiting_list) || !list_empty(&dcb->srb_going_list))
seq_printf(m, "\n");
seq_puts(m, "\n");
}

if (debug_enabled(DBG_1)) {
seq_printf(m, "DCB list for ACB %p:\n", acb);
list_for_each_entry(dcb, &acb->dcb_list, list) {
seq_printf(m, "%p -> ", dcb);
}
seq_printf(m, "END\n");
seq_puts(m, "END\n");
}

DC395x_UNLOCK_IO(acb->scsi_host, flags);
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/dpt_i2o.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ static int adpt_show_info(struct seq_file *m, struct Scsi_Host *host)
seq_printf(m, "\tpost fifo size = %d\n\treply fifo size = %d\n\tsg table size = %d\n\n",
host->can_queue, (int) pHba->reply_fifo_size , host->sg_tablesize);

seq_printf(m, "Devices:\n");
seq_puts(m, "Devices:\n");
for(chan = 0; chan < MAX_CHANNEL; chan++) {
for(id = 0; id < MAX_ID; id++) {
d = pHba->channel[chan].device[id];
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/eata_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int eata_pio_show_info(struct seq_file *m, struct Scsi_Host *shost)
shost->host_no, SD(shost)->name);
seq_printf(m, "Firmware revision: v%s\n",
SD(shost)->revision);
seq_printf(m, "IO: PIO\n");
seq_puts(m, "IO: PIO\n");
seq_printf(m, "Base IO : %#.4x\n", (u32) shost->base);
seq_printf(m, "Host Bus: %s\n",
(SD(shost)->bustype == 'P')?"PCI ":
Expand Down
Loading

0 comments on commit 91c40f2

Please sign in to comment.