tech-kern archive

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

Re: introduce device_is_attached()



On 04/16/12 19:37, David Young wrote:
On Mon, Apr 16, 2012 at 06:52:28PM +0200, Christoph Egger wrote:

Hi,

I want to introduce a new function to sys/devices.h:

bool device_is_attached(device_t parent, cfdata_t cf);

The purpose is for bus drivers who wants to attach children
and ensure that only one instance of it will attach.

'parent' is the bus driver and 'cf' is the child device
as passed to the submatch callback via config_search_loc().

The return value is true if the child is already attached.

I implemented a reference usage of it in amdnb_misc.c to ensure
that amdtemp only attaches once on rescan.

Don't add that function.  Just use a small amdnb_misc softc to track
whether or not the amdtemp is attached or not:

struct amdnb_misc_softc {
        device_t sc_amdtemp;
};

This is what pchb(4) did before the revert. It doesn't meet the needs
of attaching multiple drivers to the same pci device.

Don't pass a pci_attach_args to amdtemp.  Just pass it the chipset tag
and PCI tag if that is all that it needs.

Why is pci_attach_args a no-go ?

I'm not sure I fully understand the purpose of amdnb_miscbus.
Are all of the functions that do/will attach at amdnb_miscbus
configuration-space only functions, or are they something else?  Please
explain what amdnb_miscbus is for.

Drivers attaching to amdnb_miscbus are all pci drivers which use
different capabilities of the northbridge device.
Their match/attach routines need the same 'aux' parameter as it
is passed to amdnb_misc(4).

amdtemp(4) uses some PCI registers of the northbridge device to read
the cpu temperature.
I have a local driver which uses a different feature of the same
northbridge device.
To access the device I need the same chipset tag and pci tag.

Instead of making amdtemp(4) a mess I chose to implement different
features in different small drivers.
This also simplifies handling of erratas: If a feature doesn't work
then just don't let match/attach the corresponding driver.

Christoph


Home | Main Index | Thread Index | Old Index