sensors: Accept -1 as sensor thread cpuid
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 4 Jun 2015 12:31:02 +0000 (20:31 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 4 Jun 2015 12:31:02 +0000 (20:31 +0800)
The task will be register to the default sensor thread.

sys/kern/kern_sensors.c

index cff1303..24b267a 100644 (file)
@@ -236,7 +236,7 @@ sensor_find(struct ksensordev *sensdev, enum sensor_type type, int numt)
 void
 sensor_task_register(void *arg, void (*func)(void *), int period)
 {
-       sensor_task_register2(arg, func, period, SENSOR_TASK_DEFCPU);
+       sensor_task_register2(arg, func, period, -1);
 }
 
 void
@@ -276,6 +276,8 @@ sensor_task_register2(void *arg, void (*func)(void *), int period, int cpu)
        struct sensor_taskthr   *thr;
        struct sensor_task      *st;
 
+       if (cpu < 0)
+               cpu = SENSOR_TASK_DEFCPU;
        KASSERT(cpu >= 0 && cpu < ncpus, ("invalid cpuid %d", cpu));
        thr = &sensor_task_threads[cpu];