Chinaunix首页 | 论坛 | 博客
  • 博客访问: 337374
  • 博文数量: 61
  • 博客积分: 2816
  • 博客等级: 少校
  • 技术积分: 880
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-18 23:38
文章存档

2012年(1)

2011年(19)

2010年(41)

分类: LINUX

2010-08-29 23:57:02

存在于://device.h

#define class_create(owner, name)               \
({                                              \
        static struct lock_class_key __key;     \
        __class_create(owner, name, &__key);    \
})

扩展阅读
class_create为该设备创建一个class,再为每个设备调用 class_device_create创建对应的设备。大致用法如下:
struct class *myclass = class_create(THIS_MODULE, “my_device_driver”);
class_device_create(myclass, NULL, MKDEV(major_num, 0), NULL, “my_device”);
这样的module被加载时,udev daemon就会自动在/dev下创建my_device设备文件。


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()
-------------------------------------------------
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
阅读(6375) | 评论(2) | 转发(3) |
给主人留下些什么吧!~~

devwang2015-03-21 10:37:33

文明上网,理性发言..学习啦 谢谢.

chinaunix网友2010-08-30 21:30:56

Download More than 1000 free IT eBooks: http://free-ebooks.appspot.com