In our simple demo from the previous section (ch5/cross/helloworld_lkm.c), we have hard-coded a printk() to emit a "Hello/Goodbye, Raspberry Pi world\n" string, regardless of whether or not the kernel module actually runs on a Raspberry Pi device. For a better, though still quite simplistic, way to "detect" some system details (such as the CPU or OS), we refer you to our sample ch5/min_sysinfo/min_sysinfo.c kernel module. In the following code snippet, we show only the relevant function:
// ch5/min_sysinfo/min_sysinfo.c
[ ... ]
void llkd_sysinfo(void)
{
char msg[128];
memset(msg, 0, strlen(msg));
snprintf(msg, 47, "%s(): minimal Platform Info:\nCPU: ", __func__);
/* Strictly speaking, all this #if... is considered ugly and should be
* isolated as far as is possible */
#ifdef CONFIG_X86
#if(BITS_PER_LONG == 32)
strncat(msg, "x86-32, ", 9);
#else
strncat(msg, ...