Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Linux Device Driver Development Cookbook

You're reading from   Linux Device Driver Development Cookbook Learn kernel programming and build custom drivers for your embedded Linux applications

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781838558802
Length 356 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Rodolfo Giometti Rodolfo Giometti
Author Profile Icon Rodolfo Giometti
Rodolfo Giometti
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Installing the Development System FREE CHAPTER 2. A Peek Inside the Kernel 3. Working with Char Drivers 4. Using the Device Tree 5. Managing Interrupts and Concurrency 6. Miscellaneous Kernel Internals 7. Advanced Char Driver Operations 8. Additional Information: Working with Char Drivers 9. Additional Information: Using the Device Tree 10. Additional Information: Managing Interrupts and Concurrency 11. Additional Information: Miscellaneous Kernel Internals 12. Additional Information: Advanced Char Driver Operations 13. Other Books You May Enjoy

Spending time in the kernel

In Chapter 5, Managing Interrupts and Concurrency, we saw how we can defer action at a later time; however, it may happen that we still have to wait some time between two operations on a peripheral, as follows:

writeb(0x12, ctrl_reg);
wait_us(100);
writeb(0x00, ctrl_reg);

That is, if we have to write a value into a register, then wait for 100 microseconds, then write another value, these operations can be done by simply using functions defined in the linux/include/linux/delay.h header file (and other ones) instead of using techniques presented before (kernel timers and workqueues, and so on):

void ndelay(unsigned long nsecs);
void udelay(unsigned long usecs);
void mdelay(unsigned long msecs);

void usleep_range(unsigned long min, unsigned long max);
void msleep(unsigned int msecs);
unsigned long msleep_interruptible(unsigned int msecs);
void ssleep(unsigned...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image