Make ichsmb(4) child device handling properly.
This commit is contained in:
parent
2cc12aded0
commit
2e6e32da7b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=147253
@ -96,14 +96,6 @@ static int ichsmb_wait(sc_p sc);
|
||||
int
|
||||
ichsmb_probe(device_t dev)
|
||||
{
|
||||
device_t smb;
|
||||
|
||||
/* Add child: an instance of the "smbus" device */
|
||||
if ((smb = device_add_child(dev, DRIVER_SMBUS, -1)) == NULL) {
|
||||
log(LOG_ERR, "%s: no \"%s\" child found\n",
|
||||
device_get_nameunit(dev), DRIVER_SMBUS);
|
||||
return (ENXIO);
|
||||
}
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
@ -116,6 +108,14 @@ ichsmb_attach(device_t dev)
|
||||
{
|
||||
const sc_p sc = device_get_softc(dev);
|
||||
int error;
|
||||
device_t smb;
|
||||
|
||||
/* Add child: an instance of the "smbus" device */
|
||||
if ((smb = device_add_child(dev, DRIVER_SMBUS, -1)) == NULL) {
|
||||
log(LOG_ERR, "%s: no \"%s\" child found\n",
|
||||
device_get_nameunit(dev), DRIVER_SMBUS);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/* Clear interrupt conditions */
|
||||
bus_space_write_1(sc->io_bst, sc->io_bsh, ICH_HST_STA, 0xff);
|
||||
@ -675,3 +675,17 @@ ichsmb_release_resources(sc_p sc)
|
||||
}
|
||||
}
|
||||
|
||||
int ichsmb_detach(device_t dev)
|
||||
{
|
||||
#if 0
|
||||
const sc_p sc = device_get_softc(dev);
|
||||
bus_generic_detach(dev);
|
||||
device_delete_child(dev, sc->smb);
|
||||
ichsmb_release_resources(sc);
|
||||
|
||||
return 0;
|
||||
#else
|
||||
/*smbus drivers don't handle detach child properly*/
|
||||
return EBUSY;
|
||||
#endif
|
||||
}
|
||||
|
@ -80,12 +80,17 @@ __FBSDID("$FreeBSD$");
|
||||
/* Internal functions */
|
||||
static int ichsmb_pci_probe(device_t dev);
|
||||
static int ichsmb_pci_attach(device_t dev);
|
||||
/*Use generic one for now*/
|
||||
#if 0
|
||||
static int ichsmb_pci_detach(device_t dev);
|
||||
#endif
|
||||
|
||||
/* Device methods */
|
||||
static device_method_t ichsmb_pci_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, ichsmb_pci_probe),
|
||||
DEVMETHOD(device_attach, ichsmb_pci_attach),
|
||||
DEVMETHOD(device_detach, ichsmb_detach),
|
||||
|
||||
/* Bus methods */
|
||||
DEVMETHOD(bus_print_child, bus_generic_print_child),
|
||||
@ -224,6 +229,8 @@ ichsmb_pci_attach(device_t dev)
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
||||
MODULE_DEPEND(ichsmb, pci, 1, 1, 1);
|
||||
MODULE_DEPEND(ichsmb, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER);
|
||||
MODULE_VERSION(ichsmb, 1);
|
||||
;
|
||||
|
@ -48,6 +48,7 @@ struct ichsmb_softc {
|
||||
|
||||
/* Device/bus stuff */
|
||||
device_t dev; /* this device */
|
||||
device_t smb; /* smb device */
|
||||
struct resource *io_res; /* i/o port resource */
|
||||
int io_rid; /* i/o port bus id */
|
||||
bus_space_tag_t io_bst; /* bus space tag */
|
||||
@ -85,6 +86,7 @@ extern void ichsmb_device_intr(void *cookie);
|
||||
extern void ichsmb_release_resources(sc_p sc);
|
||||
extern int ichsmb_probe(device_t dev);
|
||||
extern int ichsmb_attach(device_t dev);
|
||||
extern int ichsmb_detach(device_t dev);
|
||||
|
||||
#endif /* _DEV_ICHSMB_ICHSMB_VAR_H */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user