LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-23-2006, 05:09 AM   #1
frisky
LQ Newbie
 
Registered: May 2006
Posts: 21

Rep: Reputation: 15
I can't find where the definition of the function pci_bus_read_config_byte()


Hi all,
I can't find where the definition of the function pci_bus_read_config_byte() in file linux/pci.h of kernel 2.16.20. Neither as the other versions. I also searched the *.s files and can't find the prototype definition. Is it just a empty function? It seems impossible.
 
Old 06-23-2006, 05:13 AM   #2
frisky
LQ Newbie
 
Registered: May 2006
Posts: 21

Original Poster
Rep: Reputation: 15
I will use pci_read_config_byte() to read PCI config space byte. It calls pci_bus_read_config_byte() and I can't find the function's definiton. So the problem. Can you help me ? thank you very much!
 
Old 06-23-2006, 05:18 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
I use cscope to navigate through source, its more powerfull that vi ctags.

Install cscope, then go in your src root and do
cscope -R
for the kernel it takes some times (on my old machine, 30s) but its far far quicker than grep and stuffs.

Its a very good little tool, to my mind..

result for your question:
in drivers/pci/access.c
Quote:
int pci_bus_read_config_##size \
(struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
{ \
int res; \
unsigned long flags; \
u32 data = 0; \
if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
spin_lock_irqsave(&pci_lock, flags); \
res = bus->ops->read(bus, devfn, pos, len, &data); \
*value = (type)data; \
spin_unlock_irqrestore(&pci_lock, flags); \
return res; \
}
not easy to spot

Last edited by nx5000; 06-23-2006 at 05:23 AM.
 
Old 06-23-2006, 05:45 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You might try using grep.
quoted from drivers/pci/access.c:
Code:
/*
 * This interrupt-safe spinlock protects all accesses to PCI
 * configuration space.
 */

static DEFINE_SPINLOCK(pci_lock);

/*
 *  Wrappers for all PCI configuration access functions.  They just check
 *  alignment, do locking and call the low-level functions pointed to
 *  by pci_dev->ops.
 */

#define PCI_byte_BAD 0
#define PCI_word_BAD (pos & 1)
#define PCI_dword_BAD (pos & 3)

#define PCI_OP_READ(size,type,len) \
int pci_bus_read_config_##size \
        (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
{                                                                       \
        int res;                                                        \
        unsigned long flags;                                            \
        u32 data = 0;                                                   \
        if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;       \
        spin_lock_irqsave(&pci_lock, flags);                            \
        res = bus->ops->read(bus, devfn, pos, len, &data);              \
        *value = (type)data;                                            \
        spin_unlock_irqrestore(&pci_lock, flags);                       \
        return res;                                                     \
}
 
Old 06-23-2006, 05:50 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
IMHO, grep is a bit archaic for doing this


This is what cscope does:

Quote:
Find this C symbol:
Find this global definition:
Find functions called by this function:
Find functions calling this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:
 
Old 06-25-2006, 05:07 AM   #6
frisky
LQ Newbie
 
Registered: May 2006
Posts: 21

Original Poster
Rep: Reputation: 15
nx5000,jschiwal:
Thank you both. I get it. Yes, I use SI 3.5 to search the symbols. I'm learning cscope Thank you again.
 
  


Reply



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
function definition query slzckboy Programming 1 04-18-2006 08:29 AM
Question about the find function in Kate LaptopLinux Linux - Software 2 06-27-2005 08:32 AM
Defining a non-inline function inside class definition (tm) Programming 6 05-11-2005 09:14 AM
Cannot find strnset() in string.h: none ANSI-C function xxfunkxx Programming 2 12-09-2004 09:18 AM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:57 PM.

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
Open Source Consulting | Domain Registration