Clearly, in order to create a (pseudo) file under sysfs, we somehow require, as the first parameter to device_create_file(), a pointer to a struct device. However, for our demo sysfs driver here and now, we don't actually have any real device, and therefore no struct device, to work on!
So, can't we create an artificial or pseudo device and simply use it? Yes, but how, and more crucially, why exactly should we have to do this? It's critical to understand that the modern Linux Device Model (LDM) is built on three key components: an underlying bus must exist that devices live on, and devices are "bound to" and driven by device drivers. (We already mentioned this in Chapter 1, Writing a Simple misc Character Device Driver, in the A quick note on the Linux Device Model section).
All of these must be registered to the driver core. Now, don't worry about the buses and the bus drivers that drive them; they...