0

私が理解しているように、の署名は次のregister_chrdev_regionように記述されています

extern int register_chrdev_region(dev_t firstmajor,unsigned int count,const char*dev_name);
//firstmajor: The major number requested for reservation of the dirver
//dev_name: Name of the device associated with the major number(for procfs and sysfs)
//count: Total number of contagious device numbes that is requested??

count関数での引数の使用法がわかりません(alloc_chrdev_region同様に)。伝染性のあるデバイス番号をドライバーに予約する簡単な使用例を説明してください

http://www.makelinux.net/ldd3/chp-3-sect-2の 3.2.2 を参照

4

2 に答える 2

2

コメントは言った:

/**     
 * alloc_chrdev_region() - register a range of char device numbers
 * @dev: output parameter for first assigned number
 * @baseminor: first of the requested range of minor numbers
 * @count: the number of minor numbers required
 * @name: the name of the associated device or driver
 *      
 * Allocates a range of char device numbers.  The major number will be
 * chosen dynamically, and returned (along with the first minor number)
 * in @dev.  Returns zero or a negative error code.
 */

fs/fuse/cuse.c に例があります。

/* determine and reserve devt */
devt = MKDEV(arg->dev_major, arg->dev_minor);
if (!MAJOR(devt))
        rc = alloc_chrdev_region(&devt, MINOR(devt), 1, devinfo.name);
else
        rc = register_chrdev_region(devt, 1, devinfo.name);
if (rc) {
        printk(KERN_ERR "CUSE: failed to register chrdev region\n");
        goto err;
}
于 2012-11-18T13:13:31.477 に答える