Date: Tue, 7 Aug 2007 02:41:32 GMT From: "Constantine A. Murenin" <cnst@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124794 for review Message-ID: <200708070241.l772fWVC093479@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124794 Change 124794 by cnst@dale on 2007/08/07 02:40:31 change sensor_find(9) to make the framework slightly more efficient and better prepared for some future locking. This also saves a few bytes in kern_sensors.o. Affected files ... .. //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#8 edit Differences ... ==== //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#8 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $P4: //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#7 $ */ +/* $P4: //depot/projects/soc2007/cnst-sensors/sys.kern/kern_sensors.c#8 $ */ /* $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 $ */ @@ -39,7 +39,7 @@ SLIST_HEAD(, ksensordev) sensordev_list = SLIST_HEAD_INITIALIZER(sensordev_list); struct ksensordev *sensordev_get(int); -struct ksensor *sensor_find(int, enum sensor_type, int); +struct ksensor *sensor_find(struct ksensordev *, enum sensor_type, int); struct sensor_task { void *arg; @@ -156,16 +156,11 @@ } struct ksensor * -sensor_find(int dev, enum sensor_type type, int numt) +sensor_find(struct ksensordev *sensdev, enum sensor_type type, int numt) { struct ksensor *s; - struct ksensordev *sensdev; struct ksensors_head *sh; - sensdev = sensordev_get(dev); - if (sensdev == NULL) - return (NULL); - sh = &sensdev->sensors_list; SLIST_FOREACH(s, sh, list) if (s->type == type && s->numt == numt) @@ -315,11 +310,12 @@ return (ENOTDIR); dev = name[0]; + + ksd = sensordev_get(dev); + if (ksd == NULL) + return (ENOENT); + if (namelen == 1) { - ksd = sensordev_get(dev); - if (ksd == NULL) - return (ENOENT); - /* Grab a copy, to clear the kernel pointers */ usd = malloc(sizeof(*usd), M_TEMP, M_WAITOK); bzero(usd, sizeof(*usd)); @@ -338,7 +334,7 @@ type = name[1]; numt = name[2]; - ks = sensor_find(dev, type, numt); + ks = sensor_find(ksd, type, numt); if (ks == NULL) return (ENOENT);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708070241.l772fWVC093479>