Received: by 10.213.65.68 with SMTP id h4csp720444imn; Fri, 6 Apr 2018 07:50:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/7ixVFFKm1sQWWrFi3oNP1tFErwUqhH92qezswrHDx5iV+uh9vnb3aeWwEahzpU3QzRwW9 X-Received: by 10.101.74.193 with SMTP id c1mr18034687pgu.116.1523026209003; Fri, 06 Apr 2018 07:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523026208; cv=none; d=google.com; s=arc-20160816; b=CDDAaUrFptE8wUBpRJBkiIdXG2Tn2uiyWCHyQaGGOznqW+VfSLe3vDPvCwTGKZ34NT cUlVX3aEdvKQNAIn6mEr1Bq39eibQihmASxNtrC2SAZzL7Opc0AdD45ULoKY2SnNtq2i rapuQRg0F+Gj25O5MRqTOuauYFA8UmCkMHdpw/DiTsBkeNmEKUZqlpyPb/c1tSnQA/fE tqYBIMCYT0uh1WTKNA9QiMERwdTNaaWRUjMRiGGpSzSshLD0ouLQDSAGb08ts1VaTwQX sMcLiOqSkAYHXbiiB03oexxI1i7f0foNntrMgPt39nGDEj3MSqjoZu6gXyl/ugK+Djst Hysw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zDly7uu1XpIlGYd0aQ0F+mo9LOFZTgvcgpuraeXMmfE=; b=jGN7NjL7wjDcvOFPgkew80Lr7mSy1pj+K+2O2HK437d4KRgk1AHxnmnoTJ5GbNz3wZ yzsliWrqWFLt3fx65PbQjpxUB9YhROmcVWuq9GMuckFoqkTkHahkf5nSqIw0oT6AJUaR fql4YJ0tNbONfL+7HjE2bJwWWpcmzS4HrQVh3lXB9NPVidENGGoa+W0gnY7oaPG6T9UX mnTTjUtYoHMb7Ue1mXJJi2wnAp7oQxPixBgqSrjkFu3vyWrS4kYj30GDkqDFQtPgkkFQ /gozhUCzCKaJ/PF7e9NzmATTAJUw5spgXnWFZzaKYgPXVjAmSM9vGuWzmhbfA7oYlbv5 0Eag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 135si7991192pfc.21.2018.04.06.07.49.54; Fri, 06 Apr 2018 07:50:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755651AbeDFNdg (ORCPT + 99 others); Fri, 6 Apr 2018 09:33:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57958 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755635AbeDFNde (ORCPT ); Fri, 6 Apr 2018 09:33:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DE818CF1; Fri, 6 Apr 2018 13:33:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frank Praznik , Jiri Kosina , Nathan Chancellor Subject: [PATCH 4.9 027/102] HID: sony: Use LED_CORE_SUSPENDRESUME Date: Fri, 6 Apr 2018 15:23:08 +0200 Message-Id: <20180406084335.460135496@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Frank Praznik commit 765a1077c85e5f2efcc43582f80caf43a052e903 upstream. 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 Signed-off-by: Jiri Kosina Cc: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-sony.c | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1056,7 +1056,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; @@ -1793,6 +1792,7 @@ static int sony_leds_init(struct sony_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; @@ -2509,47 +2509,32 @@ static void sony_remove(struct hid_devic 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;