Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

The release method

The release method is called when the device gets closed, the reverse of the open method. You must then undo everything you have done in the open task. What you have to do is roughly:

  1. Free any private memory allocated during the open() step
  2. Shut down the device (if supported) and discard every buffer on the last closing (if the device supports multi opening, or if the driver can handle more than one device at a time)

The following is an excerpt from a release function:

static int sram_release(struct inode *inode, struct file *filp) { struct pcf2127 *pcf = NULL; pcf = container_of(inode->i_cdev, struct pcf2127, cdev); mutex_lock(&device_list_lock); filp->private_data = NULL; /* last close? */ pcf2127->users--; if (!pcf2127->users) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content