Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\genhd.c Create Date:2022-07-28 17:17:41
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:gister_blkdev - register a new block device*@major: the requested major device number [1..BLKDEV_MAJOR_MAX-1]. If*@major = 0, try to allocate any unused major number.*@name: the name of the new block device as a zero terminated string

Proto:int register_blkdev(unsigned int major, const char *name)

Type:int

Parameter:

TypeParameterName
unsigned intmajor
const char *name
357  ret = 0
359  mutex_lock( & block_class_lock)
362  If major == 0 Then
363  When index > 0 cycle
364  If (major_names[index] == NULL) Then Break
368  If index == 0 Then
371  ret = -EBUSY
372  Go to out
374  major = index
375  ret = major
378  If major >= BLKDEV_MAJOR_MAX Then
379  pr_err("%s: major requested (%u) is greater than the maximum (%u) for %s\n", __func__, major, BLKDEV_MAJOR_MAX - 1, name)
382  ret = -EINVAL
383  Go to out
386  p = Allocation memory
387  If (p == NULL) Then
388  ret = -ENOMEM
389  Go to out
392  major = major
393  Copy a NUL terminated string into a sized buffer
394  next = NULL
395  index = dex in the above - for now: assume no multimajor ranges
397  When n cycle
398  If major == major Then Break
401  If Not n Then n = p
403  Else ret = -EBUSY
406  If ret < 0 Then
407  printk - print a kernel message*@fmt: format string* This is printk(). It can be called from any context. We want it to work.* We try to grab the console_lock. If we succeed, it's easy - we log the* output and call the console drivers
409  kfree(p)
411  out :
412  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.
413  Return ret
Caller
NameDescribe
genhd_device_init