Question

What is the best way to get a character to show up in /dev? I have a driver that calls register_chrdev, and I see the entry in /proc/devices when I load the module. However, I still have to call mknod on the command-line in order to get it show up in /dev.

Is there a good way to do this programmatic-ally at module load time?

Was it helpful?

Solution

To have a device node automatically created, for example by means of udev or devtmpfs, an accompanying kevent needs to be generated. register_chrdev alone does not do this. Instead, it is required to follow the device/driver model (see also Documentation/driver-model/), and make use of kobjects.

Compare with drivers/char/misc.c for one of the simpler examples: it uses device_create(). The prerequisite for that is having a struct class, also showcased by misc.c.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top