Date: Tue, 26 Feb 2019 22:34:29 +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: r344609 - in head/sys: dev/fdt modules/fdt modules/fdt/fdt_slicer Message-ID: <201902262234.x1QMYTo7013214@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Tue Feb 26 22:34:29 2019 New Revision: 344609 URL: https://svnweb.freebsd.org/changeset/base/344609 Log: Make it possible to load fdt_slicer as a module (unloading works too fwiw). Added: head/sys/modules/fdt/ head/sys/modules/fdt/Makefile (contents, props changed) head/sys/modules/fdt/fdt_slicer/ head/sys/modules/fdt/fdt_slicer/Makefile (contents, props changed) Modified: head/sys/dev/fdt/fdt_slicer.c Modified: head/sys/dev/fdt/fdt_slicer.c ============================================================================== --- head/sys/dev/fdt/fdt_slicer.c Tue Feb 26 22:07:59 2019 (r344608) +++ head/sys/dev/fdt/fdt_slicer.c Tue Feb 26 22:34:29 2019 (r344609) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/module.h> #include <sys/slicer.h> #include <dev/fdt/fdt_common.h> @@ -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); Added: head/sys/modules/fdt/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/fdt/Makefile Tue Feb 26 22:34:29 2019 (r344609) @@ -0,0 +1,7 @@ +# $FreeBSD$ +# Build dev/fdt modules. + +SUBDIR = \ + fdt_slicer \ + +.include <bsd.subdir.mk> Added: head/sys/modules/fdt/fdt_slicer/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/fdt/fdt_slicer/Makefile Tue Feb 26 22:34:29 2019 (r344609) @@ -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 <bsd.kmod.mk>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902262234.x1QMYTo7013214>