439 return (EFAULT);
440 if (intvl == 0)
441 return (EINVAL);
442
443 mutex_enter(&tsp->lock);
444 o_intvl = tsp->intvl;
445 mutex_exit(&tsp->lock);
446
447 if (ddi_copyout((const void *)&o_intvl, (void *)arg,
448 sizeof (o_intvl), flag))
449 return (EFAULT);
450
451 mutex_enter(&tsp->lock);
452 if (tsp->started == B_TRUE) {
453 mutex_exit(&tsp->lock);
454 return (EINVAL);
455 }
456 tsp->intvl = intvl;
457 tsp->tid = realtime_timeout(xcalwd_timeout,
458 (void *)(uintptr_t)instance,
459 drv_usectohz(1000000) * tsp->intvl);
460 tsp->started = B_TRUE;
461 mutex_exit(&tsp->lock);
462 return (0);
463 case XCALWD_KEEPALIVE:
464 tid = 0;
465 mutex_enter(&tsp->lock);
466 tid = tsp->tid;
467 tsp->tid = 0;
468 mutex_exit(&tsp->lock);
469 if (tid != 0)
470 (void) untimeout(tid); /* cancel */
471
472 mutex_enter(&tsp->lock);
473 if (tsp->started == B_TRUE) /* reinstate */
474 tsp->tid = realtime_timeout(xcalwd_timeout,
475 (void *)(uintptr_t)instance,
476 drv_usectohz(1000000) * tsp->intvl);
477 mutex_exit(&tsp->lock);
478 return (0);
479 case XCALWD_GETSTATE:
480 mutex_enter(&tsp->lock);
481 curstate = tsp->started;
482 mutex_exit(&tsp->lock);
483 if (ddi_copyout((const void *)&curstate, (void *)arg,
484 sizeof (curstate), flag))
485 return (EFAULT);
486 return (0);
487 default:
488 return (EINVAL);
489 }
490 /*NOTREACHED*/
491 }
|
439 return (EFAULT);
440 if (intvl == 0)
441 return (EINVAL);
442
443 mutex_enter(&tsp->lock);
444 o_intvl = tsp->intvl;
445 mutex_exit(&tsp->lock);
446
447 if (ddi_copyout((const void *)&o_intvl, (void *)arg,
448 sizeof (o_intvl), flag))
449 return (EFAULT);
450
451 mutex_enter(&tsp->lock);
452 if (tsp->started == B_TRUE) {
453 mutex_exit(&tsp->lock);
454 return (EINVAL);
455 }
456 tsp->intvl = intvl;
457 tsp->tid = realtime_timeout(xcalwd_timeout,
458 (void *)(uintptr_t)instance,
459 drv_sectohz(tsp->intvl));
460 tsp->started = B_TRUE;
461 mutex_exit(&tsp->lock);
462 return (0);
463 case XCALWD_KEEPALIVE:
464 tid = 0;
465 mutex_enter(&tsp->lock);
466 tid = tsp->tid;
467 tsp->tid = 0;
468 mutex_exit(&tsp->lock);
469 if (tid != 0)
470 (void) untimeout(tid); /* cancel */
471
472 mutex_enter(&tsp->lock);
473 if (tsp->started == B_TRUE) /* reinstate */
474 tsp->tid = realtime_timeout(xcalwd_timeout,
475 (void *)(uintptr_t)instance,
476 drv_sectohz(tsp->intvl));
477 mutex_exit(&tsp->lock);
478 return (0);
479 case XCALWD_GETSTATE:
480 mutex_enter(&tsp->lock);
481 curstate = tsp->started;
482 mutex_exit(&tsp->lock);
483 if (ddi_copyout((const void *)&curstate, (void *)arg,
484 sizeof (curstate), flag))
485 return (EFAULT);
486 return (0);
487 default:
488 return (EINVAL);
489 }
490 /*NOTREACHED*/
491 }
|