clkdom_dump(): improve output text

If the call to clknode_get_freq() returns an error (unlikely), report
this, rather than printing the error code as the clock frequency.

If the clock has no parent (e.g. a fixed reference clock), print "none"
rather than "(NULL)(-1)". This is a more human-legible presentation of the
same information.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44267
This commit is contained in:
Mitchell Horne 2024-03-08 10:09:08 -04:00
parent 1cb9f6f641
commit 08635c51d1

View file

@ -512,10 +512,20 @@ clkdom_dump(struct clkdom * clkdom)
CLK_TOPO_SLOCK();
TAILQ_FOREACH(clknode, &clkdom->clknode_list, clkdom_link) {
rv = clknode_get_freq(clknode, &freq);
printf("Clock: %s, parent: %s(%d), freq: %ju\n", clknode->name,
clknode->parent == NULL ? "(NULL)" : clknode->parent->name,
clknode->parent_idx,
(uintmax_t)((rv == 0) ? freq: rv));
if (rv != 0) {
printf("Clock: %s, error getting frequency: %d\n",
clknode->name, rv);
continue;
}
if (clknode->parent != NULL) {
printf("Clock: %s, parent: %s(%d), freq: %ju\n",
clknode->name, clknode->parent->name,
clknode->parent_idx, (uintmax_t)freq);
} else {
printf("Clock: %s, parent: none, freq: %ju\n",
clknode->name, (uintmax_t)freq);
}
}
CLK_TOPO_UNLOCK();
}