* [PATCH] HID: sony: Use LED_CORE_SUSPENDRESUME
@ 2017-02-08 18:58 Frank Praznik
2017-03-06 12:47 ` Jiri Kosina
0 siblings, 1 reply; 3+ messages in thread
From: Frank Praznik @ 2017-02-08 18:58 UTC (permalink / raw)
To: linux-input
Cc: jikos, roderick.colenbrander, simon, tim.bird, dmitry.torokhov,
Frank Praznik
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 <frank.praznik@gmail.com>
---
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;
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: sony: Use LED_CORE_SUSPENDRESUME
2017-02-08 18:58 [PATCH] HID: sony: Use LED_CORE_SUSPENDRESUME Frank Praznik
@ 2017-03-06 12:47 ` Jiri Kosina
2017-03-06 12:51 ` Jiri Kosina
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2017-03-06 12:47 UTC (permalink / raw)
To: Frank Praznik
Cc: linux-input, roderick.colenbrander, simon, tim.bird, dmitry.torokhov
On Wed, 8 Feb 2017, Frank Praznik wrote:
> 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 <frank.praznik@gmail.com>
Applied to for-4.11/sony. Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: sony: Use LED_CORE_SUSPENDRESUME
2017-03-06 12:47 ` Jiri Kosina
@ 2017-03-06 12:51 ` Jiri Kosina
0 siblings, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2017-03-06 12:51 UTC (permalink / raw)
To: Frank Praznik
Cc: linux-input, roderick.colenbrander, simon, tim.bird, dmitry.torokhov
On Mon, 6 Mar 2017, Jiri Kosina wrote:
> > 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 <frank.praznik@gmail.com>
>
> Applied to for-4.11/sony. Thanks,
This should've read for-4.12, sorry for the noise.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-06 12:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-08 18:58 [PATCH] HID: sony: Use LED_CORE_SUSPENDRESUME Frank Praznik
2017-03-06 12:47 ` Jiri Kosina
2017-03-06 12:51 ` Jiri Kosina
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.