From patchwork Wed Feb 8 18:58:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Praznik X-Patchwork-Id: 9563215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4AF2B60236 for ; Wed, 8 Feb 2017 19:10:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C9DC284FF for ; Wed, 8 Feb 2017 19:10:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 213202850F; Wed, 8 Feb 2017 19:10:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAC27284FF for ; Wed, 8 Feb 2017 19:10:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751816AbdBHTJs (ORCPT ); Wed, 8 Feb 2017 14:09:48 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:36730 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752415AbdBHTJp (ORCPT ); Wed, 8 Feb 2017 14:09:45 -0500 Received: by mail-qt0-f196.google.com with SMTP id h53so24452720qth.3 for ; Wed, 08 Feb 2017 11:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JUV4UWuqCvW4vZk/WVCEuWN37cvALMxaD/jecED6KkY=; b=RB3wu7jf/8f99J4/vHog+OPKbyU/VRUgHZilpmsC6Ffjc/zSk3TRtlYI5Uiajceq27 /5wGxS6W6wMEhTx9IC0ewr3B+Nw+YFphxVC3PbWDsY5/EzufAXDoJ1dsxwFaFxbDyyYx ofeJokcm+JJe9z6HgORhDZSg0E19FjO3+D+z9vU2iJTTsEVhAmosdf8QmOREb69B8NjI BoSqyOsf6HwfcBcyw/ZWwL3DNTOmZO+hJ5Ngbie73nBwee+x3k0VHl9j3XU54Ox7DuKT 0fA4z7T+tbuM73NitmwMTveR0CDzqb61RXwNWRx30sKQGRabXW689NBzZn0bFAVK6xmT LMsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JUV4UWuqCvW4vZk/WVCEuWN37cvALMxaD/jecED6KkY=; b=QwBgjEjAAvR6EBlUQ8b+sUqnY4amiPzM2cUHJ1MkimCeBT9u1zH4j6+qRiYvEo0BX9 w8e1dcpAQ+FrpjlOSlEeCjeIl7ecYw7QYRcHt09IcL6K5o0Iv4HSxIzUV3PW43ioA1y9 Ldp9yr213tNDRf5BiMXrPSE0YGJt3+PN1rsCZMoYiEv0mrxwikbwLiPnQcP8znMZ+RAK T/aXlVKFkWz9WZ7Jt5aDrcMuXKz2vvpn1E1iRFPqLhCvcYTIb9iIRyPGd0MWujtTRt40 oGyNwvfXw5Jkishe1w/s3XEx9Za9qJFKAn4Dfh4FzhdP8Jbkir0lGwQa/Vm8c7G8toTl npfg== X-Gm-Message-State: AMke39lQsnCDGBLwep5rcE39Ndt0Fs1dmIzUWXHI4fJIDU2xCNShOMc7hD0o6vdEaRiyuQ== X-Received: by 10.200.47.53 with SMTP id j50mr20538399qta.273.1486580346635; Wed, 08 Feb 2017 10:59:06 -0800 (PST) Received: from localhost.localdomain ([2607:fcc8:9e44:d500:5862:d269:6009:4911]) by smtp.gmail.com with ESMTPSA id x22sm3814687qkb.12.2017.02.08.10.59.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 10:59:05 -0800 (PST) From: Frank Praznik To: linux-input@vger.kernel.org Cc: jikos@kernel.org, roderick.colenbrander@sony.com, simon@mungewell.org, tim.bird@am.sony.com, dmitry.torokhov@gmail.com, Frank Praznik Subject: [PATCH] HID: sony: Use LED_CORE_SUSPENDRESUME Date: Wed, 8 Feb 2017 13:58:43 -0500 Message-Id: <20170208185843.5822-1-frank.praznik@gmail.com> X-Mailer: git-send-email 2.9.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The LED subsystem provides the LED_CORE_SUSPENDRESUME flag to handle automatically turning off and restoring the state of device LEDs during suspend/resume. Use this flag instead of saving and restoring the state locally. Signed-off-by: Frank Praznik --- drivers/hid/hid-sony.c | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index f405b07..7e2bae3 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1095,7 +1095,6 @@ struct sony_sc { u8 battery_charging; u8 battery_capacity; u8 led_state[MAX_LEDS]; - u8 resume_led_state[MAX_LEDS]; u8 led_delay_on[MAX_LEDS]; u8 led_delay_off[MAX_LEDS]; u8 led_count; @@ -1964,6 +1963,7 @@ static int sony_leds_init(struct sony_sc *sc) led->name = name; led->brightness = sc->led_state[n]; led->max_brightness = max_brightness[n]; + led->flags = LED_CORE_SUSPENDRESUME; led->brightness_get = sony_led_get_brightness; led->brightness_set = sony_led_set_brightness; @@ -2734,47 +2734,32 @@ static void sony_remove(struct hid_device *hdev) static int sony_suspend(struct hid_device *hdev, pm_message_t message) { - /* - * On suspend save the current LED state, - * stop running force-feedback and blank the LEDS. - */ - if (SONY_LED_SUPPORT || SONY_FF_SUPPORT) { - struct sony_sc *sc = hid_get_drvdata(hdev); - #ifdef CONFIG_SONY_FF - sc->left = sc->right = 0; -#endif - memcpy(sc->resume_led_state, sc->led_state, - sizeof(sc->resume_led_state)); - memset(sc->led_state, 0, sizeof(sc->led_state)); + /* On suspend stop any running force-feedback events */ + if (SONY_FF_SUPPORT) { + struct sony_sc *sc = hid_get_drvdata(hdev); + sc->left = sc->right = 0; sony_send_output_report(sc); } +#endif return 0; } static int sony_resume(struct hid_device *hdev) { - /* Restore the state of controller LEDs on resume */ - if (SONY_LED_SUPPORT) { - struct sony_sc *sc = hid_get_drvdata(hdev); - - memcpy(sc->led_state, sc->resume_led_state, - sizeof(sc->led_state)); - - /* - * The Sixaxis and navigation controllers on USB need to be - * reinitialized on resume or they won't behave properly. - */ - if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || - (sc->quirks & NAVIGATION_CONTROLLER_USB)) { - sixaxis_set_operational_usb(sc->hdev); - sc->defer_initialization = 1; - } + struct sony_sc *sc = hid_get_drvdata(hdev); - sony_set_leds(sc); + /* + * The Sixaxis and navigation controllers on USB need to be + * reinitialized on resume or they won't behave properly. + */ + if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || + (sc->quirks & NAVIGATION_CONTROLLER_USB)) { + sixaxis_set_operational_usb(sc->hdev); + sc->defer_initialization = 1; } return 0;