diff options
author | Frank Praznik <frank.praznik@gmail.com> | 2017-02-08 13:58:43 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2017-03-06 07:45:34 -0500 |
commit | 765a1077c85e5f2efcc43582f80caf43a052e903 (patch) | |
tree | 434eb1431a9770dbab16d0adee210b5be50db40a /drivers/hid | |
parent | 81bbef23db51c0b450d90607fbbc2ad80ee0d43f (diff) |
HID: sony: Use LED_CORE_SUSPENDRESUME
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>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-sony.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index f405b07d0381..7e2bae309671 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
@@ -1095,7 +1095,6 @@ struct sony_sc { | |||
1095 | u8 battery_charging; | 1095 | u8 battery_charging; |
1096 | u8 battery_capacity; | 1096 | u8 battery_capacity; |
1097 | u8 led_state[MAX_LEDS]; | 1097 | u8 led_state[MAX_LEDS]; |
1098 | u8 resume_led_state[MAX_LEDS]; | ||
1099 | u8 led_delay_on[MAX_LEDS]; | 1098 | u8 led_delay_on[MAX_LEDS]; |
1100 | u8 led_delay_off[MAX_LEDS]; | 1099 | u8 led_delay_off[MAX_LEDS]; |
1101 | u8 led_count; | 1100 | u8 led_count; |
@@ -1964,6 +1963,7 @@ static int sony_leds_init(struct sony_sc *sc) | |||
1964 | led->name = name; | 1963 | led->name = name; |
1965 | led->brightness = sc->led_state[n]; | 1964 | led->brightness = sc->led_state[n]; |
1966 | led->max_brightness = max_brightness[n]; | 1965 | led->max_brightness = max_brightness[n]; |
1966 | led->flags = LED_CORE_SUSPENDRESUME; | ||
1967 | led->brightness_get = sony_led_get_brightness; | 1967 | led->brightness_get = sony_led_get_brightness; |
1968 | led->brightness_set = sony_led_set_brightness; | 1968 | led->brightness_set = sony_led_set_brightness; |
1969 | 1969 | ||
@@ -2734,47 +2734,32 @@ static void sony_remove(struct hid_device *hdev) | |||
2734 | 2734 | ||
2735 | static int sony_suspend(struct hid_device *hdev, pm_message_t message) | 2735 | static int sony_suspend(struct hid_device *hdev, pm_message_t message) |
2736 | { | 2736 | { |
2737 | /* | ||
2738 | * On suspend save the current LED state, | ||
2739 | * stop running force-feedback and blank the LEDS. | ||
2740 | */ | ||
2741 | if (SONY_LED_SUPPORT || SONY_FF_SUPPORT) { | ||
2742 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
2743 | |||
2744 | #ifdef CONFIG_SONY_FF | 2737 | #ifdef CONFIG_SONY_FF |
2745 | sc->left = sc->right = 0; | ||
2746 | #endif | ||
2747 | 2738 | ||
2748 | memcpy(sc->resume_led_state, sc->led_state, | 2739 | /* On suspend stop any running force-feedback events */ |
2749 | sizeof(sc->resume_led_state)); | 2740 | if (SONY_FF_SUPPORT) { |
2750 | memset(sc->led_state, 0, sizeof(sc->led_state)); | 2741 | struct sony_sc *sc = hid_get_drvdata(hdev); |
2751 | 2742 | ||
2743 | sc->left = sc->right = 0; | ||
2752 | sony_send_output_report(sc); | 2744 | sony_send_output_report(sc); |
2753 | } | 2745 | } |
2754 | 2746 | ||
2747 | #endif | ||
2755 | return 0; | 2748 | return 0; |
2756 | } | 2749 | } |
2757 | 2750 | ||
2758 | static int sony_resume(struct hid_device *hdev) | 2751 | static int sony_resume(struct hid_device *hdev) |
2759 | { | 2752 | { |
2760 | /* Restore the state of controller LEDs on resume */ | 2753 | struct sony_sc *sc = hid_get_drvdata(hdev); |
2761 | if (SONY_LED_SUPPORT) { | ||
2762 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
2763 | |||
2764 | memcpy(sc->led_state, sc->resume_led_state, | ||
2765 | sizeof(sc->led_state)); | ||
2766 | |||
2767 | /* | ||
2768 | * The Sixaxis and navigation controllers on USB need to be | ||
2769 | * reinitialized on resume or they won't behave properly. | ||
2770 | */ | ||
2771 | if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || | ||
2772 | (sc->quirks & NAVIGATION_CONTROLLER_USB)) { | ||
2773 | sixaxis_set_operational_usb(sc->hdev); | ||
2774 | sc->defer_initialization = 1; | ||
2775 | } | ||
2776 | 2754 | ||
2777 | sony_set_leds(sc); | 2755 | /* |
2756 | * The Sixaxis and navigation controllers on USB need to be | ||
2757 | * reinitialized on resume or they won't behave properly. | ||
2758 | */ | ||
2759 | if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || | ||
2760 | (sc->quirks & NAVIGATION_CONTROLLER_USB)) { | ||
2761 | sixaxis_set_operational_usb(sc->hdev); | ||
2762 | sc->defer_initialization = 1; | ||
2778 | } | 2763 | } |
2779 | 2764 | ||
2780 | return 0; | 2765 | return 0; |