常见的设备注册函数 | |
| |
来源: ChinaUnix博客 日期: 2008.07.06 10:49 (共有0 条评论) 我要评论 | |
1、register_chrdev 位置 :fs/char_dev.c 原型 :int register_chrdev(unsigned int major, const char *name, const struct file_operations *fops) 说明 : /** * register_chrdev() - Register a major number for character devices. * @major: major device number or 0 for dynamic allocation * @name: name of this range of devices * @fops: file operations associated with this devices * * If @major == 0 this functions will dynamically allocate a major and return * its number. * * If @major > 0 this function will attempt to reserve a device with the given * major number and will return zero on success. * * Returns a -ve errno on failure. * * The name of this device has nothing to do with the name of the device in * /dev. It only helps to keep track of the different owners of devices. If * your module name has only one type of devices it's ok to use e.g. the name * of the module here. * * This function registers a range of 256 minor numbers. The first minor number * is 0. */ 2、register_netdev 位置 :net/core/dev.c 原型 :int register_netdev(struct net_device *dev) 说明 : /** * register_netdev - register a network device * @dev: device to register * * Take a completed network device structure and add it to the kernel * interfaces. A %NETDEV_REGISTER message is sent to the netdev notifier * chain. 0 is returned on success. A negative errno code is returned * on a failure to set up the device, or if the name is a duplicate. * * This is a wrapper around register_netdevice that takes the rtnl semaphore * and expands the device name if you passed a format string to * alloc_netdev. */ 3、register_framebuffer 位置 :driver/video/fbmem.c 原型 :int register_framebuffer(struct fb_info *fb_info) 说明 : /** * register_framebuffer - registers a frame buffer device * @fb_info: frame buffer info structure * * Registers a frame buffer device @fb_info. * * Returns negative errno on error, or zero for success. * */ 4、register_sound_dsp 位置 :sound/sound_core.c 原型 :int register_sound_dsp(const struct file_operations *fops, int dev) 说明 : /** * register_sound_dsp - register a DSP device * @fops: File operations for the driver * @dev: Unit number to allocate * * Allocate a DSP device. Unit is the number of the DSP requested. * Pass -1 to request the next free DSP unit. On success the allocated * number is returned, on failure a negative error code is returned. * * This function allocates both the audio and dsp device entries together * and will always allocate them as a matching pair - eg dsp3/audio3 */ 5、register_sound_mixer 位置 :sound/sound_core.c 原型 :int register_sound_mixer(const struct file_operations *fops, int dev) 说明 : /** * register_sound_mixer - register a mixer device * @fops: File operations for the driver * @dev: Unit number to allocate * * Allocate a mixer device. Unit is the number of the mixer requested. * Pass -1 to request the next free mixer unit. On success the allocated * number is returned, on failure a negative error code is returned. */ 本文来自ChinaUnix博客,如果查看原文请点: http://blog.chinaunix.net/u1/57747/showart_1074074.html | |
常见的设备注册函数
最新推荐文章于 2023-12-08 11:40:29 发布