Make simplebus friendlier for subclassing.

MFC after:	1 week
This commit is contained in:
Michal Meloun 2020-09-25 09:56:50 +00:00
parent 586bd2de78
commit b95a8021ec
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366146
2 changed files with 29 additions and 2 deletions

View File

@ -67,7 +67,7 @@ static device_method_t simplebus_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, simplebus_probe),
DEVMETHOD(device_attach, simplebus_attach),
DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_detach, simplebus_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@ -134,7 +134,7 @@ simplebus_probe(device_t dev)
}
int
simplebus_attach(device_t dev)
simplebus_attach_impl(device_t dev)
{
struct simplebus_softc *sc;
phandle_t node;
@ -154,9 +154,34 @@ simplebus_attach(device_t dev)
for (node = OF_child(sc->node); node > 0; node = OF_peer(node))
simplebus_add_device(dev, node, 0, NULL, -1, NULL);
return (0);
}
int
simplebus_attach(device_t dev)
{
int rv;
rv = simplebus_attach_impl(dev);
if (rv != 0)
return (rv);
return (bus_generic_attach(dev));
}
int
simplebus_detach(device_t dev)
{
struct simplebus_softc *sc;
sc = device_get_softc(dev);
if (sc->ranges != NULL)
free(sc->ranges, M_DEVBUF);
return (bus_generic_detach(dev));
}
void
simplebus_init(device_t dev, phandle_t node)
{

View File

@ -67,5 +67,7 @@ int simplebus_fill_ranges(phandle_t node,
struct simplebus_softc *sc);
int simplebus_attach(device_t dev);
int simplebus_attach_impl(device_t dev);
int simplebus_detach(device_t dev);
#endif /* _FDT_SIMPLEBUS_H */