Lines Matching refs:unitp
170 struct max1617_unit *unitp; in max1617_do_attach() local
184 unitp = ddi_get_soft_state(max1617_soft_statep, instance); in max1617_do_attach()
186 (void) snprintf(unitp->max1617_name, sizeof (unitp->max1617_name), in max1617_do_attach()
196 " name '%s'", unitp->max1617_name, minor_name); in max1617_do_attach()
209 unitp->max1617_name, minor_name); in max1617_do_attach()
216 if (i2c_client_register(dip, &unitp->max1617_hdl) != I2C_SUCCESS) { in max1617_do_attach()
223 mutex_init(&unitp->max1617_mutex, NULL, MUTEX_DRIVER, NULL); in max1617_do_attach()
224 cv_init(&unitp->max1617_cv, NULL, CV_DRIVER, NULL); in max1617_do_attach()
235 struct max1617_unit *unitp; in max1617_do_resume() local
237 if ((unitp = ddi_get_soft_state(max1617_soft_statep, instance)) == in max1617_do_resume()
242 (void) i2c_transfer_alloc(unitp->max1617_hdl, in max1617_do_resume()
249 i2ctp->i2c_wbuf[1] = unitp->max1617_cpr_state.max1617_config; in max1617_do_resume()
251 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_resume()
257 i2ctp->i2c_wbuf[1] = unitp->max1617_cpr_state.max1617_conv_rate; in max1617_do_resume()
258 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_resume()
264 i2ctp->i2c_wbuf[1] = unitp->max1617_cpr_state.max1617_lcl_hlimit; in max1617_do_resume()
266 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_resume()
272 i2ctp->i2c_wbuf[1] = unitp->max1617_cpr_state.max1617_remote_hlimit; in max1617_do_resume()
274 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_resume()
280 i2ctp->i2c_wbuf[1] = unitp->max1617_cpr_state.max1617_lcl_llimit; in max1617_do_resume()
282 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_resume()
288 i2ctp->i2c_wbuf[1] = unitp->max1617_cpr_state.max1617_remote_llimit; in max1617_do_resume()
290 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_resume()
296 mutex_enter(&unitp->max1617_mutex); in max1617_do_resume()
297 unitp->max1617_flags = 0; in max1617_do_resume()
298 cv_signal(&unitp->max1617_cv); in max1617_do_resume()
299 mutex_exit(&unitp->max1617_mutex); in max1617_do_resume()
301 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_do_resume()
324 struct max1617_unit *unitp; in max1617_do_detach() local
329 unitp = ddi_get_soft_state(max1617_soft_statep, instance); in max1617_do_detach()
331 if (unitp == NULL) { in max1617_do_detach()
335 i2c_client_unregister(unitp->max1617_hdl); in max1617_do_detach()
339 mutex_destroy(&unitp->max1617_mutex); in max1617_do_detach()
340 cv_destroy(&unitp->max1617_cv); in max1617_do_detach()
352 struct max1617_unit *unitp; in max1617_do_suspend() local
354 if ((unitp = ddi_get_soft_state(max1617_soft_statep, instance)) == in max1617_do_suspend()
359 (void) i2c_transfer_alloc(unitp->max1617_hdl, in max1617_do_suspend()
366 mutex_enter(&unitp->max1617_mutex); in max1617_do_suspend()
367 while (unitp->max1617_flags == MAX1617_BUSY) { in max1617_do_suspend()
368 cv_wait(&unitp->max1617_cv, &unitp->max1617_mutex); in max1617_do_suspend()
370 unitp->max1617_flags = MAX1617_BUSY; in max1617_do_suspend()
371 mutex_exit(&unitp->max1617_mutex); in max1617_do_suspend()
376 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_suspend()
380 unitp->max1617_cpr_state.max1617_config = i2ctp->i2c_rbuf[0]; in max1617_do_suspend()
383 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_suspend()
387 unitp->max1617_cpr_state.max1617_conv_rate = i2ctp->i2c_rbuf[0]; in max1617_do_suspend()
390 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_suspend()
394 unitp->max1617_cpr_state.max1617_lcl_hlimit = i2ctp->i2c_rbuf[0]; in max1617_do_suspend()
397 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_suspend()
401 unitp->max1617_cpr_state.max1617_remote_hlimit = i2ctp->i2c_rbuf[0]; in max1617_do_suspend()
404 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_suspend()
408 unitp->max1617_cpr_state.max1617_lcl_llimit = i2ctp->i2c_rbuf[0]; in max1617_do_suspend()
411 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_do_suspend()
415 unitp->max1617_cpr_state.max1617_remote_llimit = i2ctp->i2c_rbuf[0]; in max1617_do_suspend()
418 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_do_suspend()
421 mutex_enter(&unitp->max1617_mutex); in max1617_do_suspend()
422 unitp->max1617_flags = 0; in max1617_do_suspend()
423 cv_broadcast(&unitp->max1617_cv); in max1617_do_suspend()
424 mutex_exit(&unitp->max1617_mutex); in max1617_do_suspend()
451 struct max1617_unit *unitp; in max1617_open() local
462 unitp = (struct max1617_unit *) in max1617_open()
465 if (unitp == NULL) { in max1617_open()
475 mutex_enter(&unitp->max1617_mutex); in max1617_open()
478 if (unitp->max1617_oflag != 0) { in max1617_open()
481 unitp->max1617_oflag = FEXCL; in max1617_open()
484 if (unitp->max1617_oflag == FEXCL) { in max1617_open()
487 unitp->max1617_oflag = (uint16_t)FOPEN; in max1617_open()
492 mutex_exit(&unitp->max1617_mutex); in max1617_open()
502 struct max1617_unit *unitp; in max1617_close() local
510 unitp = (struct max1617_unit *) in max1617_close()
513 if (unitp == NULL) { in max1617_close()
518 mutex_enter(&unitp->max1617_mutex); in max1617_close()
520 unitp->max1617_oflag = 0; in max1617_close()
522 mutex_exit(&unitp->max1617_mutex); in max1617_close()
528 set_temp_limit(struct max1617_unit *unitp, uchar_t device_reg, caddr_t arg, in set_temp_limit() argument
535 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, 2, 0, I2C_SLEEP); in set_temp_limit()
542 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in set_temp_limit()
549 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in set_temp_limit()
553 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in set_temp_limit()
559 get_temp_limit(struct max1617_unit *unitp, uchar_t reg, caddr_t arg, int mode) in get_temp_limit() argument
565 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, 1, 1, I2C_SLEEP); in get_temp_limit()
569 if (i2c_transfer(unitp->max1617_hdl, i2ctp) == I2C_SUCCESS) { in get_temp_limit()
582 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in get_temp_limit()
592 struct max1617_unit *unitp; in max1617_ioctl() local
599 unitp = (struct max1617_unit *) in max1617_ioctl()
611 mutex_enter(&unitp->max1617_mutex); in max1617_ioctl()
612 while (unitp->max1617_flags == MAX1617_BUSY) { in max1617_ioctl()
613 if (cv_wait_sig(&unitp->max1617_cv, in max1617_ioctl()
614 &unitp->max1617_mutex) <= 0) { in max1617_ioctl()
615 mutex_exit(&unitp->max1617_mutex); in max1617_ioctl()
619 unitp->max1617_flags = MAX1617_BUSY; in max1617_ioctl()
620 mutex_exit(&unitp->max1617_mutex); in max1617_ioctl()
642 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, in max1617_ioctl()
648 if (i2c_transfer(unitp->max1617_hdl, i2ctp) == I2C_SUCCESS) { in max1617_ioctl()
663 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_ioctl()
667 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, in max1617_ioctl()
673 if (i2c_transfer(unitp->max1617_hdl, i2ctp) == I2C_SUCCESS) { in max1617_ioctl()
681 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_ioctl()
684 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, 1, 1, in max1617_ioctl()
689 if (i2c_transfer(unitp->max1617_hdl, i2ctp) == I2C_SUCCESS) { in max1617_ioctl()
697 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_ioctl()
700 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, in max1617_ioctl()
705 if (i2c_transfer(unitp->max1617_hdl, i2ctp) == I2C_SUCCESS) { in max1617_ioctl()
713 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_ioctl()
719 err = get_temp_limit(unitp, MAX1617_LOCALTEMP_HIGH_REG, in max1617_ioctl()
723 err = get_temp_limit(unitp, MAX1617_REMOTETEMP_HIGH_REG, in max1617_ioctl()
736 err = get_temp_limit(unitp, MAX1617_LOCALTEMP_LOW_REG, in max1617_ioctl()
740 err = get_temp_limit(unitp, MAX1617_REMOTETEMP_LOW_REG, in max1617_ioctl()
749 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, in max1617_ioctl()
759 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_ioctl()
762 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_ioctl()
766 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, in max1617_ioctl()
776 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_ioctl()
780 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_ioctl()
786 err = set_temp_limit(unitp, in max1617_ioctl()
790 err = set_temp_limit(unitp, in max1617_ioctl()
801 err = set_temp_limit(unitp, in max1617_ioctl()
805 err = set_temp_limit(unitp, in max1617_ioctl()
814 (void) i2c_transfer_alloc(unitp->max1617_hdl, &i2ctp, 1, 0, in max1617_ioctl()
819 if (i2c_transfer(unitp->max1617_hdl, i2ctp) != I2C_SUCCESS) { in max1617_ioctl()
823 i2c_transfer_free(unitp->max1617_hdl, i2ctp); in max1617_ioctl()
832 mutex_enter(&unitp->max1617_mutex); in max1617_ioctl()
833 unitp->max1617_flags = 0; in max1617_ioctl()
834 cv_signal(&unitp->max1617_cv); in max1617_ioctl()
835 mutex_exit(&unitp->max1617_mutex); in max1617_ioctl()