Date: Thu, 25 Jan 2018 17:53:33 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328405 - head/sys/arm/freescale/imx Message-ID: <201801251753.w0PHrXBq087955@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Thu Jan 25 17:53:33 2018 New Revision: 328405 URL: https://svnweb.freebsd.org/changeset/base/328405 Log: 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. Modified: head/sys/arm/freescale/imx/imx_wdog.c Modified: head/sys/arm/freescale/imx/imx_wdog.c ============================================================================== --- head/sys/arm/freescale/imx/imx_wdog.c Thu Jan 25 17:16:29 2018 (r328404) +++ head/sys/arm/freescale/imx/imx_wdog.c Thu Jan 25 17:53:33 2018 (r328405) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801251753.w0PHrXBq087955>