Skip to content

Commit d710741

Browse files
andy-shevpmladek
authored andcommitted
scsi: fnic: Switch to use %ptSp
Use %ptSp instead of open coded variants to print content of struct timespec64 in human readable format. Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Karan Tilak Kumar <kartilak@cisco.com> Link: https://patch.msgid.link/20251113150217.3030010-20-andriy.shevchenko@linux.intel.com [pmladek@suse.com: Fixed output ordering and last_read_time update.] Signed-off-by: Petr Mladek <pmladek@suse.com>
1 parent ed40532 commit d710741

1 file changed

Lines changed: 25 additions & 32 deletions

File tree

drivers/scsi/fnic/fnic_trace.c

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
138138
*/
139139
len += scnprintf(fnic_dbgfs_prt->buffer + len,
140140
(trace_max_pages * PAGE_SIZE * 3) - len,
141-
"%16llu.%09lu %-50s %8x %8x %16llx %16llx "
142-
"%16llx %16llx %16llx\n", (u64)val.tv_sec,
143-
val.tv_nsec, str, tbp->host_no, tbp->tag,
141+
"%ptSp %-50s %8x %8x %16llx %16llx %16llx %16llx %16llx\n",
142+
&val, str, tbp->host_no, tbp->tag,
144143
tbp->data[0], tbp->data[1], tbp->data[2],
145144
tbp->data[3], tbp->data[4]);
146145
rd_idx++;
@@ -180,9 +179,8 @@ int fnic_get_trace_data(fnic_dbgfs_t *fnic_dbgfs_prt)
180179
*/
181180
len += scnprintf(fnic_dbgfs_prt->buffer + len,
182181
(trace_max_pages * PAGE_SIZE * 3) - len,
183-
"%16llu.%09lu %-50s %8x %8x %16llx %16llx "
184-
"%16llx %16llx %16llx\n", (u64)val.tv_sec,
185-
val.tv_nsec, str, tbp->host_no, tbp->tag,
182+
"%ptSp %-50s %8x %8x %16llx %16llx %16llx %16llx %16llx\n",
183+
&val, str, tbp->host_no, tbp->tag,
186184
tbp->data[0], tbp->data[1], tbp->data[2],
187185
tbp->data[3], tbp->data[4]);
188186
rd_idx++;
@@ -215,32 +213,29 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
215213
{
216214
int len = 0;
217215
int buf_size = debug->buf_size;
218-
struct timespec64 val1, val2;
216+
struct timespec64 val, val1, val2;
219217
int i = 0;
220218

221-
ktime_get_real_ts64(&val1);
219+
ktime_get_real_ts64(&val);
222220
len = scnprintf(debug->debug_buffer + len, buf_size - len,
223221
"------------------------------------------\n"
224222
"\t\tTime\n"
225223
"------------------------------------------\n");
226224

225+
val1 = timespec64_sub(val, stats->stats_timestamps.last_reset_time);
226+
val2 = timespec64_sub(val, stats->stats_timestamps.last_read_time);
227227
len += scnprintf(debug->debug_buffer + len, buf_size - len,
228-
"Current time : [%lld:%ld]\n"
229-
"Last stats reset time: [%lld:%09ld]\n"
230-
"Last stats read time: [%lld:%ld]\n"
231-
"delta since last reset: [%lld:%ld]\n"
232-
"delta since last read: [%lld:%ld]\n",
233-
(s64)val1.tv_sec, val1.tv_nsec,
234-
(s64)stats->stats_timestamps.last_reset_time.tv_sec,
235-
stats->stats_timestamps.last_reset_time.tv_nsec,
236-
(s64)stats->stats_timestamps.last_read_time.tv_sec,
237-
stats->stats_timestamps.last_read_time.tv_nsec,
238-
(s64)timespec64_sub(val1, stats->stats_timestamps.last_reset_time).tv_sec,
239-
timespec64_sub(val1, stats->stats_timestamps.last_reset_time).tv_nsec,
240-
(s64)timespec64_sub(val1, stats->stats_timestamps.last_read_time).tv_sec,
241-
timespec64_sub(val1, stats->stats_timestamps.last_read_time).tv_nsec);
242-
243-
stats->stats_timestamps.last_read_time = val1;
228+
"Current time : [%ptSp]\n"
229+
"Last stats reset time: [%ptSp]\n"
230+
"Last stats read time: [%ptSp]\n"
231+
"delta since last reset: [%ptSp]\n"
232+
"delta since last read: [%ptSp]\n",
233+
&val,
234+
&stats->stats_timestamps.last_reset_time,
235+
&stats->stats_timestamps.last_read_time,
236+
&val1, &val2);
237+
238+
stats->stats_timestamps.last_read_time = val;
244239

245240
len += scnprintf(debug->debug_buffer + len, buf_size - len,
246241
"------------------------------------------\n"
@@ -416,8 +411,8 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
416411
jiffies_to_timespec64(stats->misc_stats.last_ack_time, &val2);
417412

418413
len += scnprintf(debug->debug_buffer + len, buf_size - len,
419-
"Last ISR time: %llu (%8llu.%09lu)\n"
420-
"Last ACK time: %llu (%8llu.%09lu)\n"
414+
"Last ISR time: %llu (%ptSp)\n"
415+
"Last ACK time: %llu (%ptSp)\n"
421416
"Max ISR jiffies: %llu\n"
422417
"Max ISR time (ms) (0 denotes < 1 ms): %llu\n"
423418
"Corr. work done: %llu\n"
@@ -437,10 +432,8 @@ int fnic_get_stats_data(struct stats_debug_info *debug,
437432
"Number of rport not ready: %lld\n"
438433
"Number of receive frame errors: %lld\n"
439434
"Port speed (in Mbps): %lld\n",
440-
(u64)stats->misc_stats.last_isr_time,
441-
(s64)val1.tv_sec, val1.tv_nsec,
442-
(u64)stats->misc_stats.last_ack_time,
443-
(s64)val2.tv_sec, val2.tv_nsec,
435+
(u64)stats->misc_stats.last_isr_time, &val1,
436+
(u64)stats->misc_stats.last_ack_time, &val2,
444437
(u64)atomic64_read(&stats->misc_stats.max_isr_jiffies),
445438
(u64)atomic64_read(&stats->misc_stats.max_isr_time_ms),
446439
(u64)atomic64_read(&stats->misc_stats.corr_work_done),
@@ -857,8 +850,8 @@ void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
857850
len = *orig_len;
858851

859852
len += scnprintf(fnic_dbgfs_prt->buffer + len, max_size - len,
860-
"%ptTs.%09lu ns%8x %c%8x\t",
861-
&tdata->time_stamp.tv_sec, tdata->time_stamp.tv_nsec,
853+
"%ptSs ns%8x %c%8x\t",
854+
&tdata->time_stamp,
862855
tdata->host_no, tdata->frame_type, tdata->frame_len);
863856

864857
fc_trace = (char *)FC_TRACE_ADDRESS(tdata);

0 commit comments

Comments
 (0)