diff --git a/sys/dev/fdt/fdt_slicer.c b/sys/dev/fdt/fdt_slicer.c index 312300e64d3b..122567c38602 100644 --- a/sys/dev/fdt/fdt_slicer.c +++ b/sys/dev/fdt/fdt_slicer.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -131,10 +132,37 @@ fdt_slicer_init(void) FALSE); } +static void +fdt_slicer_cleanup(void) +{ + + flash_register_slicer(NULL, FLASH_SLICES_TYPE_NAND, true); + flash_register_slicer(NULL, FLASH_SLICES_TYPE_CFI, true); + flash_register_slicer(NULL, FLASH_SLICES_TYPE_SPI, true); +} + /* * Must be initialized after GEOM classes (SI_SUB_DRIVERS/SI_ORDER_FIRST), * i. e. after g_init() is called, due to the use of the GEOM topology_lock * in flash_register_slicer(). However, must be before SI_SUB_CONFIGURE. */ -SYSINIT(fdt_slicer_rootconf, SI_SUB_DRIVERS, SI_ORDER_SECOND, fdt_slicer_init, - NULL); +SYSINIT(fdt_slicer, SI_SUB_DRIVERS, SI_ORDER_SECOND, fdt_slicer_init, NULL); +SYSUNINIT(fdt_slicer, SI_SUB_DRIVERS, SI_ORDER_SECOND, fdt_slicer_cleanup, NULL); + +static int +mod_handler(module_t mod, int type, void *data) +{ + + /* + * Nothing to do here: the SYSINIT/SYSUNINIT defined above run + * automatically at module load/unload time. + */ + return (0); +} + +static moduledata_t fdt_slicer_mod = { + "fdt_slicer", mod_handler, NULL +}; + +DECLARE_MODULE(fdt_slicer, fdt_slicer_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); +MODULE_VERSION(fdt_slicer, 1); diff --git a/sys/modules/fdt/Makefile b/sys/modules/fdt/Makefile new file mode 100644 index 000000000000..8bfb0f47fcbc --- /dev/null +++ b/sys/modules/fdt/Makefile @@ -0,0 +1,7 @@ +# $FreeBSD$ +# Build dev/fdt modules. + +SUBDIR = \ + fdt_slicer \ + +.include diff --git a/sys/modules/fdt/fdt_slicer/Makefile b/sys/modules/fdt/fdt_slicer/Makefile new file mode 100644 index 000000000000..ba58ea1e8f19 --- /dev/null +++ b/sys/modules/fdt/fdt_slicer/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/dev/fdt + +KMOD= fdt_slicer +SRCS= fdt_slicer.c + +# Generated files... +SRCS+= \ + ofw_bus_if.h \ + opt_platform.h \ + +.include