函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\char_dev.c Create Date:2022-07-29 10:32:39
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称: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.

函数原型:static struct char_device_struct *__register_chrdev_region(unsigned int major, unsigned int baseminor, int minorct, const char *name)

返回类型:struct char_device_struct

参数:

类型参数名称
unsigned intmajor
unsigned intbaseminor
intminorct
const char *name
100  struct char_device_struct * cd, * curr, * prev = NULL
104  如果major大于等于s/char_dev.c
105  打印错误信息("CHRDEV \"%s\" major requested (%u) is greater than the maximum (%u)\n", name, major, s/char_dev.c - 1)
107  返回:错误号
110  如果minorct大于MINORMASK加1减baseminor
111  打印错误信息("CHRDEV \"%s\" minor range requested (%u-%u) is out of range of maximum range (%u-%u) for a single major\n", name, baseminor, baseminor + minorct - 1, 0, MINORMASK)
113  返回:错误号
116  cd等于分配内存并置零
117  如果(cd == NULL)则返回:错误号
120  mutex_lock( & chrdevs_lock)
122  如果major恒等于0则
123  ret等于find_dynamic_major()
124  如果ret小于0则
125  打印错误信息("CHRDEV \"%s\" dynamic allocation region is full\n", name)
127  转到:out
129  major等于ret
132  ret等于负EBUSY
133  i等于dex in the above
134 curr循环
135  如果major小于major则继续下一循环
138  如果major大于major退出
141  如果baseminorminorct小于等于baseminor则继续下一循环
144  如果baseminor大于等于baseminorminorct退出
147  转到:out
150  major等于major
151  baseminor等于baseminor
152  minorct等于minorct
153  长字符串复制
155  如果非prev
156  next等于curr
157  chrdevs[i]等于cd
158  否则
159  next等于next
160  next等于cd
163  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
164  返回:cd
165  out :
166  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
167  释放内存
168  返回:错误号
调用者
名称描述
register_chrdev_regiongister_chrdev_region() - register a range of device numbers*@from: the first in the desired range of device numbers; must include* the major number.*@count: the number of consecutive device numbers required*@name: the name of the device or driver.
alloc_chrdev_regionalloc_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
__register_chrdev__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