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

Allowing sysfs attribute files to be pollable

Here we will see how not to make CPU wasting polling to sense sysfs attributes data availability. The idea is to use poll or select system calls to wait for the attribute's content to change. The patch to make sysfs attributes pollable was created by Neil Brown and Greg Kroah-Hartman. The kobject manager (the driver which has access to the kobject) must support notification to allow poll or select to return (be released) when the content changes. The magic function that does the trick comes from the kernel side, and is sysfs_notify():

void sysfs_notify(struct kobject *kobj, const char *dir, 
                  const char *attr) 

If the dir parameter is non-null, it is used to find a subdirectory, which contains the ...

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