LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 12-05-2008, 12:55 AM   #1
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Rep: Reputation: 15
Some kernel library function doubts


Sir,

I am trying to learn how to write a device driver for an input device. As a start I tried to understand the actual device driver code written for linux 2.6.9 kernel. It is always good to follow masters in programming . I understood some parts of the code . But I got stuck with some library functions and macros . Hope you masters can shed some light in to my doubts.

1. What is time_after() function ? It is used in the actual serial mouse driver for kernel 2.6.9. Below given is the line where it is used

if (time_after(jiffies, my_mouse->last + HZ/10))
my_mouse->count = 0;

I tried to get the logic behind the line but I failed to do so . I read that jiffies is a global variable that increase with every time tick starting from system log on. Can anybody help me to understand the logic behind this line.

2. There is a mouse connect function which is called whenever we connect a serial mouse to the serial port. The function takes two arguments, a pointer to struct serio and struct serio_drv. This struct serio pointer is used throughout the connect function but we are not initializing it anywhere. So What I understand is that when we connect the serial mouse the input sub system automatically initializes this structure with the details of the mouse we connected so that the driver program can use these details to select the protocol and type of mouse. I just want a conformation from you that what I understand is right (I hope so) .

3. in serio.h headerfile there are some macros defined. like

#define SERIO_TYPE 0xff000000UL
#define SERIO_PROTO 0xFFUL

In the both definition the label UL is used which I believe(?) stands for unsigned long. What my doubt is that why ff (small letter) and FF(capital letter ) is used . What is the difference between these two .

Sorry if the way I asked my questine is not right. My english is not that great. Can anyone help me to understand these points. Thanking you...
 
Old 12-05-2008, 01:58 AM   #2
digvijay.gahlot
Member
 
Registered: Mar 2008
Posts: 53

Rep: Reputation: 15
Do a
# ctags -R *

on root directory of your kernel sources. You will get a tags file, you can search this file for all functions and in which file they are defined.

#define time_after(unknown,known) ((long)(unknown) - (long)(known)<0))
 
Old 12-05-2008, 06:31 AM   #3
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Original Poster
Rep: Reputation: 15
Thanks for the quick replay. But my problem was not how to find where are these macros and function defined. What I want to know is that what they are meant by in my context, say serial mouse. Again thanking for the replay.
 
Old 12-05-2008, 11:15 AM   #4
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,455

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
"time_after" is used to see if a timeout-interval has passed. For instance, "has it been long-enough since the last time this happened?"
 
Old 12-05-2008, 10:43 PM   #5
iamjayanth
Member
 
Registered: Oct 2008
Posts: 51

Original Poster
Rep: Reputation: 15
That is what I want to know about time_after........thanks sundialsvcs.........Then can anyone help me about my other doubts...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
list library function of a shared library .so powah Linux - General 7 10-25-2011 05:47 AM
Doubts in Kernel Stack muralis Linux - Kernel 0 09-04-2008 01:08 PM
How to know the library name when I already know function name letuanle Programming 8 06-08-2007 09:53 AM
gets library function in C reddazz Programming 3 03-27-2005 03:04 AM
what is the function library of the basic graphics library in rethat9.0? zerwolve Red Hat 0 04-29-2004 10:18 PM


All times are GMT -5. The time now is 11:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration