Li-Ta Lo <ollie(a)lanl.gov> writes:
I still don't understand why we have to enable some device
even the config file says the device is disabled. The code
if (dev->chip && dev->chip->control &&
int enabled = dev->enabled;
dev->enabled = 1;
dev->enabled = enabled;
tries to ignore the dev->enabled flag and enable the device.
Later the enable_dev() or enable() is called again.
Because we don't know what kind of devices it is, just that it exists.
We temporarily enable the device's config space so we can look up the
type of device (vendor/device id) and get more specific methods. In
the case of the 8111 it does not matter. For some chips we may need
to do more to disable an device than just disable it's pci
The other half of the picture is that doing it that way more reliably
tests the code paths of a device. So we catch it if someone forgets
to implement the code needed if the device is enabled.
Probably that piece of code deserves a comment.