Lines Matching refs:ca
162 static void dvb_ca_private_free(struct dvb_ca_private *ca) in dvb_ca_private_free() argument
166 dvb_device_put(ca->dvbdev); in dvb_ca_private_free()
167 for (i = 0; i < ca->slot_count; i++) in dvb_ca_private_free()
168 vfree(ca->slot_info[i].rx_buffer.data); in dvb_ca_private_free()
170 kfree(ca->slot_info); in dvb_ca_private_free()
171 kfree(ca); in dvb_ca_private_free()
176 struct dvb_ca_private *ca; in dvb_ca_private_release() local
178 ca = container_of(ref, struct dvb_ca_private, refcount); in dvb_ca_private_release()
179 dvb_ca_private_free(ca); in dvb_ca_private_release()
182 static void dvb_ca_private_get(struct dvb_ca_private *ca) in dvb_ca_private_get() argument
184 kref_get(&ca->refcount); in dvb_ca_private_get()
187 static void dvb_ca_private_put(struct dvb_ca_private *ca) in dvb_ca_private_put() argument
189 kref_put(&ca->refcount, dvb_ca_private_release); in dvb_ca_private_put()
192 static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca);
193 static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
195 static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
228 static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot) in dvb_ca_en50221_check_camstatus() argument
230 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_check_camstatus()
236 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) in dvb_ca_en50221_check_camstatus()
240 slot_status = ca->pub->poll_slot_status(ca->pub, slot, ca->open); in dvb_ca_en50221_check_camstatus()
278 static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot, in dvb_ca_en50221_wait_if_status() argument
293 res = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS); in dvb_ca_en50221_wait_if_status()
326 static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot) in dvb_ca_en50221_link_init() argument
328 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_link_init()
345 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, in dvb_ca_en50221_link_init()
349 ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ); in dvb_ca_en50221_link_init()
352 ret = dvb_ca_en50221_read_data(ca, slot, buf, 2); in dvb_ca_en50221_link_init()
355 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN); in dvb_ca_en50221_link_init()
372 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, in dvb_ca_en50221_link_init()
376 ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10); in dvb_ca_en50221_link_init()
379 ret = dvb_ca_en50221_write_data(ca, slot, buf, 2, CMDREG_SW); in dvb_ca_en50221_link_init()
382 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN); in dvb_ca_en50221_link_init()
402 static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot, in dvb_ca_en50221_read_tuple() argument
412 _tuple_type = ca->pub->read_attribute_mem(ca->pub, slot, _address); in dvb_ca_en50221_read_tuple()
422 _tuple_length = ca->pub->read_attribute_mem(ca->pub, slot, in dvb_ca_en50221_read_tuple()
432 tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot, in dvb_ca_en50221_read_tuple()
456 static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot) in dvb_ca_en50221_parse_attributes() argument
473 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type, in dvb_ca_en50221_parse_attributes()
481 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type, in dvb_ca_en50221_parse_attributes()
489 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type, in dvb_ca_en50221_parse_attributes()
497 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type, in dvb_ca_en50221_parse_attributes()
509 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type, in dvb_ca_en50221_parse_attributes()
522 sl = &ca->slot_info[slot]; in dvb_ca_en50221_parse_attributes()
537 ca->dvbdev->adapter->num, dvb_str[8], dvb_str[9], in dvb_ca_en50221_parse_attributes()
544 status = dvb_ca_en50221_read_tuple(ca, slot, &address, in dvb_ca_en50221_parse_attributes()
601 static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot) in dvb_ca_en50221_set_configoption() argument
603 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_set_configoption()
609 ca->pub->write_attribute_mem(ca->pub, slot, sl->config_base, in dvb_ca_en50221_set_configoption()
613 configoption = ca->pub->read_attribute_mem(ca->pub, slot, in dvb_ca_en50221_set_configoption()
637 static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, in dvb_ca_en50221_read_data() argument
640 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_read_data()
665 if (ca->pub->read_data && in dvb_ca_en50221_read_data()
668 status = ca->pub->read_data(ca->pub, slot, buf, in dvb_ca_en50221_read_data()
671 status = ca->pub->read_data(ca->pub, slot, buf, ecount); in dvb_ca_en50221_read_data()
679 status = ca->pub->read_cam_control(ca->pub, slot, in dvb_ca_en50221_read_data()
690 status = ca->pub->read_cam_control(ca->pub, slot, in dvb_ca_en50221_read_data()
695 status = ca->pub->read_cam_control(ca->pub, slot, in dvb_ca_en50221_read_data()
705 ca->dvbdev->adapter->num, bytes_read, in dvb_ca_en50221_read_data()
713 ca->dvbdev->adapter->num); in dvb_ca_en50221_read_data()
721 ca->dvbdev->adapter->num); in dvb_ca_en50221_read_data()
730 status = ca->pub->read_cam_control(ca->pub, slot, in dvb_ca_en50221_read_data()
740 status = ca->pub->read_cam_control(ca->pub, slot, in dvb_ca_en50221_read_data()
770 wake_up_interruptible(&ca->wait_queue); in dvb_ca_en50221_read_data()
792 static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, in dvb_ca_en50221_write_data() argument
795 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_write_data()
805 if (ca->pub->write_data && in dvb_ca_en50221_write_data()
807 return ca->pub->write_data(ca->pub, slot, buf, bytes_write); in dvb_ca_en50221_write_data()
815 status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS); in dvb_ca_en50221_write_data()
820 dvb_ca_en50221_thread_wakeup(ca); in dvb_ca_en50221_write_data()
827 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, in dvb_ca_en50221_write_data()
833 status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS); in dvb_ca_en50221_write_data()
853 status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS); in dvb_ca_en50221_write_data()
859 dvb_ca_en50221_thread_wakeup(ca); in dvb_ca_en50221_write_data()
866 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, in dvb_ca_en50221_write_data()
870 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW, in dvb_ca_en50221_write_data()
877 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA, in dvb_ca_en50221_write_data()
884 status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS); in dvb_ca_en50221_write_data()
898 ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN); in dvb_ca_en50221_write_data()
913 static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot) in dvb_ca_en50221_slot_shutdown() argument
917 ca->pub->slot_shutdown(ca->pub, slot); in dvb_ca_en50221_slot_shutdown()
918 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; in dvb_ca_en50221_slot_shutdown()
924 wake_up_interruptible(&ca->wait_queue); in dvb_ca_en50221_slot_shutdown()
942 struct dvb_ca_private *ca = pubca->private; in dvb_ca_en50221_camchange_irq() local
943 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_camchange_irq()
958 dvb_ca_en50221_thread_wakeup(ca); in dvb_ca_en50221_camchange_irq()
970 struct dvb_ca_private *ca = pubca->private; in dvb_ca_en50221_camready_irq() local
971 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_camready_irq()
977 dvb_ca_en50221_thread_wakeup(ca); in dvb_ca_en50221_camready_irq()
990 struct dvb_ca_private *ca = pubca->private; in dvb_ca_en50221_frda_irq() local
991 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_frda_irq()
998 flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS); in dvb_ca_en50221_frda_irq()
1006 if (ca->open) in dvb_ca_en50221_frda_irq()
1007 dvb_ca_en50221_thread_wakeup(ca); in dvb_ca_en50221_frda_irq()
1021 static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca) in dvb_ca_en50221_thread_wakeup() argument
1025 ca->wakeup = 1; in dvb_ca_en50221_thread_wakeup()
1027 wake_up_process(ca->thread); in dvb_ca_en50221_thread_wakeup()
1035 static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca) in dvb_ca_en50221_thread_update_delay() argument
1045 for (slot = 0; slot < ca->slot_count; slot++) { in dvb_ca_en50221_thread_update_delay()
1046 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_thread_update_delay()
1052 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) in dvb_ca_en50221_thread_update_delay()
1057 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) in dvb_ca_en50221_thread_update_delay()
1071 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) in dvb_ca_en50221_thread_update_delay()
1073 if (ca->open) { in dvb_ca_en50221_thread_update_delay()
1075 (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) in dvb_ca_en50221_thread_update_delay()
1085 ca->delay = curdelay; in dvb_ca_en50221_thread_update_delay()
1097 static int dvb_ca_en50221_poll_cam_gone(struct dvb_ca_private *ca, int slot) in dvb_ca_en50221_poll_cam_gone() argument
1106 if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && in dvb_ca_en50221_poll_cam_gone()
1107 (ca->pub->poll_slot_status)) { in dvb_ca_en50221_poll_cam_gone()
1108 status = ca->pub->poll_slot_status(ca->pub, slot, 0); in dvb_ca_en50221_poll_cam_gone()
1111 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; in dvb_ca_en50221_poll_cam_gone()
1112 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_poll_cam_gone()
1126 static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca, in dvb_ca_en50221_thread_state_machine() argument
1129 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_thread_state_machine()
1137 while (dvb_ca_en50221_check_camstatus(ca, slot)) { in dvb_ca_en50221_thread_state_machine()
1140 dvb_ca_en50221_slot_shutdown(ca, slot); in dvb_ca_en50221_thread_state_machine()
1147 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1160 ca->pub->slot_reset(ca->pub, slot); in dvb_ca_en50221_thread_state_machine()
1167 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1169 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1179 if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) { in dvb_ca_en50221_thread_state_machine()
1180 if (dvb_ca_en50221_poll_cam_gone(ca, slot)) in dvb_ca_en50221_thread_state_machine()
1184 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1186 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1189 if (dvb_ca_en50221_set_configoption(ca, slot) != 0) { in dvb_ca_en50221_thread_state_machine()
1191 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1193 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1196 if (ca->pub->write_cam_control(ca->pub, slot, in dvb_ca_en50221_thread_state_machine()
1200 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1202 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1209 ca->wakeup = 1; in dvb_ca_en50221_thread_state_machine()
1215 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1217 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1221 flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS); in dvb_ca_en50221_thread_state_machine()
1224 ca->wakeup = 1; in dvb_ca_en50221_thread_state_machine()
1229 if (dvb_ca_en50221_link_init(ca, slot) != 0) { in dvb_ca_en50221_thread_state_machine()
1230 if (dvb_ca_en50221_poll_cam_gone(ca, slot)) in dvb_ca_en50221_thread_state_machine()
1234 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1236 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1244 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1246 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1253 ca->pub->slot_ts_enable(ca->pub, slot); in dvb_ca_en50221_thread_state_machine()
1255 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread_state_machine()
1257 ca->dvbdev->adapter->num); in dvb_ca_en50221_thread_state_machine()
1261 if (!ca->open) in dvb_ca_en50221_thread_state_machine()
1266 while (dvb_ca_en50221_read_data(ca, slot, NULL, 0) > 0) { in dvb_ca_en50221_thread_state_machine()
1267 if (!ca->open) in dvb_ca_en50221_thread_state_machine()
1274 if (dvb_ca_en50221_check_camstatus(ca, slot)) { in dvb_ca_en50221_thread_state_machine()
1279 ca->wakeup = 1; in dvb_ca_en50221_thread_state_machine()
1289 ca->wakeup = 1; in dvb_ca_en50221_thread_state_machine()
1305 struct dvb_ca_private *ca = data; in dvb_ca_en50221_thread() local
1311 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_thread()
1316 if (!ca->wakeup) { in dvb_ca_en50221_thread()
1318 schedule_timeout(ca->delay); in dvb_ca_en50221_thread()
1322 ca->wakeup = 0; in dvb_ca_en50221_thread()
1325 for (slot = 0; slot < ca->slot_count; slot++) in dvb_ca_en50221_thread()
1326 dvb_ca_en50221_thread_state_machine(ca, slot); in dvb_ca_en50221_thread()
1350 struct dvb_ca_private *ca = dvbdev->priv; in dvb_ca_en50221_io_do_ioctl() local
1356 if (mutex_lock_interruptible(&ca->ioctl_mutex)) in dvb_ca_en50221_io_do_ioctl()
1361 for (slot = 0; slot < ca->slot_count; slot++) { in dvb_ca_en50221_io_do_ioctl()
1362 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_io_do_ioctl()
1366 dvb_ca_en50221_slot_shutdown(ca, slot); in dvb_ca_en50221_io_do_ioctl()
1367 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) in dvb_ca_en50221_io_do_ioctl()
1368 dvb_ca_en50221_camchange_irq(ca->pub, in dvb_ca_en50221_io_do_ioctl()
1374 ca->next_read_slot = 0; in dvb_ca_en50221_io_do_ioctl()
1375 dvb_ca_en50221_thread_wakeup(ca); in dvb_ca_en50221_io_do_ioctl()
1381 caps->slot_num = ca->slot_count; in dvb_ca_en50221_io_do_ioctl()
1393 if ((slot >= ca->slot_count) || (slot < 0)) { in dvb_ca_en50221_io_do_ioctl()
1397 slot = array_index_nospec(slot, ca->slot_count); in dvb_ca_en50221_io_do_ioctl()
1401 sl = &ca->slot_info[slot]; in dvb_ca_en50221_io_do_ioctl()
1417 mutex_unlock(&ca->ioctl_mutex); in dvb_ca_en50221_io_do_ioctl()
1451 struct dvb_ca_private *ca = dvbdev->priv; in dvb_ca_en50221_io_write() local
1478 if (slot >= ca->slot_count) in dvb_ca_en50221_io_write()
1480 slot = array_index_nospec(slot, ca->slot_count); in dvb_ca_en50221_io_write()
1481 sl = &ca->slot_info[slot]; in dvb_ca_en50221_io_write()
1518 status = dvb_ca_en50221_write_data(ca, slot, fragbuf, in dvb_ca_en50221_io_write()
1546 static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, in dvb_ca_en50221_io_read_condition() argument
1557 slot = ca->next_read_slot; in dvb_ca_en50221_io_read_condition()
1558 while ((slot_count < ca->slot_count) && (!found)) { in dvb_ca_en50221_io_read_condition()
1559 struct dvb_ca_slot *sl = &ca->slot_info[slot]; in dvb_ca_en50221_io_read_condition()
1584 slot = (slot + 1) % ca->slot_count; in dvb_ca_en50221_io_read_condition()
1588 ca->next_read_slot = slot; in dvb_ca_en50221_io_read_condition()
1606 struct dvb_ca_private *ca = dvbdev->priv; in dvb_ca_en50221_io_read() local
1629 status = dvb_ca_en50221_io_read_condition(ca, &result, &slot); in dvb_ca_en50221_io_read()
1636 status = wait_event_interruptible(ca->wait_queue, in dvb_ca_en50221_io_read()
1638 (ca, &result, &slot)); in dvb_ca_en50221_io_read()
1646 sl = &ca->slot_info[slot]; in dvb_ca_en50221_io_read()
1652 ca->dvbdev->adapter->num); in dvb_ca_en50221_io_read()
1714 struct dvb_ca_private *ca = dvbdev->priv; in dvb_ca_en50221_io_open() local
1720 mutex_lock(&ca->remove_mutex); in dvb_ca_en50221_io_open()
1722 if (ca->exit) { in dvb_ca_en50221_io_open()
1723 mutex_unlock(&ca->remove_mutex); in dvb_ca_en50221_io_open()
1727 if (!try_module_get(ca->pub->owner)) { in dvb_ca_en50221_io_open()
1728 mutex_unlock(&ca->remove_mutex); in dvb_ca_en50221_io_open()
1734 module_put(ca->pub->owner); in dvb_ca_en50221_io_open()
1735 mutex_unlock(&ca->remove_mutex); in dvb_ca_en50221_io_open()
1739 for (i = 0; i < ca->slot_count; i++) { in dvb_ca_en50221_io_open()
1740 struct dvb_ca_slot *sl = &ca->slot_info[i]; in dvb_ca_en50221_io_open()
1754 ca->open = 1; in dvb_ca_en50221_io_open()
1755 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_io_open()
1756 dvb_ca_en50221_thread_wakeup(ca); in dvb_ca_en50221_io_open()
1758 dvb_ca_private_get(ca); in dvb_ca_en50221_io_open()
1760 mutex_unlock(&ca->remove_mutex); in dvb_ca_en50221_io_open()
1775 struct dvb_ca_private *ca = dvbdev->priv; in dvb_ca_en50221_io_release() local
1780 mutex_lock(&ca->remove_mutex); in dvb_ca_en50221_io_release()
1783 ca->open = 0; in dvb_ca_en50221_io_release()
1784 dvb_ca_en50221_thread_update_delay(ca); in dvb_ca_en50221_io_release()
1788 module_put(ca->pub->owner); in dvb_ca_en50221_io_release()
1790 dvb_ca_private_put(ca); in dvb_ca_en50221_io_release()
1792 if (dvbdev->users == 1 && ca->exit == 1) { in dvb_ca_en50221_io_release()
1793 mutex_unlock(&ca->remove_mutex); in dvb_ca_en50221_io_release()
1796 mutex_unlock(&ca->remove_mutex); in dvb_ca_en50221_io_release()
1813 struct dvb_ca_private *ca = dvbdev->priv; in dvb_ca_en50221_io_poll() local
1820 poll_wait(file, &ca->wait_queue, wait); in dvb_ca_en50221_io_poll()
1822 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) in dvb_ca_en50221_io_poll()
1829 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) in dvb_ca_en50221_io_poll()
1874 struct dvb_ca_private *ca = NULL; in dvb_ca_en50221_init() local
1883 ca = kzalloc(sizeof(*ca), GFP_KERNEL); in dvb_ca_en50221_init()
1884 if (!ca) { in dvb_ca_en50221_init()
1888 kref_init(&ca->refcount); in dvb_ca_en50221_init()
1889 ca->pub = pubca; in dvb_ca_en50221_init()
1890 ca->flags = flags; in dvb_ca_en50221_init()
1891 ca->slot_count = slot_count; in dvb_ca_en50221_init()
1892 ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), in dvb_ca_en50221_init()
1894 if (!ca->slot_info) { in dvb_ca_en50221_init()
1898 init_waitqueue_head(&ca->wait_queue); in dvb_ca_en50221_init()
1899 ca->open = 0; in dvb_ca_en50221_init()
1900 ca->wakeup = 0; in dvb_ca_en50221_init()
1901 ca->next_read_slot = 0; in dvb_ca_en50221_init()
1902 pubca->private = ca; in dvb_ca_en50221_init()
1905 ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, in dvb_ca_en50221_init()
1912 struct dvb_ca_slot *sl = &ca->slot_info[i]; in dvb_ca_en50221_init()
1921 mutex_init(&ca->ioctl_mutex); in dvb_ca_en50221_init()
1922 mutex_init(&ca->remove_mutex); in dvb_ca_en50221_init()
1931 ca->thread = kthread_run(dvb_ca_en50221_thread, ca, "kdvb-ca-%i:%i", in dvb_ca_en50221_init()
1932 ca->dvbdev->adapter->num, ca->dvbdev->id); in dvb_ca_en50221_init()
1933 if (IS_ERR(ca->thread)) { in dvb_ca_en50221_init()
1934 ret = PTR_ERR(ca->thread); in dvb_ca_en50221_init()
1942 dvb_unregister_device(ca->dvbdev); in dvb_ca_en50221_init()
1944 kfree(ca->slot_info); in dvb_ca_en50221_init()
1946 kfree(ca); in dvb_ca_en50221_init()
1960 struct dvb_ca_private *ca = pubca->private; in dvb_ca_en50221_release() local
1965 mutex_lock(&ca->remove_mutex); in dvb_ca_en50221_release()
1966 ca->exit = 1; in dvb_ca_en50221_release()
1967 mutex_unlock(&ca->remove_mutex); in dvb_ca_en50221_release()
1969 if (ca->dvbdev->users < 1) in dvb_ca_en50221_release()
1970 wait_event(ca->dvbdev->wait_queue, in dvb_ca_en50221_release()
1971 ca->dvbdev->users == 1); in dvb_ca_en50221_release()
1974 kthread_stop(ca->thread); in dvb_ca_en50221_release()
1976 for (i = 0; i < ca->slot_count; i++) in dvb_ca_en50221_release()
1977 dvb_ca_en50221_slot_shutdown(ca, i); in dvb_ca_en50221_release()
1979 dvb_remove_device(ca->dvbdev); in dvb_ca_en50221_release()
1980 dvb_ca_private_put(ca); in dvb_ca_en50221_release()