PERFORCE change 126025 for review
Constantine A. Murenin
cnst at FreeBSD.org
Mon Sep 3 16:24:20 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=126025
Change 126025 by cnst at dale on 2007/09/03 23:23:34
remove noops and put the Giant lock instead.
The Giant lock is used by the sysctl logic with every sysctl call,
so its use in these attach/detach sensor device driver functions
is similar (if not better) in nature to the spl usage on OpenBSD.
thanks to rwarson and astrodog for some Giant chat on irc :)
(although we had a general discussion
not specifically related to this code,
so reasonable comments are welcome :)
Affected files ...
.. //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#9 edit
Differences ...
==== //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#9 (text+ko) ====
@@ -1,4 +1,4 @@
-/* $P4: //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#8 $ */
+/* $P4: //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#9 $ */
/* $FreeBSD$ */
/* $OpenBSD: kern_sensors.c,v 1.19 2007/06/04 18:42:05 deraadt Exp $ */
/* $OpenBSD: kern_sysctl.c,v 1.154 2007/06/01 17:29:10 beck Exp $ */
@@ -31,6 +31,8 @@
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/time.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/sensors.h>
@@ -60,9 +62,8 @@
sensordev_install(struct ksensordev *sensdev)
{
struct ksensordev *v, *nv;
- int s;
- s = splhigh();
+ mtx_lock(&Giant);
if (sensordev_count == 0) {
sensdev->num = 0;
SLIST_INSERT_HEAD(&sensordev_list, sensdev, list);
@@ -75,7 +76,7 @@
SLIST_INSERT_AFTER(v, sensdev, list);
}
sensordev_count++;
- splx(s);
+ mtx_unlock(&Giant);
}
void
@@ -83,9 +84,9 @@
{
struct ksensor *v, *nv;
struct ksensors_head *sh;
- int s, i;
+ int i;
- s = splhigh();
+ mtx_lock(&Giant);
sh = &sensdev->sensors_list;
if (sensdev->sensors_count == 0) {
for (i = 0; i < SENSOR_MAX_TYPES; i++)
@@ -111,27 +112,24 @@
if (sensdev->maxnumt[sens->type] == sens->numt)
sensdev->maxnumt[sens->type]++;
sensdev->sensors_count++;
- splx(s);
+ mtx_unlock(&Giant);
}
void
sensordev_deinstall(struct ksensordev *sensdev)
{
- int s;
-
- s = splhigh();
+ mtx_lock(&Giant);
sensordev_count--;
SLIST_REMOVE(&sensordev_list, sensdev, ksensordev, list);
- splx(s);
+ mtx_unlock(&Giant);
}
void
sensor_detach(struct ksensordev *sensdev, struct ksensor *sens)
{
struct ksensors_head *sh;
- int s;
- s = splhigh();
+ mtx_lock(&Giant);
sh = &sensdev->sensors_list;
sensdev->sensors_count--;
SLIST_REMOVE(sh, sens, ksensor, list);
@@ -140,7 +138,7 @@
*/
if (sens->numt == sensdev->maxnumt[sens->type] - 1)
sensdev->maxnumt[sens->type]--;
- splx(s);
+ mtx_unlock(&Giant);
}
struct ksensordev *
More information about the p4-projects
mailing list