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.
在/sys/class/下创建类目录
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
//动态获取主设备号(dev_t devid中包含"主设备号"和"次设备号"信息) alloc_chrdev_region(&devid, 66, 1, "led");
led_Major = MAJOR(devid);
led_Minor = MINOR(devid);
printk(KERN_INFO "I was assigned major number %d.\n", led_Major);
printk(KERN_INFO "I was assigned minor number %d.\n", led_Minor);