One way to create a pseudo (or virtual) file under sysfs is via the device_create_file() API. Its signature is as follows:
drivers/base/core.c:int device_create_file(struct device *dev,
const struct device_attribute *attr);
Let's consider its two parameters one by one; first, there is a pointer to struct device. The second parameter is a pointer to a device attribute structure; we shall explain and work on it a bit later (in the Setting up the device attributes and creating the sysfs file section). For now, let's focus on the first parameter only – the device structure. It seems quite intuitive – a device is represented by a metadata structure called device (it is part of the driver core; you can look up its full definition in the include/linux/device.h header).
Note that when you write (or work on) a "real" device driver, chances are high that a generic device structure will exist or...