Minor cleanups... Move DRIVER_MODULE() and other boilerplate stuff to the

bottom of the file, where it is in most imx5/6 drivers.  Switch from an RD2
macro using bus_space_read_2() to an inline function using bus_read_2();
likewise for WR2.  Use RESOURCE_SPEC_END to end the resource_spec list.

Net effect should be no functional changes.
This commit is contained in:
Ian Lepore 2018-01-25 17:53:33 +00:00
parent 5823f6fb29
commit 76ecefce9d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328405

View File

@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$");
struct imx_wdog_softc {
struct mtx sc_mtx;
device_t sc_dev;
bus_space_tag_t sc_bst;
bus_space_handle_t sc_bsh;
struct resource *sc_res[2];
uint32_t sc_timeout;
};
@ -63,9 +61,12 @@ struct imx_wdog_softc {
static struct resource_spec imx_wdog_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ SYS_RES_IRQ, 0, RF_ACTIVE },
{ -1, 0 }
RESOURCE_SPEC_END
};
#define MEMRES 0
#define IRQRES 1
static struct ofw_compat_data compat_data[] = {
{"fsl,imx6sx-wdt", 1},
{"fsl,imx6sl-wdt", 1},
@ -80,28 +81,19 @@ static struct ofw_compat_data compat_data[] = {
{NULL, 0}
};
static void imx_watchdog(void *, u_int, int *);
static int imx_wdog_probe(device_t);
static int imx_wdog_attach(device_t);
static inline uint16_t
RD2(struct imx_wdog_softc *sc, bus_size_t offs)
{
static device_method_t imx_wdog_methods[] = {
DEVMETHOD(device_probe, imx_wdog_probe),
DEVMETHOD(device_attach, imx_wdog_attach),
DEVMETHOD_END
};
return bus_read_2(sc->sc_res[MEMRES], offs);
}
static driver_t imx_wdog_driver = {
"imx_wdog",
imx_wdog_methods,
sizeof(struct imx_wdog_softc),
};
static devclass_t imx_wdog_devclass;
DRIVER_MODULE(imx_wdog, simplebus, imx_wdog_driver, imx_wdog_devclass, 0, 0);
static inline void
WR2(struct imx_wdog_softc *sc, bus_size_t offs, uint16_t val)
{
#define RD2(_sc, _r) \
bus_space_read_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r))
#define WR2(_sc, _r, _v) \
bus_space_write_2((_sc)->sc_bst, (_sc)->sc_bsh, (_r), (_v))
return bus_write_2(sc->sc_res[MEMRES], offs, val);
}
static void
imx_watchdog(void *arg, u_int cmd, int *error)
@ -165,12 +157,24 @@ imx_wdog_attach(device_t dev)
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "imx_wdt", MTX_DEF);
sc->sc_dev = dev;
sc->sc_bst = rman_get_bustag(sc->sc_res[0]);
sc->sc_bsh = rman_get_bushandle(sc->sc_res[0]);
/* TODO: handle interrupt */
EVENTHANDLER_REGISTER(watchdog_list, imx_watchdog, sc, 0);
return (0);
}
static device_method_t imx_wdog_methods[] = {
DEVMETHOD(device_probe, imx_wdog_probe),
DEVMETHOD(device_attach, imx_wdog_attach),
DEVMETHOD_END
};
static driver_t imx_wdog_driver = {
"imx_wdog",
imx_wdog_methods,
sizeof(struct imx_wdog_softc),
};
static devclass_t imx_wdog_devclass;
DRIVER_MODULE(imx_wdog, simplebus, imx_wdog_driver, imx_wdog_devclass, 0, 0);