Skip to contentSkip to conversation

scsi: lpfc: Switch to use %ptTs

PATCH In review Andy Shevchenko 3 participants 5 messages Feb 6, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: lpfc: Switch to use %ptTs

Use %ptTs instead of open-coded variant to print contents of time64_t type in human readable form.

---
 drivers/scsi/lpfc/lpfc_init.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +1 -14
index e360fc79b028..240e92143d73 100644
@@ -5643,24 +5643,11 @@ void
 lpfc_cgn_update_tstamp(struct lpfc_hba *phba, struct lpfc_cgn_ts *ts)
 {
 	struct timespec64 cur_time;
-	struct tm tm_val;
 
 	ktime_get_real_ts64(&cur_time);
-	time64_to_tm(cur_time.tv_sec, 0, &tm_val);
-
-	ts->month = tm_val.tm_mon + 1;
-	ts->day	= tm_val.tm_mday;
-	ts->year = tm_val.tm_year - 100;
-	ts->hour = tm_val.tm_hour;
-	ts->minute = tm_val.tm_min;
-	ts->second = tm_val.tm_sec;
 
 	lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
-			"2646 Updated CMF timestamp : "
-			"%u/%u/%u %u:%u:%u\n",
-			ts->day, ts->month,
-			ts->year, ts->hour,
-			ts->minute, ts->second);
+			"2646 Updated CMF timestamp : %ptTs\n", cur_time);
 }
 
 /**
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#1 lore raw
Quoted 25 lines · Andy Shevchenko

Use %ptTs instead of open-coded variant to print contents of time64_t type in human readable form.

---
 drivers/scsi/lpfc/lpfc_init.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +0 -7
index e360fc79b028..240e92143d73 100644
@@ -5643,24 +5643,11 @@ void
 lpfc_cgn_update_tstamp(struct lpfc_hba *phba, struct lpfc_cgn_ts *ts)
 {
 	struct timespec64 cur_time;
-	struct tm tm_val;
 
 	ktime_get_real_ts64(&cur_time);
-	time64_to_tm(cur_time.tv_sec, 0, &tm_val);
-
-	ts->month = tm_val.tm_mon + 1;
-	ts->day	= tm_val.tm_mday;
-	ts->year = tm_val.tm_year - 100;
-	ts->hour = tm_val.tm_hour;

drivers/scsi/lpfc/lpfc_init.c void · line 5650

Quoted 10 lines
drivers/scsi/lpfc/lpfc_init.c +1 -7
-	ts->minute = tm_val.tm_min;
-	ts->second = tm_val.tm_sec;
 
 	lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
-			"2646 Updated CMF timestamp : "
-			"%u/%u/%u %u:%u:%u\n",
-			ts->day, ts->month,
-			ts->year, ts->hour,
-			ts->minute, ts->second);
+			"2646 Updated CMF timestamp : %ptTs\n", cur_time);

All %p<FOO> arguments need to be addresses.
Also %ptT wants a time64_t, not a 'struct timespec64'.
It would work by chance because tv_sec is the first member and time64_t.

Correct: "&cur_time.tv_sec".

Quoted 6 lines
drivers/scsi/lpfc/lpfc_init.c +0 -0
 }
 
 /**
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
#2 lore raw
Quoted 1 line · Thomas Weißschuh

On Thu, Feb 06, 2025 at 05:58:22PM +0200, Andy Shevchenko wrote:

...

Quoted 12 lines

drivers/scsi/lpfc/lpfc_init.c void · line 5650

Quoted 7 lines
drivers/scsi/lpfc/lpfc_init.c +1 -5
 	lpfc_printf_log(phba, KERN_INFO, LOG_CGN_MGMT,
-			"2646 Updated CMF timestamp : "
-			"%u/%u/%u %u:%u:%u\n",
-			ts->day, ts->month,
-			ts->year, ts->hour,
-			ts->minute, ts->second);
+			"2646 Updated CMF timestamp : %ptTs\n", cur_time);

All %p<FOO> arguments need to be addresses.
Also %ptT wants a time64_t, not a 'struct timespec64'.
It would work by chance because tv_sec is the first member and time64_t.

Quoted 1 line

Correct: "&cur_time.tv_sec".

Indeed, thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
In reply to Andy Shevchenko

Hi Andy,

The purpose of the lpfc_cgn_update_tstamp routine is more than just printf. The *ts pointer argument is updated with cur_time, and is typically a pointer to a global statistics struct used by the device driver in various contexts. Sorry, but we can’t remove the lines suggested in this patch.

Regards,
Justin Tee

#4 lore raw
Quoted 7 lines · Justin Tee

Hi Andy,

The purpose of the lpfc_cgn_update_tstamp routine is more than just printf. The *ts pointer argument is updated with cur_time, and is typically a pointer to a global statistics struct used by the device driver in various contexts. Sorry, but we can’t remove the lines suggested in this patch.

Ah, you are right, the ts is used somewhere else.

Signature · 2 lines
With Best Regards,
Andy Shevchenko