H A D | pcwd_usb.c | 172 struct usb_pcwd_private *usb_pcwd = usb_pcwd_intr_done() local 174 unsigned char *data = usb_pcwd->intr_buffer; usb_pcwd_intr_done() 175 struct device *dev = &usb_pcwd->interface->dev; usb_pcwd_intr_done() 198 usb_pcwd->cmd_command = data[0]; usb_pcwd_intr_done() 199 usb_pcwd->cmd_data_msb = data[1]; usb_pcwd_intr_done() 200 usb_pcwd->cmd_data_lsb = data[2]; usb_pcwd_intr_done() 203 atomic_set(&usb_pcwd->cmd_received, 1); usb_pcwd_intr_done() 212 static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, usb_pcwd_send_command() argument 220 if ((!usb_pcwd) || (!usb_pcwd->exists)) usb_pcwd_send_command() 234 dev_dbg(&usb_pcwd->interface->dev, usb_pcwd_send_command() 238 atomic_set(&usb_pcwd->cmd_received, 0); usb_pcwd_send_command() 240 if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0), usb_pcwd_send_command() 242 0x0200, usb_pcwd->interface_number, buf, 6, usb_pcwd_send_command() 244 dev_dbg(&usb_pcwd->interface->dev, usb_pcwd_send_command() 254 if (atomic_read(&usb_pcwd->cmd_received)) usb_pcwd_send_command() 258 if ((got_response) && (cmd == usb_pcwd->cmd_command)) { usb_pcwd_send_command() 260 *msb = usb_pcwd->cmd_data_msb; usb_pcwd_send_command() 261 *lsb = usb_pcwd->cmd_data_lsb; usb_pcwd_send_command() 269 static int usb_pcwd_start(struct usb_pcwd_private *usb_pcwd) usb_pcwd_start() argument 276 retval = usb_pcwd_send_command(usb_pcwd, CMD_ENABLE_WATCHDOG, usb_pcwd_start() 287 static int usb_pcwd_stop(struct usb_pcwd_private *usb_pcwd) usb_pcwd_stop() argument 294 retval = usb_pcwd_send_command(usb_pcwd, CMD_DISABLE_WATCHDOG, usb_pcwd_stop() 305 static int usb_pcwd_keepalive(struct usb_pcwd_private *usb_pcwd) usb_pcwd_keepalive() argument 310 usb_pcwd_send_command(usb_pcwd, CMD_TRIGGER, &dummy, &dummy); usb_pcwd_keepalive() 315 static int usb_pcwd_set_heartbeat(struct usb_pcwd_private *usb_pcwd, int t) usb_pcwd_set_heartbeat() argument 324 usb_pcwd_send_command(usb_pcwd, CMD_WRITE_WATCHDOG_TIMEOUT, &msb, &lsb); usb_pcwd_set_heartbeat() 330 static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, usb_pcwd_get_temperature() argument 335 usb_pcwd_send_command(usb_pcwd, CMD_READ_TEMP, &msb, &lsb); usb_pcwd_get_temperature() 346 static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, usb_pcwd_get_timeleft() argument 353 usb_pcwd_send_command(usb_pcwd, CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb); usb_pcwd_get_timeleft() 589 static inline void usb_pcwd_delete(struct usb_pcwd_private *usb_pcwd) usb_pcwd_delete() argument 591 usb_free_urb(usb_pcwd->intr_urb); usb_pcwd_delete() 592 if (usb_pcwd->intr_buffer != NULL) usb_pcwd_delete() 593 usb_free_coherent(usb_pcwd->udev, usb_pcwd->intr_size, usb_pcwd_delete() 594 usb_pcwd->intr_buffer, usb_pcwd->intr_dma); usb_pcwd_delete() 595 kfree(usb_pcwd); usb_pcwd_delete() 610 struct usb_pcwd_private *usb_pcwd = NULL; usb_pcwd_probe() local 647 usb_pcwd = kzalloc(sizeof(struct usb_pcwd_private), GFP_KERNEL); usb_pcwd_probe() 648 if (usb_pcwd == NULL) usb_pcwd_probe() 651 usb_pcwd_device = usb_pcwd; usb_pcwd_probe() 653 mutex_init(&usb_pcwd->mtx); usb_pcwd_probe() 654 usb_pcwd->udev = udev; usb_pcwd_probe() 655 usb_pcwd->interface = interface; usb_pcwd_probe() 656 usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber; usb_pcwd_probe() 657 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? usb_pcwd_probe() 661 usb_pcwd->intr_buffer = usb_alloc_coherent(udev, usb_pcwd->intr_size, usb_pcwd_probe() 662 GFP_ATOMIC, &usb_pcwd->intr_dma); usb_pcwd_probe() 663 if (!usb_pcwd->intr_buffer) { usb_pcwd_probe() 669 usb_pcwd->intr_urb = usb_alloc_urb(0, GFP_KERNEL); usb_pcwd_probe() 670 if (!usb_pcwd->intr_urb) { usb_pcwd_probe() 676 usb_fill_int_urb(usb_pcwd->intr_urb, udev, pipe, usb_pcwd_probe() 677 usb_pcwd->intr_buffer, usb_pcwd->intr_size, usb_pcwd_probe() 678 usb_pcwd_intr_done, usb_pcwd, endpoint->bInterval); usb_pcwd_probe() 679 usb_pcwd->intr_urb->transfer_dma = usb_pcwd->intr_dma; usb_pcwd_probe() 680 usb_pcwd->intr_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; usb_pcwd_probe() 683 if (usb_submit_urb(usb_pcwd->intr_urb, GFP_KERNEL)) { usb_pcwd_probe() 690 usb_pcwd->exists = 1; usb_pcwd_probe() 693 usb_pcwd_stop(usb_pcwd); usb_pcwd_probe() 696 got_fw_rev = usb_pcwd_send_command(usb_pcwd, CMD_GET_FIRMWARE_VERSION, usb_pcwd_probe() 706 usb_pcwd_send_command(usb_pcwd, CMD_GET_DIP_SWITCH_SETTINGS, &dummy, usb_pcwd_probe() 720 if (usb_pcwd_set_heartbeat(usb_pcwd, heartbeat)) { usb_pcwd_probe() 721 usb_pcwd_set_heartbeat(usb_pcwd, WATCHDOG_HEARTBEAT); usb_pcwd_probe() 747 usb_set_intfdata(interface, usb_pcwd); usb_pcwd_probe() 759 if (usb_pcwd) usb_pcwd_probe() 760 usb_pcwd_delete(usb_pcwd); usb_pcwd_probe() 776 struct usb_pcwd_private *usb_pcwd; usb_pcwd_disconnect() local 781 usb_pcwd = usb_get_intfdata(interface); usb_pcwd_disconnect() 784 mutex_lock(&usb_pcwd->mtx); usb_pcwd_disconnect() 788 usb_pcwd_stop(usb_pcwd); usb_pcwd_disconnect() 791 usb_pcwd->exists = 0; usb_pcwd_disconnect() 798 mutex_unlock(&usb_pcwd->mtx); usb_pcwd_disconnect() 801 usb_pcwd_delete(usb_pcwd); usb_pcwd_disconnect()
|