Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\char_dev.c Create Date:2022-07-28 20:02:45
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__register_chrdev() - create and register a cdev occupying a range of minors*@major: major device number or 0 for dynamic allocation*@baseminor: first of the requested range of minor numbers*@count: the number of minor numbers required*@name: name of this

Proto:int __register_chrdev(unsigned int major, unsigned int baseminor, unsigned int count, const char *name, const struct file_operations *fops)

Type:int

Parameter:

TypeParameterName
unsigned intmajor
unsigned intbaseminor
unsigned intcount
const char *name
const struct file_operations *fops
274  err = -ENOMEM
276  cd = Register a single major with a specified minor range.* If major == 0 this function will dynamically allocate an unused major.* If major > 0 this function will attempt to reserve the range of minors* with given major.
277  If IS_ERR(cd) Then Return PTR_ERR(cd)
280  cdev = dev_alloc() - allocate a cdev structure* Allocates and returns a cdev structure, or NULL on failure.
281  If Not cdev Then Go to out2
284  owner = owner
285  ops = fops
286  kobject_set_name() - Set the name of a kobject
288  err = dev_add() - add a char device to the system*@p: the cdev structure for the device*@dev: the first device number for which this device is responsible*@count: the number of consecutive minor numbers corresponding to this* device* cdev_add() adds the device
289  If err Then Go to out
292  will die = cdev
294  Return If major Then 0 Else major
295  out :
296  kobject_put() - Decrement refcount for object.*@kobj: object.* Decrement the refcount, and if 0, call kobject_cleanup().
297  out2 :
298  kfree(__unregister_chrdev_region(major, baseminor, count))
299  Return err
Caller
NameDescribe
cpuid_init
register_chrdev