When modifying a linux netinterface driver,i use printk to print the system time in driver probe function.but it`s output is weird. code snippet like this:
void *axienet_ptp_timer_probe(void __iomem *base, struct platform_device *pdev)
{
......
ts = ktime_to_timespec64(ktime_get_real());
printk(KERN_ERR "probe:sec:%ld,nsec:%ldn",ts.tv_sec,ts.tv_nsec);
pr_debug("%s: sec: %ld nsec: %ldn", __func__, ts.tv_sec, ts.tv_nsec);
.....
}
when kernel boot, output message:
probe:sec:0,nsec:2
axienet_ptp_timer_probe: sec: 2 nsec: 0
why printk and pr_debug have different output ?
for testing printk ,i also add more parameter to it :
int test =12;
....
ts = ktime_to_timespec64(ktime_get_real());
printk(KERN_ERR "probe:sec:%ld,nsec:%ld,test:%ldn",ts.tv_sec,ts.tv_nsec,test);
pr_debug("%s: sec: %ld nsec: %ldn", __func__, ts.tv_sec, ts.tv_nsec);
output:
probe:sec:0,nsec:2,test:0
axienet_ptp_timer_probe: sec: 2 nsec: 0
New contributor
ghu ftg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.