I have a bitmap that I need to debug, and it would be much easier for me to printk the number in binary rather than decimal.开发者_高级运维 Can I do this?
Perhaps try hex or octal:
printk("%02X", mybyte);
printk("%03o", mybyte);
There is a function to print a binary value in arch/parisc/kernel/traps.c
, called printbinary()
. You can copy it into your code (or just link it if you happen to be on parisc). Better still move it somewhere generic in the kernel tree, eg. lib
, and send a patch to LKML.
printk uses sprintf which behaves identical to printf. this means you cant printk in binary. There is no format specifier for binary so you will have to write the function your self. You can use a loop to convert a number into a string of its binary representation and then print that string.
精彩评论