Re: Question regarding pci_bus_read_config_byte

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 01, 2006 at 04:04:01PM -0600, Jes?s Velazquez wrote:
> Hi guys!
> 
> I am a linux newbie and I am facing some issues regarding accessing the
> configuration space of PCI devices. At this time, I am developing a driver
> which access directly to the configuration space of any PCI device using the
> traditional enumeration scheme: bus, device, function, register. I found
> that I need a struct pci_dev *dev for accessing the configuration space
> using the pci_(read|write)_config_(byte|word|dword). But, I have to enable
> some bits in some devices and I only have the bus, dev, fun, reg numbers, I
> do not have any pci_dev structure.

Then you are not writing a pci driver.  From within a PCI driver, you
always have access to your own pci_dev structure.

> I found that using the
> pci_bus_(read|write)_config(byte|word|dword) funtions I can access to any
> dev+fun device but, how can I create a pci_bus structure from a bus number,
> for example: I want to access to bus=0x0, dev=0x1, func=0x0, reg=0xCA. How
> can I do that?, I mean how can I create the missing pci_bus structure from
> 0?. Also, I found that the bus structure have diferent lists inside of it:
> children, devices, etc.
> 
> This module is just for debugging proposes I know that this is not a proper
> behaivor.

Then I would suggest not doing it from within kernel space :)

You should be able to do all of this from userspace using libpci, right?
You don't need to write kernel code to get to PCI config space for any
device.

But to answer your question, yes, you can do this.  Look at the pci
hotplug drivers for examples of how to hack things up to get access to
this kind of information.

good luck,

greg k-h

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux