Add slot number ivar to return which slot number the child is attached to.

This will always be 0 for pccbb, but may be non-zero for other kinds of bridges,
should they show up in the tree. Make querying it generic.
This commit is contained in:
Warner Losh 2019-12-16 21:34:57 +00:00
parent 7b9439d081
commit 1187f0cad2
2 changed files with 18 additions and 0 deletions

View File

@ -151,4 +151,17 @@ exca_clrb(struct exca_softc *sc, int reg, uint8_t mask)
exca_putb(sc, reg, exca_getb(sc, reg) & ~mask);
}
enum {
EXCA_IVAR_SLOT = 100,
};
#define EXCA_ACCESSOR(A, B, T) \
static inline int \
exca_get_ ## A(device_t dev, T *t) \
{ \
return BUS_READ_IVAR(device_get_parent(dev), dev, \
EXCA_IVAR_ ## B, (uintptr_t *) t); \
}
EXCA_ACCESSOR(slot, SLOT, uint32_t)
#endif /* !_SYS_DEV_EXCA_EXCAVAR_H */

View File

@ -1565,6 +1565,9 @@ cbb_read_ivar(device_t brdev, device_t child, int which, uintptr_t *result)
case PCIB_IVAR_BUS:
*result = sc->bus.sec;
return (0);
case EXCA_IVAR_SLOT:
*result = 0;
return (0);
}
return (ENOENT);
}
@ -1578,6 +1581,8 @@ cbb_write_ivar(device_t brdev, device_t child, int which, uintptr_t value)
return (EINVAL);
case PCIB_IVAR_BUS:
return (EINVAL);
case EXCA_IVAR_SLOT:
return (EINVAL);
}
return (ENOENT);
}