First, let's check out the "driver context" data structure that we shall use throughout this chapter (in fact, we first used it in the previous chapter):
// ch2/procfs_simple_intf/procfs_simple_intf.c
[ ... ]
/* Borrowed from ch1; the 'driver context' data structure;
* all relevant 'state info' reg the driver and (fictional) 'device'
* is maintained here.
*/
struct drv_ctx {
int tx, rx, err, myword, power;
u32 config1; /* treated as equivalent to 'debug level' of our driver */
u32 config2;
u64 config3;
#define MAXBYTES 128
char oursecret[MAXBYTES];
};
static struct drv_ctx *gdrvctx;
static int debug_level; /* 'off' (0) by default ... */
Here, we can also see that we have a global integer named debug_level; this will provide dynamic control over the debug verbosity of the "project". The debug level is assigned a range of [0-2], where we have the following...