Skip to content

Commit

Permalink
scsi: print single-character strings with seq_putc
Browse files Browse the repository at this point in the history
Using seq_putc to print a single character saves at least a strlen()
call and a memory access, and may also give a small .text reduction.

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 3d30079 commit f50332f
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion drivers/scsi/NCR5380.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_puts(m, "\n");
seq_putc(m, '\n');
}

static void lprint_opcode(int opcode, struct seq_file *m)
Expand Down
34 changes: 17 additions & 17 deletions drivers/scsi/advansys.c
Original file line number Diff line number Diff line change
Expand Up @@ -3088,7 +3088,7 @@ static void asc_prt_asc_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
for (i = 0; i <= ASC_MAX_TID; i++)
seq_printf(m, " %c",
(ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
seq_puts(m, "\n");
seq_putc(m, '\n');

#ifdef CONFIG_ISA
if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
Expand Down Expand Up @@ -3203,7 +3203,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
seq_puts(m, " Target ID: ");
for (i = 0; i <= ADV_MAX_TID; i++)
seq_printf(m, " %X", i);
seq_puts(m, "\n");
seq_putc(m, '\n');

if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
word = ep_3550->disc_enable;
Expand All @@ -3216,7 +3216,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
for (i = 0; i <= ADV_MAX_TID; i++)
seq_printf(m, " %c",
(word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
seq_puts(m, "\n");
seq_putc(m, '\n');

if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
word = ep_3550->tagqng_able;
Expand All @@ -3229,7 +3229,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
for (i = 0; i <= ADV_MAX_TID; i++)
seq_printf(m, " %c",
(word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
seq_puts(m, "\n");
seq_putc(m, '\n');

if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
word = ep_3550->start_motor;
Expand All @@ -3242,15 +3242,15 @@ static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
for (i = 0; i <= ADV_MAX_TID; i++)
seq_printf(m, " %c",
(word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
seq_puts(m, "\n");
seq_putc(m, '\n');

if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
seq_puts(m, " Synchronous Transfer:");
for (i = 0; i <= ADV_MAX_TID; i++)
seq_printf(m, " %c",
(ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
'Y' : 'N');
seq_puts(m, "\n");
seq_putc(m, '\n');
}

if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
Expand All @@ -3259,7 +3259,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
seq_printf(m, " %c",
(ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i))
? 'Y' : 'N');
seq_puts(m, "\n");
seq_putc(m, '\n');
}

if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
Expand All @@ -3273,7 +3273,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
for (i = 0; i <= ADV_MAX_TID; i++)
seq_printf(m, " %c",
(word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
seq_puts(m, "\n");
seq_putc(m, '\n');

if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
Expand Down Expand Up @@ -3318,7 +3318,7 @@ static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost
seq_puts(m, "\n ");
sdtr_speed >>= 4;
}
seq_puts(m, "\n");
seq_putc(m, '\n');
}
}

Expand Down Expand Up @@ -3448,7 +3448,7 @@ static void asc_prt_asc_board_info(struct seq_file *m, struct Scsi_Host *shost)
i,
(v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
}
seq_puts(m, "\n");
seq_putc(m, '\n');

for (i = 0; i <= ASC_MAX_TID; i++) {
uchar syn_period_ix;
Expand Down Expand Up @@ -3483,7 +3483,7 @@ static void asc_prt_asc_board_info(struct seq_file *m, struct Scsi_Host *shost)
seq_puts(m, "*\n");
renegotiate = 1;
} else {
seq_puts(m, "\n");
seq_putc(m, '\n');
}
}

Expand Down Expand Up @@ -3570,7 +3570,7 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)

seq_printf(m, " %X:%d", i, lrambyte);
}
seq_puts(m, "\n");
seq_putc(m, '\n');

AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
seq_puts(m, " Wide Enabled:");
Expand All @@ -3584,7 +3584,7 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)
i,
(wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
}
seq_puts(m, "\n");
seq_putc(m, '\n');

AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
seq_puts(m, " Transfer Bit Width:");
Expand All @@ -3603,11 +3603,11 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)

if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
(wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
seq_puts(m, "*");
seq_putc(m, '*');
renegotiate = 1;
}
}
seq_puts(m, "\n");
seq_putc(m, '\n');

AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
seq_puts(m, " Synchronous Enabled:");
Expand All @@ -3621,7 +3621,7 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)
i,
(sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
}
seq_puts(m, "\n");
seq_putc(m, '\n');

AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
for (i = 0; i <= ADV_MAX_TID; i++) {
Expand Down Expand Up @@ -3670,7 +3670,7 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)
seq_puts(m, "*\n");
renegotiate = 1;
} else {
seq_puts(m, "\n");
seq_putc(m, '\n');
}
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/scsi/aic7xxx/aic79xx_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ ahd_format_transinfo(struct seq_file *m, struct ahd_transinfo *tinfo)
}
seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
} else if (freq != 0) {
seq_puts(m, ")");
seq_putc(m, ')');
}
seq_puts(m, "\n");
seq_putc(m, '\n');
}

static void
Expand Down Expand Up @@ -294,14 +294,14 @@ ahd_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
seq_puts(m, "Serial EEPROM:\n");
for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
if (((i % 8) == 0) && (i != 0)) {
seq_puts(m, "\n");
seq_putc(m, '\n');
}
seq_printf(m, "0x%.4x ",
((uint16_t*)ahd->seep_config)[i]);
}
seq_puts(m, "\n");
seq_putc(m, '\n');
}
seq_puts(m, "\n");
seq_putc(m, '\n');

if ((ahd->features & AHD_WIDE) == 0)
max_targ = 8;
Expand Down
10 changes: 5 additions & 5 deletions drivers/scsi/aic7xxx/aic7xxx_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ ahc_format_transinfo(struct seq_file *m, struct ahc_transinfo *tinfo)
}
seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
} else if (freq != 0) {
seq_puts(m, ")");
seq_putc(m, ')');
}
seq_puts(m, "\n");
seq_putc(m, '\n');
}

static void
Expand Down Expand Up @@ -308,14 +308,14 @@ ahc_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
seq_puts(m, "Serial EEPROM:\n");
for (i = 0; i < sizeof(*ahc->seep_config)/2; i++) {
if (((i % 8) == 0) && (i != 0)) {
seq_puts(m, "\n");
seq_putc(m, '\n');
}
seq_printf(m, "0x%.4x ",
((uint16_t*)ahc->seep_config)[i]);
}
seq_puts(m, "\n");
seq_putc(m, '\n');
}
seq_puts(m, "\n");
seq_putc(m, '\n');

max_targ = 16;
if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0)
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/atari_NCR5380.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ static void show_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
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_puts(m, "\n");
seq_putc(m, '\n');
}

static int __maybe_unused NCR5380_show_info(struct seq_file *m,
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/dc395x.c
Original file line number Diff line number Diff line change
Expand Up @@ -4692,7 +4692,7 @@ static int dc395x_show_info(struct seq_file *m, struct Scsi_Host *host)
if (timer_pending(&acb->waiting_timer))
seq_puts(m, "Waiting queue timer running\n");
else
seq_puts(m, "\n");
seq_putc(m, '\n');

list_for_each_entry(dcb, &acb->dcb_list, list) {
struct ScsiReqBlk *srb;
Expand All @@ -4709,7 +4709,7 @@ 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_puts(m, "\n");
seq_putc(m, '\n');
}

if (debug_enabled(DBG_1)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/esas2r/esas2r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ int esas2r_show_info(struct seq_file *m, struct Scsi_Host *sh)
if (dev_count == 0)
seq_puts(m, "none\n");

seq_puts(m, "\n");
seq_putc(m, '\n');
return 0;

}
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/in2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ static int in2000_show_info(struct seq_file *m, struct Scsi_Host *instance)
if (hd->proc & PR_TEST) {
; /* insert your own custom function here */
}
seq_puts(m, "\n");
seq_putc(m, '\n');
spin_unlock_irqrestore(instance->host_lock, flags);
#endif /* PROC_INTERFACE */
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ips.c
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ ips_host_info(ips_ha_t *ha, struct seq_file *m)
seq_printf(m, "\tCurrent Active PT Commands : %d\n",
ha->num_ioctl);

seq_puts(m, "\n");
seq_putc(m, '\n');

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/nsp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ static int nsp32_show_info(struct seq_file *m, struct Scsi_Host *host)
data->target[id].offset
);
}
seq_puts(m, "\n");
seq_putc(m, '\n');
}
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/pcmcia/nsp_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ static int nsp_show_info(struct seq_file *m, struct Scsi_Host *host)
seq_puts(m, "???");
break;
}
seq_puts(m, "\n");
seq_putc(m, '\n');


spin_lock_irqsave(&(data->Lock), flags);
Expand Down Expand Up @@ -1439,7 +1439,7 @@ static int nsp_show_info(struct seq_file *m, struct Scsi_Host *host)
data->Sync[id].SyncOffset
);
}
seq_puts(m, "\n");
seq_putc(m, '\n');
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/qla2xxx/qla_dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ qla2x00_dfs_fce_show(struct seq_file *s, void *unused)
seq_printf(s, "\n%llx: ",
(unsigned long long)((cnt * 4) + fce_start));
else
seq_puts(s, " ");
seq_putc(s, ' ');
seq_printf(s, "%08x", *fce++);
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/scsi/scsi_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,34 +191,34 @@ static int proc_print_scsidevice(struct device *dev, void *data)
if (sdev->vendor[i] >= 0x20)
seq_putc(s, sdev->vendor[i]);
else
seq_puts(s, " ");
seq_putc(s, ' ');
}

seq_puts(s, " Model: ");
for (i = 0; i < 16; i++) {
if (sdev->model[i] >= 0x20)
seq_putc(s, sdev->model[i]);
else
seq_puts(s, " ");
seq_putc(s, ' ');
}

seq_puts(s, " Rev: ");
for (i = 0; i < 4; i++) {
if (sdev->rev[i] >= 0x20)
seq_putc(s, sdev->rev[i]);
else
seq_puts(s, " ");
seq_putc(s, ' ');
}

seq_puts(s, "\n");
seq_putc(s, '\n');

seq_printf(s, " Type: %s ", scsi_device_type(sdev->type));
seq_printf(s, " ANSI SCSI revision: %02x",
sdev->scsi_level - (sdev->scsi_level > 1));
if (sdev->scsi_level == 2)
seq_puts(s, " CCS\n");
else
seq_puts(s, "\n");
seq_putc(s, '\n');

out:
return 0;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/scsi_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ scsi_trace_misc(struct trace_seq *p, unsigned char *cdb, int len)
{
const char *ret = trace_seq_buffer_ptr(p);

trace_seq_puts(p, "-");
trace_seq_putc(p, '-');
trace_seq_putc(p, 0);

return ret;
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/wd33c93.c
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,7 @@ wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance)
cmd = (struct scsi_cmnd *) cmd->host_scribble;
}
}
seq_puts(m, "\n");
seq_putc(m, '\n');
spin_unlock_irq(&hd->lock);
#endif /* PROC_INTERFACE */
return 0;
Expand Down

0 comments on commit f50332f

Please sign in to comment.