Subject: Re: CVS commit: src/sys/dev/pci
To: Jason Thorpe <thorpej@shagadelic.org>
From: Gavan Fantom <gavan@NetBSD.org>
List: tech-kern
Date: 02/16/2006 17:38:50
Jason Thorpe wrote:
>> Not really, unless there's a way to tie properties to a specific 
>> *instance* of the driver.
> 
> Yes, properties are tied to specific instances.  See e.g. 
> device_register() in arch/evbmips/alchemy/autoconf.c:
> 
>                         if (prop_set(dev_propdb, dev, "mac-addr",
>                                      ethaddr, sizeof(ethaddr), 0, 0) != 
> 0) {
>                                 printf("WARNING: unable to set mac-addr "
>                                     "property for %s\n", dev->dv_xname);
>                         }

How would you determine in this case whether the ethernet device was 
onboard or on a plug-in card? In the particular case I'm looking at, 
it's just another PCI device on the same bus, and the only real 
distinguishing attribute is the lack of a connected EEPROM.

>> The properties are a fallback in case the checksum fails. This allows 
>> for the scenario where you have one (EEPROM-less) wm chip integrated 
>> into the motherboard, and a PCI add-on card also with a wm chip on it.
> 
> I would say:
> 
>     if (property exists for this device)
>         fetch value from property;
>     else if (eeprom is valid)
>         fetch value from eeprom;
>     else
>         printf("This board sucks, yo!\n");

I'd like to do this, but only if there's a reliable way of determining 
which device to set the properties for.