Re: PCI device initialization.

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Tue Mar 28 2000 - 16:20:47 EST


Rui Sousa wrote:
>
> Hi,
>
> Some questions about the new PCI device initialization:
>
> Is check_region() obsolete?

IMNSHO yes. You should call request_region, and check its return value
for NULL (region request failed). request_region is atomic so you much
less worries about region conflicts.

A lot of drivers use check-region and wind up getting things wrong (or
make assumptions based on _very_ old semantics)

> If several devices are found the "probe" function will be called
> several times, once per device?

Correct.

> In the case several devices are found are there any guarantees that
> the "remove" function will be called in the reverse order of "probe"?

Good question. Read through the PCI code, I don't remember. The remove
function is definitely called once for each device removed...

HOWEVER if you are making assumptions based on the order of remove I
think that is a very bad idea overall. Since the new PCI interface
makes hotplug seamless, ideally your driver should not care if the
second of three devices is removed before any of the others...

hint: keep device-specific data stored in pdev->driver_data to assist
your code with being independent of global device lists, and
probe/remove ordering assumptions.

> That is, if I keep the devices in a linked list is the following code
> guaranteed to work? And does the list remain consistent (without "holes")?

use pdev->driver_data _instead of_ a linked list of devices.

> Or do I need to be more careful and search the list for the actual
> device being removed and update it accordingly?

If you must have the device list, be more careful as you describe here.
Otherwise your code will be unstable in the face of hotplug and other
dynamic events (like suspend/resume).

-- 
Jeff Garzik              | Tact is the ability to tell a man 
Building 1024            | he has an open mind when he has a
MandrakeSoft, Inc.       | hole in his head.  (-random fortune)

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:23 EST