函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Called every time a character special file is opened

函数原型:static int chrdev_open(struct inode *inode, struct file *filp)

返回类型:int

参数:

类型参数名称
struct inode *inode
struct file *filp
377  struct cdev * new = NULL
378  ret等于0
380  加自旋锁
381  p等于i_cdev
382  如果非p
385  自旋锁解锁
386  kobj等于kobj_lookup(cdev_map, i_rdev, & idx)
387  如果非kobj则返回:负ENXIO
389  new等于container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(kobj, structcdev, kobj)
390  加自旋锁
393  p等于i_cdev
394  如果非p
395  i_cdev等于p等于new
397  new = NULL
398  否则如果非cdev_get(p)则ret等于负ENXIO
400  否则如果非cdev_get(p)则ret等于负ENXIO
402  自旋锁解锁
403  cdev_put(new)
404  如果ret则返回:ret
407  ret等于负ENXIO
408  fops等于Alas, no aliases. Too much hassle with bringing module.h everywhere (ops)
409  如果非fops则转到:out_cdev_put
412  This one is to be used *ONLY* from ->open() instances.* fops must be non-NULL, pinned down *and* module dependencies* should be sufficient to pin the caller down as well.(filp, fops)
413  如果open
414  ret等于open(inode, filp)
415  如果ret则转到:out_cdev_put
419  返回:0
421  out_cdev_put :
422  cdev_put(p)
423  返回:ret