device/pnp: introduce and use PNP_SKIP_FUNCTION

-1 shouldn't be assigned to an unsigned variable, so use an otherwise
unused constant here. Since 7 is the highest virtual LDN number, using
0xffff as PNP_SKIP_FUNCTION marker has no unwanted side effects.

Change-Id: I5e31e7ef9dad5fedfd5552963c298336c533a5e9
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/37741
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
This commit is contained in:
Felix Held 2019-12-15 13:53:48 +01:00
parent 116a837818
commit 7b7bc59f20
3 changed files with 6 additions and 2 deletions

View File

@ -370,7 +370,7 @@ void pnp_enable_devices(struct device *base_dev, struct device_operations *ops,
/* Setup the ops and resources on the newly allocated devices. */
for (i = 0; i < functions; i++) {
/* Skip logical devices this Super I/O doesn't have. */
if (info[i].function == -1)
if (info[i].function == PNP_SKIP_FUNCTION)
continue;
path.pnp.device = info[i].function;

View File

@ -34,6 +34,7 @@ extern struct device_operations pnp_ops;
struct pnp_info {
struct device_operations *ops; /* LDN-specific ops override */
#define PNP_SKIP_FUNCTION 0xffff
unsigned int function; /* Must be at least 16 bits (virtual LDNs)! */
unsigned int flags;
#define PNP_IO0 0x000001

View File

@ -280,7 +280,10 @@ static void enable_dev(struct device *dev)
*/
for (j = 0; j < ARRAY_SIZE(pnp_dev_info); j++) {
fn = pnp_dev_info[j].function;
pnp_dev_info[j].function = logical_device_table[i].devs[fn];
if (logical_device_table[i].devs[fn] != -1)
pnp_dev_info[j].function = logical_device_table[i].devs[fn];
else
pnp_dev_info[j].function = PNP_SKIP_FUNCTION;
}
/* Enable the specified devices (if present on the chip). */