Commit b592e89ac9af521be164490e45c53c93e89c776f

Authored by Christof Schmitt
Committed by James Bottomley
1 parent 0fac3f477b

[SCSI] zfcp: Remove duplicated code for debug timestamps

The timestamp calculation used for s390dbf output is the same in a
private zfcp function and in debug.c. Replace both with a common
inline function.

Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

Showing 4 changed files with 13 additions and 23 deletions Side-by-side Diff

arch/s390/include/asm/timex.h
... ... @@ -88,6 +88,14 @@
88 88 void init_cpu_timer(void);
89 89 unsigned long long monotonic_clock(void);
90 90  
  91 +void tod_to_timeval(__u64, struct timespec *);
  92 +
  93 +static inline
  94 +void stck_to_timespec(unsigned long long stck, struct timespec *ts)
  95 +{
  96 + tod_to_timeval(stck - TOD_UNIX_EPOCH, ts);
  97 +}
  98 +
91 99 extern u64 sched_clock_base_cc;
92 100  
93 101 #endif
arch/s390/kernel/debug.c
... ... @@ -63,8 +63,6 @@
63 63 } debug_sprintf_entry_t;
64 64  
65 65  
66   -extern void tod_to_timeval(uint64_t todval, struct timespec *xtime);
67   -
68 66 /* internal function prototyes */
69 67  
70 68 static int debug_init(void);
71 69  
... ... @@ -1450,17 +1448,13 @@
1450 1448 int area, debug_entry_t * entry, char *out_buf)
1451 1449 {
1452 1450 struct timespec time_spec;
1453   - unsigned long long time;
1454 1451 char *except_str;
1455 1452 unsigned long caller;
1456 1453 int rc = 0;
1457 1454 unsigned int level;
1458 1455  
1459 1456 level = entry->id.fields.level;
1460   - time = entry->id.stck;
1461   - /* adjust todclock to 1970 */
1462   - time -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096);
1463   - tod_to_timeval(time, &time_spec);
  1457 + stck_to_timespec(entry->id.stck, &time_spec);
1464 1458  
1465 1459 if (entry->id.fields.exception)
1466 1460 except_str = "*";
arch/s390/kernel/time.c
... ... @@ -90,6 +90,7 @@
90 90 todval -= (sec * 1000000) << 12;
91 91 xtime->tv_nsec = ((todval * 1000) >> 12);
92 92 }
  93 +EXPORT_SYMBOL(tod_to_timeval);
93 94  
94 95 void clock_comparator_work(void)
95 96 {
drivers/s390/scsi/zfcp_dbf.c
... ... @@ -38,19 +38,6 @@
38 38 }
39 39 }
40 40  
41   -/* FIXME: this duplicate this code in s390 debug feature */
42   -static void zfcp_dbf_timestamp(unsigned long long stck, struct timespec *time)
43   -{
44   - unsigned long long sec;
45   -
46   - stck -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096);
47   - sec = stck >> 12;
48   - do_div(sec, 1000000);
49   - time->tv_sec = sec;
50   - stck -= (sec * 1000000) << 12;
51   - time->tv_nsec = ((stck * 1000) >> 12);
52   -}
53   -
54 41 static void zfcp_dbf_tag(char **p, const char *label, const char *tag)
55 42 {
56 43 int i;
... ... @@ -107,7 +94,7 @@
107 94 char *p = out_buf;
108 95  
109 96 if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) {
110   - zfcp_dbf_timestamp(entry->id.stck, &t);
  97 + stck_to_timespec(entry->id.stck, &t);
111 98 zfcp_dbf_out(&p, "timestamp", "%011lu:%06lu",
112 99 t.tv_sec, t.tv_nsec);
113 100 zfcp_dbf_out(&p, "cpu", "%02i", entry->id.fields.cpuid);
... ... @@ -320,7 +307,7 @@
320 307 zfcp_dbf_out(p, "fsf_command", "0x%08x", r->fsf_command);
321 308 zfcp_dbf_out(p, "fsf_reqid", "0x%0Lx", r->fsf_reqid);
322 309 zfcp_dbf_out(p, "fsf_seqno", "0x%08x", r->fsf_seqno);
323   - zfcp_dbf_timestamp(r->fsf_issued, &t);
  310 + stck_to_timespec(r->fsf_issued, &t);
324 311 zfcp_dbf_out(p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec);
325 312 zfcp_dbf_out(p, "fsf_prot_status", "0x%08x", r->fsf_prot_status);
326 313 zfcp_dbf_out(p, "fsf_status", "0x%08x", r->fsf_status);
... ... @@ -976,7 +963,7 @@
976 963 zfcp_dbf_out(&p, "old_fsf_reqid", "0x%0Lx", r->old_fsf_reqid);
977 964 zfcp_dbf_out(&p, "fsf_reqid", "0x%0Lx", r->fsf_reqid);
978 965 zfcp_dbf_out(&p, "fsf_seqno", "0x%08x", r->fsf_seqno);
979   - zfcp_dbf_timestamp(r->fsf_issued, &t);
  966 + stck_to_timespec(r->fsf_issued, &t);
980 967 zfcp_dbf_out(&p, "fsf_issued", "%011lu:%06lu", t.tv_sec, t.tv_nsec);
981 968  
982 969 if (strncmp(r->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) {