Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/pci Modularize the amdsmn(4) driver, and update...



details:   https://anonhg.NetBSD.org/src/rev/6cd85252bf9b
branches:  trunk
changeset: 829327:6cd85252bf9b
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Jan 25 23:37:33 2018 +0000

description:
Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4)

diffstat:

 sys/arch/x86/pci/amdsmn.c     |  55 +++++++++++++++++++++++++++++++++++++++---
 sys/arch/x86/pci/amdzentemp.c |   6 ++--
 2 files changed, 53 insertions(+), 8 deletions(-)

diffs (137 lines):

diff -r 7f10bcc55003 -r 6cd85252bf9b sys/arch/x86/pci/amdsmn.c
--- a/sys/arch/x86/pci/amdsmn.c Thu Jan 25 22:49:32 2018 +0000
+++ b/sys/arch/x86/pci/amdsmn.c Thu Jan 25 23:37:33 2018 +0000
@@ -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 <cem%FreeBSD.org@localhost>
@@ -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 @@
 #include <sys/mutex.h>
 #include <sys/systm.h>
 #include <sys/cpu.h>
+#include <sys/module.h>
 
 #include <machine/specialreg.h>
 
@@ -49,6 +50,7 @@
 #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 @@
 
 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 @@
 {
        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 @@
 
        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;
+}
+
diff -r 7f10bcc55003 -r 6cd85252bf9b sys/arch/x86/pci/amdzentemp.c
--- a/sys/arch/x86/pci/amdzentemp.c     Thu Jan 25 22:49:32 2018 +0000
+++ b/sys/arch/x86/pci/amdzentemp.c     Thu Jan 25 23:37:33 2018 +0000
@@ -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 @@
        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"



Home | Main Index | Thread Index | Old Index