hid-sony.c (cb54b53adae70701bdd77d848cea4b9b39b61cf9) hid-sony.c (abf832bfc349b54fd500f1e3b612f7f3cd9dfcc6)
1/*
2 * HID driver for Sony / PS2 / PS3 BD devices.
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2008 Jiri Slaby
8 * Copyright (c) 2012 David Dillow <dave@thedillows.org>

--- 609 unchanged lines hidden (view full) ---

618
619static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
620{
621 int ret;
622 unsigned long quirks = id->driver_data;
623 struct sony_sc *sc;
624 unsigned int connect_mask = HID_CONNECT_DEFAULT;
625
1/*
2 * HID driver for Sony / PS2 / PS3 BD devices.
3 *
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2008 Jiri Slaby
8 * Copyright (c) 2012 David Dillow <dave@thedillows.org>

--- 609 unchanged lines hidden (view full) ---

618
619static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
620{
621 int ret;
622 unsigned long quirks = id->driver_data;
623 struct sony_sc *sc;
624 unsigned int connect_mask = HID_CONNECT_DEFAULT;
625
626 sc = kzalloc(sizeof(*sc), GFP_KERNEL);
626 sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL);
627 if (sc == NULL) {
628 hid_err(hdev, "can't alloc sony descriptor\n");
629 return -ENOMEM;
630 }
631
632 sc->quirks = quirks;
633 hid_set_drvdata(hdev, sc);
634
635 ret = hid_parse(hdev);
636 if (ret) {
637 hid_err(hdev, "parse failed\n");
627 if (sc == NULL) {
628 hid_err(hdev, "can't alloc sony descriptor\n");
629 return -ENOMEM;
630 }
631
632 sc->quirks = quirks;
633 hid_set_drvdata(hdev, sc);
634
635 ret = hid_parse(hdev);
636 if (ret) {
637 hid_err(hdev, "parse failed\n");
638 goto err_free;
638 return ret;
639 }
640
641 if (sc->quirks & VAIO_RDESC_CONSTANT)
642 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
643 else if (sc->quirks & SIXAXIS_CONTROLLER_USB)
644 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
645 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
646 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
647
648 ret = hid_hw_start(hdev, connect_mask);
649 if (ret) {
650 hid_err(hdev, "hw start failed\n");
639 }
640
641 if (sc->quirks & VAIO_RDESC_CONSTANT)
642 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
643 else if (sc->quirks & SIXAXIS_CONTROLLER_USB)
644 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
645 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
646 connect_mask |= HID_CONNECT_HIDDEV_FORCE;
647
648 ret = hid_hw_start(hdev, connect_mask);
649 if (ret) {
650 hid_err(hdev, "hw start failed\n");
651 goto err_free;
651 return ret;
652 }
653
654 if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
655 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
656 ret = sixaxis_set_operational_usb(hdev);
657 }
658 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
659 ret = sixaxis_set_operational_bt(hdev);
660 else if (sc->quirks & BUZZ_CONTROLLER)
661 ret = buzz_init(hdev);
662 else
663 ret = 0;
664
665 if (ret < 0)
666 goto err_stop;
667
668 return 0;
669err_stop:
670 hid_hw_stop(hdev);
652 }
653
654 if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
655 hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
656 ret = sixaxis_set_operational_usb(hdev);
657 }
658 else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
659 ret = sixaxis_set_operational_bt(hdev);
660 else if (sc->quirks & BUZZ_CONTROLLER)
661 ret = buzz_init(hdev);
662 else
663 ret = 0;
664
665 if (ret < 0)
666 goto err_stop;
667
668 return 0;
669err_stop:
670 hid_hw_stop(hdev);
671err_free:
672 kfree(sc);
673 return ret;
674}
675
676static void sony_remove(struct hid_device *hdev)
677{
678 struct sony_sc *sc = hid_get_drvdata(hdev);
679
680 if (sc->quirks & BUZZ_CONTROLLER)
681 buzz_remove(hdev);
682
683 hid_hw_stop(hdev);
671 return ret;
672}
673
674static void sony_remove(struct hid_device *hdev)
675{
676 struct sony_sc *sc = hid_get_drvdata(hdev);
677
678 if (sc->quirks & BUZZ_CONTROLLER)
679 buzz_remove(hdev);
680
681 hid_hw_stop(hdev);
684 kfree(sc);
685}
686
687static const struct hid_device_id sony_devices[] = {
688 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
689 .driver_data = SIXAXIS_CONTROLLER_USB },
690 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
691 .driver_data = SIXAXIS_CONTROLLER_USB },
692 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),

--- 33 unchanged lines hidden ---
682}
683
684static const struct hid_device_id sony_devices[] = {
685 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
686 .driver_data = SIXAXIS_CONTROLLER_USB },
687 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER),
688 .driver_data = SIXAXIS_CONTROLLER_USB },
689 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),

--- 33 unchanged lines hidden ---