diff mbox series

Input: xpad - Turn off wireless controllers on shutdown

Message ID 20220324145308.2372-1-stephen.douthit@gmail.com (mailing list archive)
State New, archived
Headers show
Series Input: xpad - Turn off wireless controllers on shutdown | expand

Commit Message

Stephen Douthit March 24, 2022, 2:53 p.m. UTC
We already do this on suspend, makes sense for shutdown as well

Signed-off-by: Stephen Douthit <stephen.douthit@gmail.com>
---
 drivers/input/joystick/xpad.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 18190b529bca..8be79f91ba56 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1738,6 +1738,16 @@  static int xpad_init_input(struct usb_xpad *xpad)
 	return error;
 }
 
+static void xpad360w_shutdown(struct device *dev)
+{
+	struct usb_interface *intf = to_usb_interface(dev);
+	struct usb_xpad *xpad = usb_get_intfdata(intf);
+
+	xpad360w_stop_input(xpad);
+	if (xpad->pad_present)
+		xpad360w_poweroff_controller(xpad);
+}
+
 static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
@@ -1863,6 +1873,12 @@  static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 		 * here in this driver and in usb core.
 		 */
 		udev->quirks |= USB_QUIRK_RESET_RESUME;
+
+		/*
+		 * Populate shutdown callback so wireless controllers turn off
+		 * when the machine turns off
+		 */
+		intf->dev.driver->shutdown = xpad360w_shutdown;
 	} else {
 		error = xpad_init_input(xpad);
 		if (error)