Lines Matching refs:np

86 	struct msts *np;  in mstsopen()  local
94 np = malloc(sizeof(struct msts), M_DEVBUF, M_WAITOK|M_ZERO); in mstsopen()
95 snprintf(np->timedev.xname, sizeof(np->timedev.xname), "msts%d", in mstsopen()
98 np->time.status = SENSOR_S_UNKNOWN; in mstsopen()
99 np->time.type = SENSOR_TIMEDELTA; in mstsopen()
101 np->time.flags = SENSOR_FINVALID; in mstsopen()
103 sensor_attach(&np->timedev, &np->time); in mstsopen()
105 np->signal.type = SENSOR_PERCENT; in mstsopen()
106 np->signal.status = SENSOR_S_UNKNOWN; in mstsopen()
107 np->signal.value = 100000LL; in mstsopen()
108 strlcpy(np->signal.desc, "Signal", sizeof(np->signal.desc)); in mstsopen()
109 sensor_attach(&np->timedev, &np->signal); in mstsopen()
111 np->sync = 1; in mstsopen()
112 tp->t_sc = (caddr_t)np; in mstsopen()
116 free(np, M_DEVBUF, sizeof(*np)); in mstsopen()
119 sensordev_install(&np->timedev); in mstsopen()
120 timeout_set(&np->msts_tout, msts_timeout, np); in mstsopen()
129 struct msts *np = (struct msts *)tp->t_sc; in mstsclose() local
132 timeout_del(&np->msts_tout); in mstsclose()
133 sensordev_deinstall(&np->timedev); in mstsclose()
134 free(np, M_DEVBUF, sizeof(*np)); in mstsclose()
146 struct msts *np = (struct msts *)tp->t_sc; in mstsinput() local
154 np->pos = np->sync = 0; in mstsinput()
156 (np->lts.tv_sec * 1000000000LL + np->lts.tv_nsec); in mstsinput()
158 np->lts.tv_sec = ts.tv_sec; in mstsinput()
159 np->lts.tv_nsec = ts.tv_nsec; in mstsinput()
161 if (gap <= np->gap) in mstsinput()
164 np->ts.tv_sec = ts.tv_sec; in mstsinput()
165 np->ts.tv_nsec = ts.tv_nsec; in mstsinput()
166 np->gap = gap; in mstsinput()
178 tmax = lmax(np->ts.tv_sec, tp->t_tv.tv_sec); in mstsinput()
179 tmin = lmin(np->ts.tv_sec, tp->t_tv.tv_sec); in mstsinput()
181 np->no_pps = 1; in mstsinput()
183 np->ts.tv_sec = tp->t_tv.tv_sec; in mstsinput()
184 np->ts.tv_nsec = tp->t_tv.tv_usec * in mstsinput()
186 np->no_pps = 0; in mstsinput()
191 if (!np->sync) { in mstsinput()
192 np->cbuf[np->pos] = '\0'; in mstsinput()
193 msts_scan(np, tp); in mstsinput()
194 np->sync = 1; in mstsinput()
198 if (!np->sync && np->pos < (MSTSMAX - 1)) in mstsinput()
199 np->cbuf[np->pos++] = c; in mstsinput()
208 msts_scan(struct msts *np, struct tty *tp) in msts_scan() argument
214 fld[fldcnt++] = &np->cbuf[0]; in msts_scan()
215 for (cs = NULL, n = 0; n < np->pos && cs == NULL; n++) { in msts_scan()
216 switch (np->cbuf[n]) { in msts_scan()
218 np->cbuf[n] = '\0'; in msts_scan()
219 cs = &np->cbuf[n + 1]; in msts_scan()
223 np->cbuf[n] = '\0'; in msts_scan()
224 fld[fldcnt++] = &np->cbuf[n + 1]; in msts_scan()
233 msts_decode(np, tp, fld, fldcnt); in msts_scan()
238 msts_decode(struct msts *np, struct tty *tp, char *fld[], int fldcnt) in msts_decode() argument
260 if (msts_now <= np->last) { in msts_decode()
264 np->last = msts_now; in msts_decode()
265 np->gap = 0LL; in msts_decode()
267 if (np->time.status == SENSOR_S_UNKNOWN) { in msts_decode()
268 np->time.status = SENSOR_S_OK; in msts_decode()
269 timeout_add_sec(&np->msts_tout, TRUSTTIME); in msts_decode()
273 np->time.value = np->ts.tv_sec * 1000000000LL + in msts_decode()
274 np->ts.tv_nsec - msts_now; in msts_decode()
275 np->time.tv.tv_sec = np->ts.tv_sec; in msts_decode()
276 np->time.tv.tv_usec = np->ts.tv_nsec / 1000L; in msts_decode()
277 if (np->time.status == SENSOR_S_UNKNOWN) { in msts_decode()
278 np->time.status = SENSOR_S_OK; in msts_decode()
279 np->time.flags &= ~SENSOR_FINVALID; in msts_decode()
280 strlcpy(np->time.desc, "MSTS", sizeof(np->time.desc)); in msts_decode()
290 np->time.status = SENSOR_S_OK; in msts_decode()
291 np->signal.status = SENSOR_S_OK; in msts_decode()
293 np->signal.status = SENSOR_S_WARN; in msts_decode()
296 np->time.status = SENSOR_S_WARN; in msts_decode()
297 if (np->time.status == SENSOR_S_OK) in msts_decode()
298 timeout_add_sec(&np->msts_tout, TRUSTTIME); in msts_decode()
304 if (np->no_pps) in msts_decode()
305 np->time.status = SENSOR_S_CRIT; in msts_decode()
411 struct msts *np = xnp; in msts_timeout() local
413 if (np->time.status == SENSOR_S_OK) { in msts_timeout()
414 np->time.status = SENSOR_S_WARN; in msts_timeout()
419 timeout_add_sec(&np->msts_tout, TRUSTTIME); in msts_timeout()
421 np->time.status = SENSOR_S_CRIT; in msts_timeout()