= class_create(THIS_MODULE, "sixth_drv");//THIS_MODULE 根据file_operations 这个是定死的 sixth_drv是类名字
sixthdrv_class_dev = class_device_create(sixthdrv_class, NULL, MKDEV(major, 0), NULL, "buttons"); /* /dev/buttons */
class_create()
linux-2.6.22/include/linux/device.h
struct class *class_create(struct module *owner, const char *name)
class_create - create a struct class structure
@owner: pointer to the module that is to “own” this struct class
@name: pointer to a string for the name of this class.
class_device_create()
linux-2.6.22/include/linux/device.h
struct class_device *class_device_create(struct class *cls,
struct class_device *parent,
dev_t devt,
struct device *device,
const char *fmt, …)
class_device_create - creates a class device and registers it with sysfs
@cls: pointer to the struct class that this device should be registered to.
@parent: pointer to the parent struct class_device of this new device, if any.
@devt: the dev_t for the char device to be added.
@device: a pointer to a struct device that is assiociated with this class device.
@fmt: string for the class device's name
class_create 在sys/class/上创建sixth_drv目录
class_device_create 在上面的目录中创建设备节点buttons
为啥要在sys上创建呢?
基于mdev
相关内容
linux中的mdev机制