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

Filling the file_operations structure

When writing kernel modules, it is better to use designated initializers when it comes to statically initialize structures with their parameters. This consists of naming the member you need to assign a value to. The form is .member-name to designate which member should be initialized. This allows, among other things, initializing the members in an undefined order, or leaving the fields that we do not want to modify unchanged.

Once we have defined our functions, we just have to fill the structure as follows:

static const struct file_operations eep_fops = { .owner = THIS_MODULE, .read = eep_read, .write = eep_write, .open = eep_open, .release = eep_release, .llseek = eep_llseek, .poll = eep_poll, .unlocked_ioctl ...
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