28 #include <linux/sched.h>
30 #include <linux/errno.h>
32 #include <linux/module.h>
34 #include <linux/slab.h>
36 #include <linux/utsname.h>
39 #include <scsi/scsi.h>
59 static int auto_delink_en;
67 static int ss_delay = 50;
70 "seconds to delay before entering selective suspend");
72 static int needs_remote_wakeup;
74 MODULE_PARM_DESC(needs_remote_wakeup,
"ss state needs remote wakeup supported");
76 #ifdef SUPPORT_FILE_OP
90 static struct usb_class_driver rts51x_class = {
102 usb_autopm_put_interface(intf);
108 usb_autopm_get_interface(intf);
114 usb_autopm_enable(chip->
usb->pusb_intf);
120 usb_autopm_disable(chip->
usb->pusb_intf);
153 struct rts51x_chip *chip = usb_get_intfdata(iface);
181 struct rts51x_chip *chip = usb_get_intfdata(iface);
204 static void rts51x_try_to_enter_ss(
struct rts51x_chip *chip)
221 struct rts51x_chip *chip = usb_get_intfdata(iface);
232 struct rts51x_chip *chip = usb_get_intfdata(iface);
246 static int rts51x_control_thread(
void *__chip)
293 else if (chip->
srb->device->id) {
295 chip->
srb->device->id,
296 chip->
srb->device->lun);
300 else if (chip->
srb->device->lun > chip->
max_lun) {
302 chip->
srb->device->id,
303 chip->
srb->device->lun);
318 chip->
srb->scsi_done(chip->
srb);
357 static int rts51x_polling_thread(
void *__chip)
391 rts51x_try_to_enter_ss(chip);
428 #ifdef SUPPORT_FILE_OP
433 rts51x->
pusb_dev = interface_to_usbdev(intf);
435 rts51x->
ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
436 RTS51X_DEBUGP(
"Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n",
440 RTS51X_DEBUGP(
"Interface Subclass: 0x%02x, Protocol: 0x%02x\n",
441 intf->cur_altsetting->desc.bInterfaceSubClass,
442 intf->cur_altsetting->desc.bInterfaceProtocol);
445 usb_set_intfdata(intf, chip);
447 #ifdef SUPPORT_FILE_OP
453 usb_set_intfdata(intf,
NULL);
459 rts51x->
cr = usb_buffer_alloc(rts51x->
pusb_dev,
sizeof(*rts51x->
cr),
463 usb_set_intfdata(intf,
NULL);
469 if (!rts51x->
iobuf) {
471 usb_set_intfdata(intf,
NULL);
477 static void rts51x_init_options(
struct rts51x_chip *chip)
539 struct usb_host_interface *altsetting =
553 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
554 ep = &altsetting->endpoint[
i].desc;
556 if (usb_endpoint_xfer_bulk(ep)) {
557 if (usb_endpoint_dir_in(ep)) {
566 else if (usb_endpoint_is_int_in(ep)) {
572 if (!ep_in || !ep_out) {
582 usb_endpoint_num(ep_out));
584 usb_endpoint_num(ep_in));
595 static int rts51x_acquire_resources(
struct rts51x_chip *chip)
614 rts51x_init_options(chip);
625 static void rts51x_release_resources(
struct rts51x_chip *chip)
635 if (chip->
usb->ctl_thread)
638 if (chip->
usb->polling_thread)
654 static void dissociate_dev(
struct rts51x_chip *chip)
662 usb_buffer_free(rts51x->
pusb_dev,
sizeof(*rts51x->
cr),
671 #ifdef SUPPORT_FILE_OP
683 static void quiesce_and_remove_host(
struct rts51x_chip *chip)
686 struct Scsi_Host *host = rts51x_to_host(chip);
706 static void release_everything(
struct rts51x_chip *chip)
708 rts51x_release_resources(chip);
709 dissociate_dev(chip);
730 "Unable to allocate rts51x_usb\n");
741 "Unable to allocate the scsi host\n");
750 chip = host_to_rts51x(host);
760 init_completion(&(rts51x->
notify));
765 result = associate_dev(chip, intf);
770 result = get_pipes(chip);
775 result = rts51x_acquire_resources(chip);
783 "Unable to start control thread\n");
784 result = PTR_ERR(th);
789 result = scsi_add_host(rts51x_to_host(chip), &rts51x->
pusb_intf->dev);
800 "Unable to start polling thread\n");
801 result = PTR_ERR(th);
808 rts51x->
pusb_intf->needs_remote_wakeup = needs_remote_wakeup;
819 release_everything(chip);
828 quiesce_and_remove_host(chip);
829 release_everything(chip);
837 {USB_DEVICE(0x0BDA, 0x0139)},
838 {USB_DEVICE(0x0BDA, 0x0129)},
847 .probe = rts51x_probe,
848 .disconnect = rts51x_disconnect,