summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pci/viomb.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/dev/pci/viomb.c b/sys/dev/pci/viomb.c
index e0b477ae6f4..ac24f4ee2ef 100644
--- a/sys/dev/pci/viomb.c
+++ b/sys/dev/pci/viomb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: viomb.c,v 1.9 2014/07/09 22:45:26 jasper Exp $ */
+/* $OpenBSD: viomb.c,v 1.10 2014/07/11 08:48:38 jasper Exp $ */
/* $NetBSD: viomb.c,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
/*
@@ -33,6 +33,7 @@
#include <sys/device.h>
#include <sys/task.h>
#include <sys/pool.h>
+#include <sys/sensors.h>
#include <uvm/uvm_extern.h>
@@ -99,6 +100,8 @@ struct viomb_softc {
struct taskq *sc_taskq;
struct task sc_task;
struct pglist sc_balloon_pages;
+ struct ksensor sc_sens[2];
+ struct ksensordev sc_sensdev;
};
int viomb_match(struct device *, void *, void *);
@@ -204,6 +207,22 @@ viomb_attach(struct device *parent, struct device *self, void *aux)
goto err_dmamap;
task_set(&sc->sc_task, viomb_worker, sc, NULL);
+ strlcpy(sc->sc_sensdev.xname, DEVNAME(sc),
+ sizeof(sc->sc_sensdev.xname));
+ strlcpy(sc->sc_sens[0].desc, "desired",
+ sizeof(sc->sc_sens[0].desc));
+ sc->sc_sens[0].type = SENSOR_INTEGER;
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[0]);
+ sc->sc_sens[0].value = sc->sc_npages << PAGE_SHIFT;
+
+ strlcpy(sc->sc_sens[1].desc, "current",
+ sizeof(sc->sc_sens[1].desc));
+ sc->sc_sens[1].type = SENSOR_INTEGER;
+ sensor_attach(&sc->sc_sensdev, &sc->sc_sens[1]);
+ sc->sc_sens[1].value = sc->sc_actual << PAGE_SHIFT;
+
+ sensordev_install(&sc->sc_sensdev);
+
printf("\n");
return;
err_dmamap:
@@ -249,6 +268,10 @@ viomb_worker(void *arg1, void *arg2)
sc->sc_actual, sc->sc_npages);
viomb_deflate(sc);
}
+
+ sc->sc_sens[0].value = sc->sc_npages << PAGE_SHIFT;
+ sc->sc_sens[1].value = sc->sc_actual << PAGE_SHIFT;
+
splx(s);
}