Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Called every time a character special file is opened

Proto:static int chrdev_open(struct inode *inode, struct file *filp)

Type:int

Parameter:

TypeParameterName
struct inode *inode
struct file *filp
377  struct cdev * new = NULL
378  ret = 0
380  spin_lock( & cdev_lock)
381  p = i_cdev
382  If Not p Then
385  spin_unlock( & cdev_lock)
386  kobj = kobj_lookup(cdev_map, i_rdev, & idx)
387  If Not kobj Then Return -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  spin_lock( & cdev_lock)
393  p = i_cdev
394  If Not p Then
395  i_cdev = p = new
397  new = NULL
398  Else if Not cdev_get(p) Then ret = -ENXIO
400  Else if Not cdev_get(p) Then ret = -ENXIO
402  spin_unlock( & cdev_lock)
403  cdev_put(new)
404  If ret Then Return ret
407  ret = -ENXIO
408  fops = Alas, no aliases. Too much hassle with bringing module.h everywhere (ops)
409  If Not fops Then Go to 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  If open Then
414  ret = open(inode, filp)
415  If ret Then Go to out_cdev_put
419  Return 0
421  out_cdev_put :
422  cdev_put(p)
423  Return ret