Module Name: src Committed By: pgoyette Date: Thu Jan 25 23:37:34 UTC 2018
Modified Files: src/sys/arch/x86/pci: amdsmn.c amdzentemp.c Log Message: Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4) To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/amdsmn.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/pci/amdzentemp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/pci/amdsmn.c diff -u src/sys/arch/x86/pci/amdsmn.c:1.1 src/sys/arch/x86/pci/amdsmn.c:1.2 --- src/sys/arch/x86/pci/amdsmn.c:1.1 Thu Jan 25 01:22:21 2018 +++ src/sys/arch/x86/pci/amdsmn.c Thu Jan 25 23:37:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: amdsmn.c,v 1.1 2018/01/25 01:22:21 christos Exp $ */ +/* $NetBSD: amdsmn.c,v 1.2 2018/01/25 23:37:33 pgoyette Exp $ */ /*- * Copyright (c) 2017 Conrad Meyer <c...@freebsd.org> @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.1 2018/01/25 01:22:21 christos Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.2 2018/01/25 23:37:33 pgoyette Exp $ "); /* * Driver for the AMD Family 17h CPU System Management Network. @@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1 #include <sys/mutex.h> #include <sys/systm.h> #include <sys/cpu.h> +#include <sys/module.h> #include <machine/specialreg.h> @@ -49,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1 #include <dev/pci/pcidevs.h> #include "amdsmn.h" +#include "ioconf.h" #define SMN_ADDR_REG 0x60 #define SMN_DATA_REG 0x64 @@ -63,11 +65,12 @@ struct amdsmn_softc { static int amdsmn_match(device_t, cfdata_t, void *); static void amdsmn_attach(device_t, device_t, void *); +static int amdsmn_rescan(device_t, const char *, const int *); static int amdsmn_detach(device_t, int); static int amdsmn_misc_search(device_t, cfdata_t, const int *, void *); -CFATTACH_DECL_NEW(amdsmn, sizeof(struct amdsmn_softc), amdsmn_match, - amdsmn_attach, amdsmn_detach, NULL); +CFATTACH_DECL3_NEW(amdsmn, sizeof(struct amdsmn_softc), amdsmn_match, + amdsmn_attach, amdsmn_detach, NULL, amdsmn_rescan, NULL, 0); static int amdsmn_match(device_t parent, cfdata_t match, void *aux) @@ -91,13 +94,24 @@ amdsmn_attach(device_t parent, device_t { struct amdsmn_softc *sc = device_private(self); struct pci_attach_args *pa = aux; + int flags = 0; mutex_init(&sc->smn_lock, MUTEX_DEFAULT, IPL_NONE); sc->pa = *pa; sc->pc = pa->pa_pc; sc->pcitag = pa->pa_tag; aprint_normal(": AMD Family 17h System Management Network\n"); - config_search_loc(amdsmn_misc_search, self, "amdsmn", NULL, &sc->pa); + amdsmn_rescan(self, "amdsmn", &flags); +} + +static int +amdsmn_rescan(device_t self, const char *ifattr, const int *flags) +{ + struct amdsmn_softc *sc = device_private(self); + + config_search_loc(amdsmn_misc_search, self, ifattr, NULL, &sc->pa); + + return 0; } static int @@ -136,3 +150,34 @@ amdsmn_write(device_t dev, uint32_t addr return 0; } + +MODULE(MODULE_CLASS_DRIVER, amdsmn, "pci"); + +#ifdef _MODULE +#include "ioconf.c" +#endif + +static int +amdsmn_modcmd(modcmd_t cmd, void *opaque) +{ + int error = 0; + +#ifdef _MODULE + switch (cmd) { + case MODULE_CMD_INIT: + error = config_init_component(cfdriver_ioconf_amdsmn, + cfattach_ioconf_amdsmn, cfdata_ioconf_amdsmn); + break; + case MODULE_CMD_FINI: + error = config_fini_component(cfdriver_ioconf_amdsmn, + cfattach_ioconf_amdsmn, cfdata_ioconf_amdsmn); + break; + default: + error = ENOTTY; + break; + } +#endif + + return error; +} + Index: src/sys/arch/x86/pci/amdzentemp.c diff -u src/sys/arch/x86/pci/amdzentemp.c:1.5 src/sys/arch/x86/pci/amdzentemp.c:1.6 --- src/sys/arch/x86/pci/amdzentemp.c:1.5 Thu Jan 25 22:37:42 2018 +++ src/sys/arch/x86/pci/amdzentemp.c Thu Jan 25 23:37:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: amdzentemp.c,v 1.5 2018/01/25 22:37:42 pgoyette Exp $ */ +/* $NetBSD: amdzentemp.c,v 1.6 2018/01/25 23:37:33 pgoyette Exp $ */ /* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */ /* @@ -50,7 +50,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.5 2018/01/25 22:37:42 pgoyette Exp $ "); +__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.6 2018/01/25 23:37:33 pgoyette Exp $ "); #include <sys/param.h> #include <sys/bus.h> @@ -223,7 +223,7 @@ amdzentemp_family17_refresh(struct sysmo edata->value_cur = ((temp >> 21) * 125000) + 273150000; } -MODULE(MODULE_CLASS_DRIVER, amdzentemp, "sysmon_envsys"); +MODULE(MODULE_CLASS_DRIVER, amdzentemp, "sysmon_envsys,amdsmn"); #ifdef _MODULE #include "ioconf.c"