Lines Matching refs:instance
193 static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
211 struct cxacru_data *instance = to_usbatm_driver_data(\
214 if (instance == NULL) \
217 return cxacru_sysfs_showattr_##_type(instance->card_info[_value], buf); \
306 struct cxacru_data *instance = to_usbatm_driver_data( in mac_address_show() local
309 if (instance == NULL || instance->usbatm->atm_dev == NULL) in mac_address_show()
312 return sprintf(buf, "%pM\n", instance->usbatm->atm_dev->esi); in mac_address_show()
319 struct cxacru_data *instance = to_usbatm_driver_data( in adsl_state_show() local
323 if (instance == NULL) in adsl_state_show()
326 value = instance->card_info[CXINF_LINE_STARTABLE]; in adsl_state_show()
335 struct cxacru_data *instance = to_usbatm_driver_data( in adsl_state_store() local
350 if (instance == NULL) in adsl_state_store()
353 if (mutex_lock_interruptible(&instance->adsl_state_serialize)) in adsl_state_store()
357 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_STOP, NULL, 0, NULL, 0); in adsl_state_store()
359 atm_err(instance->usbatm, "change adsl state:" in adsl_state_store()
377 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); in adsl_state_store()
379 atm_err(instance->usbatm, "change adsl state:" in adsl_state_store()
400 mutex_lock(&instance->poll_state_serialize); in adsl_state_store()
401 switch (instance->poll_state) { in adsl_state_store()
404 instance->poll_state = CXPOLL_POLLING; in adsl_state_store()
409 instance->poll_state = CXPOLL_POLLING; in adsl_state_store()
416 mutex_unlock(&instance->poll_state_serialize); in adsl_state_store()
418 mutex_lock(&instance->poll_state_serialize); in adsl_state_store()
420 if (instance->poll_state == CXPOLL_POLLING) in adsl_state_store()
421 instance->poll_state = CXPOLL_STOPPING; in adsl_state_store()
422 mutex_unlock(&instance->poll_state_serialize); in adsl_state_store()
425 mutex_unlock(&instance->adsl_state_serialize); in adsl_state_store()
428 cxacru_poll_status(&instance->poll_work.work); in adsl_state_store()
438 struct cxacru_data *instance = to_usbatm_driver_data( in adsl_config_store() local
447 if (instance == NULL) in adsl_config_store()
481 ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET, in adsl_config_store()
484 atm_err(instance->usbatm, in adsl_config_store()
493 atm_info(instance->usbatm, "config%s\n", log); in adsl_config_store()
608 static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, in cxacru_cm() argument
614 u8 *wbuf = instance->snd_buf; in cxacru_cm()
615 u8 *rbuf = instance->rcv_buf; in cxacru_cm()
621 usb_err(instance->usbatm, "requested transfer size too large (%d, %d)\n", in cxacru_cm()
627 mutex_lock(&instance->cm_serialize); in cxacru_cm()
630 init_completion(&instance->rcv_done); in cxacru_cm()
631 ret = usb_submit_urb(instance->rcv_urb, GFP_KERNEL); in cxacru_cm()
634 usb_err(instance->usbatm, "submit of read urb for cm %#x failed (%d)\n", in cxacru_cm()
647 instance->snd_urb->transfer_buffer_length = wbuflen; in cxacru_cm()
648 init_completion(&instance->snd_done); in cxacru_cm()
649 ret = usb_submit_urb(instance->snd_urb, GFP_KERNEL); in cxacru_cm()
652 usb_err(instance->usbatm, "submit of write urb for cm %#x failed (%d)\n", in cxacru_cm()
657 ret = cxacru_start_wait_urb(instance->snd_urb, &instance->snd_done, NULL); in cxacru_cm()
660 usb_err(instance->usbatm, "send of cm %#x failed (%d)\n", cm, ret); in cxacru_cm()
664 ret = cxacru_start_wait_urb(instance->rcv_urb, &instance->rcv_done, &actlen); in cxacru_cm()
667 usb_err(instance->usbatm, "receive of cm %#x failed (%d)\n", cm, ret); in cxacru_cm()
672 usb_err(instance->usbatm, "invalid response length to cm %#x: %d\n", in cxacru_cm()
682 usb_err(instance->usbatm, "wrong cm %#x in response to cm %#x\n", in cxacru_cm()
689 usb_err(instance->usbatm, "response to cm %#x failed: %#x\n", in cxacru_cm()
701 usb_dbg(instance->usbatm, "cm %#x\n", cm); in cxacru_cm()
703 mutex_unlock(&instance->cm_serialize); in cxacru_cm()
708 static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_request cm, in cxacru_cm_get_array() argument
722 ret = cxacru_cm(instance, cm, NULL, 0, (u8 *) buf, buflen); in cxacru_cm_get_array()
733 usb_err(instance->usbatm, "invalid data length from cm %#x: %d\n", in cxacru_cm_get_array()
742 usb_err(instance->usbatm, "wrong index %#x in response to cm %#x\n", in cxacru_cm_get_array()
758 static int cxacru_card_status(struct cxacru_data *instance) in cxacru_card_status() argument
760 int ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0); in cxacru_card_status()
763 usb_dbg(instance->usbatm, "cxacru_adsl_start: CARD_GET_STATUS returned %d\n", ret); in cxacru_card_status()
772 struct cxacru_data *instance = usbatm_instance->driver_data; in cxacru_atm_start() local
780 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0, in cxacru_atm_start()
788 mutex_lock(&instance->adsl_state_serialize); in cxacru_atm_start()
789 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); in cxacru_atm_start()
794 mutex_lock(&instance->poll_state_serialize); in cxacru_atm_start()
795 switch (instance->poll_state) { in cxacru_atm_start()
798 instance->poll_state = CXPOLL_POLLING; in cxacru_atm_start()
803 instance->poll_state = CXPOLL_POLLING; in cxacru_atm_start()
810 mutex_unlock(&instance->poll_state_serialize); in cxacru_atm_start()
811 mutex_unlock(&instance->adsl_state_serialize); in cxacru_atm_start()
814 cxacru_poll_status(&instance->poll_work.work); in cxacru_atm_start()
820 struct cxacru_data *instance = in cxacru_poll_status() local
823 struct usbatm_data *usbatm = instance->usbatm; in cxacru_poll_status()
828 ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX); in cxacru_poll_status()
833 mutex_lock(&instance->poll_state_serialize); in cxacru_poll_status()
834 if (instance->poll_state != CXPOLL_SHUTDOWN) { in cxacru_poll_status()
835 instance->poll_state = CXPOLL_STOPPED; in cxacru_poll_status()
841 mutex_unlock(&instance->poll_state_serialize); in cxacru_poll_status()
845 memcpy(instance->card_info, buf, sizeof(instance->card_info)); in cxacru_poll_status()
847 if (instance->adsl_status != buf[CXINF_LINE_STARTABLE]) { in cxacru_poll_status()
848 instance->adsl_status = buf[CXINF_LINE_STARTABLE]; in cxacru_poll_status()
850 switch (instance->adsl_status) { in cxacru_poll_status()
860 atm_info(usbatm, "Unknown adsl status %02x\n", instance->adsl_status); in cxacru_poll_status()
865 if (instance->line_status == buf[CXINF_LINE_STATUS]) in cxacru_poll_status()
868 instance->line_status = buf[CXINF_LINE_STATUS]; in cxacru_poll_status()
869 switch (instance->line_status) { in cxacru_poll_status()
915 atm_info(usbatm, "Unknown line state %02x\n", instance->line_status); in cxacru_poll_status()
920 mutex_lock(&instance->poll_state_serialize); in cxacru_poll_status()
921 if (instance->poll_state == CXPOLL_STOPPING && in cxacru_poll_status()
922 instance->adsl_status == 1 && /* stopped */ in cxacru_poll_status()
923 instance->line_status == 0) /* down */ in cxacru_poll_status()
924 instance->poll_state = CXPOLL_STOPPED; in cxacru_poll_status()
926 if (instance->poll_state == CXPOLL_STOPPED) in cxacru_poll_status()
928 mutex_unlock(&instance->poll_state_serialize); in cxacru_poll_status()
931 schedule_delayed_work(&instance->poll_work, in cxacru_poll_status()
983 static void cxacru_upload_firmware(struct cxacru_data *instance, in cxacru_upload_firmware() argument
988 struct usbatm_data *usbatm = instance->usbatm; in cxacru_upload_firmware()
997 val = cpu_to_le32(instance->modem_type->pll_f_clk); in cxacru_upload_firmware()
1005 val = cpu_to_le32(instance->modem_type->pll_b_clk); in cxacru_upload_firmware()
1029 if (instance->modem_type->boot_rom_patch) { in cxacru_upload_firmware()
1046 if (instance->modem_type->boot_rom_patch) { in cxacru_upload_firmware()
1065 ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0); in cxacru_upload_firmware()
1072 static int cxacru_find_firmware(struct cxacru_data *instance, in cxacru_find_firmware() argument
1075 struct usbatm_data *usbatm = instance->usbatm; in cxacru_find_firmware()
1096 struct cxacru_data *instance = usbatm_instance->driver_data; in cxacru_heavy_init() local
1097 int ret = cxacru_find_firmware(instance, "fw", &fw); in cxacru_heavy_init()
1104 if (instance->modem_type->boot_rom_patch) { in cxacru_heavy_init()
1105 ret = cxacru_find_firmware(instance, "bp", &bp); in cxacru_heavy_init()
1113 cxacru_upload_firmware(instance, fw, bp); in cxacru_heavy_init()
1115 if (instance->modem_type->boot_rom_patch) in cxacru_heavy_init()
1119 ret = cxacru_card_status(instance); in cxacru_heavy_init()
1131 struct cxacru_data *instance; in cxacru_bind() local
1137 instance = kzalloc(sizeof(*instance), GFP_KERNEL); in cxacru_bind()
1138 if (!instance) in cxacru_bind()
1141 instance->usbatm = usbatm_instance; in cxacru_bind()
1142 instance->modem_type = (struct cxacru_modem_type *) id->driver_info; in cxacru_bind()
1144 mutex_init(&instance->poll_state_serialize); in cxacru_bind()
1145 instance->poll_state = CXPOLL_STOPPED; in cxacru_bind()
1146 instance->line_status = -1; in cxacru_bind()
1147 instance->adsl_status = -1; in cxacru_bind()
1149 mutex_init(&instance->adsl_state_serialize); in cxacru_bind()
1151 instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL); in cxacru_bind()
1152 if (!instance->rcv_buf) { in cxacru_bind()
1157 instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL); in cxacru_bind()
1158 if (!instance->snd_buf) { in cxacru_bind()
1163 instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL); in cxacru_bind()
1164 if (!instance->rcv_urb) { in cxacru_bind()
1168 instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL); in cxacru_bind()
1169 if (!instance->snd_urb) { in cxacru_bind()
1182 usb_fill_int_urb(instance->rcv_urb, in cxacru_bind()
1184 instance->rcv_buf, PAGE_SIZE, in cxacru_bind()
1185 cxacru_blocking_completion, &instance->rcv_done, 1); in cxacru_bind()
1187 usb_fill_int_urb(instance->snd_urb, in cxacru_bind()
1189 instance->snd_buf, PAGE_SIZE, in cxacru_bind()
1190 cxacru_blocking_completion, &instance->snd_done, 4); in cxacru_bind()
1192 usb_fill_bulk_urb(instance->rcv_urb, in cxacru_bind()
1194 instance->rcv_buf, PAGE_SIZE, in cxacru_bind()
1195 cxacru_blocking_completion, &instance->rcv_done); in cxacru_bind()
1197 usb_fill_bulk_urb(instance->snd_urb, in cxacru_bind()
1199 instance->snd_buf, PAGE_SIZE, in cxacru_bind()
1200 cxacru_blocking_completion, &instance->snd_done); in cxacru_bind()
1203 mutex_init(&instance->cm_serialize); in cxacru_bind()
1205 INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status); in cxacru_bind()
1207 usbatm_instance->driver_data = instance; in cxacru_bind()
1209 usbatm_instance->flags = (cxacru_card_status(instance) ? 0 : UDSL_SKIP_HEAVY_INIT); in cxacru_bind()
1214 free_page((unsigned long) instance->snd_buf); in cxacru_bind()
1215 free_page((unsigned long) instance->rcv_buf); in cxacru_bind()
1216 usb_free_urb(instance->snd_urb); in cxacru_bind()
1217 usb_free_urb(instance->rcv_urb); in cxacru_bind()
1218 kfree(instance); in cxacru_bind()
1226 struct cxacru_data *instance = usbatm_instance->driver_data; in cxacru_unbind() local
1231 if (!instance) { in cxacru_unbind()
1236 mutex_lock(&instance->poll_state_serialize); in cxacru_unbind()
1237 BUG_ON(instance->poll_state == CXPOLL_SHUTDOWN); in cxacru_unbind()
1241 if (instance->poll_state == CXPOLL_STOPPED) in cxacru_unbind()
1245 instance->poll_state = CXPOLL_SHUTDOWN; in cxacru_unbind()
1246 mutex_unlock(&instance->poll_state_serialize); in cxacru_unbind()
1249 cancel_delayed_work_sync(&instance->poll_work); in cxacru_unbind()
1251 usb_kill_urb(instance->snd_urb); in cxacru_unbind()
1252 usb_kill_urb(instance->rcv_urb); in cxacru_unbind()
1253 usb_free_urb(instance->snd_urb); in cxacru_unbind()
1254 usb_free_urb(instance->rcv_urb); in cxacru_unbind()
1256 free_page((unsigned long) instance->snd_buf); in cxacru_unbind()
1257 free_page((unsigned long) instance->rcv_buf); in cxacru_unbind()
1259 kfree(instance); in cxacru_unbind()