* [PATCH] HID: sony: Fix work queue issues.
@ 2014-02-19 18:09 Frank Praznik
2014-02-19 18:27 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Frank Praznik @ 2014-02-19 18:09 UTC (permalink / raw)
To: linux-input; +Cc: stable, dh.herrmann, jkosina, Frank Praznik
Don't initialize force-feedback for devices that don't support it to avoid calls
to schedule_work() with an uninitialized work_struct.
Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
is used for the LEDs even when force-feedback is disabled.
Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.
Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
---
This is a bugfix for 3.14.
drivers/hid/hid-sony.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 1235405..2f19b15 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -42,6 +42,7 @@
#define DUALSHOCK4_CONTROLLER_BT BIT(6)
#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB)
+#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER_USB | DUALSHOCK4_CONTROLLER_USB)
#define MAX_LEDS 4
@@ -499,6 +500,7 @@ struct sony_sc {
__u8 right;
#endif
+ __u8 worker_initialized;
__u8 led_state[MAX_LEDS];
__u8 led_count;
};
@@ -993,22 +995,11 @@ static int sony_init_ff(struct hid_device *hdev)
return input_ff_create_memless(input_dev, NULL, sony_play_effect);
}
-static void sony_destroy_ff(struct hid_device *hdev)
-{
- struct sony_sc *sc = hid_get_drvdata(hdev);
-
- cancel_work_sync(&sc->state_worker);
-}
-
#else
static int sony_init_ff(struct hid_device *hdev)
{
return 0;
}
-
-static void sony_destroy_ff(struct hid_device *hdev)
-{
-}
#endif
static int sony_set_output_report(struct sony_sc *sc, int req_id, int req_size)
@@ -1077,6 +1068,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
ret = sixaxis_set_operational_usb(hdev);
+
+ sc->worker_initialized = 1;
INIT_WORK(&sc->state_worker, sixaxis_state_worker);
}
else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
@@ -1087,6 +1080,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
if (ret < 0)
goto err_stop;
+ sc->worker_initialized = 1;
INIT_WORK(&sc->state_worker, dualshock4_state_worker);
} else {
ret = 0;
@@ -1101,9 +1095,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
goto err_stop;
}
- ret = sony_init_ff(hdev);
- if (ret < 0)
- goto err_stop;
+ if (sc->quirks & SONY_FF_SUPPORT) {
+ ret = sony_init_ff(hdev);
+ if (ret < 0)
+ goto err_stop;
+ }
return 0;
err_stop:
@@ -1120,7 +1116,8 @@ static void sony_remove(struct hid_device *hdev)
if (sc->quirks & SONY_LED_SUPPORT)
sony_leds_remove(hdev);
- sony_destroy_ff(hdev);
+ if (sc->worker_initialized)
+ cancel_work_sync(&sc->state_worker);
hid_hw_stop(hdev);
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: sony: Fix work queue issues.
2014-02-19 18:09 [PATCH] HID: sony: Fix work queue issues Frank Praznik
@ 2014-02-19 18:27 ` Greg KH
2014-02-19 18:41 ` David Herrmann
2014-02-20 13:15 ` Jiri Kosina
2 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2014-02-19 18:27 UTC (permalink / raw)
To: Frank Praznik; +Cc: linux-input, stable, dh.herrmann, jkosina
On Wed, Feb 19, 2014 at 01:09:22PM -0500, Frank Praznik wrote:
> Don't initialize force-feedback for devices that don't support it to avoid calls
> to schedule_work() with an uninitialized work_struct.
>
> Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
> is used for the LEDs even when force-feedback is disabled.
>
> Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.
>
> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
> ---
>
> This is a bugfix for 3.14.
>
> drivers/hid/hid-sony.c | 27 ++++++++++++---------------
> 1 file changed, 12 insertions(+), 15 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: sony: Fix work queue issues.
2014-02-19 18:09 [PATCH] HID: sony: Fix work queue issues Frank Praznik
2014-02-19 18:27 ` Greg KH
@ 2014-02-19 18:41 ` David Herrmann
2014-02-19 19:21 ` Frank Praznik
2014-02-20 13:15 ` Jiri Kosina
2 siblings, 1 reply; 6+ messages in thread
From: David Herrmann @ 2014-02-19 18:41 UTC (permalink / raw)
To: Frank Praznik; +Cc: open list:HID CORE LAYER, Jiri Kosina
Hi Frank
On Wed, Feb 19, 2014 at 7:09 PM, Frank Praznik <frank.praznik@oh.rr.com> wrote:
> Don't initialize force-feedback for devices that don't support it to avoid calls
> to schedule_work() with an uninitialized work_struct.
>
> Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
> is used for the LEDs even when force-feedback is disabled.
>
> Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.
>
> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Sorry, my comment might have been misleading. You have to add the "Cc:
<stable@vger.kernel.org>" line underneath/above your "Signed-off-by".
This will send a notice to the stable guys once the patch is applied
in Linus' tree.
But that's also described in the file Greg posted.
Cheers
David
> ---
>
> This is a bugfix for 3.14.
>
> drivers/hid/hid-sony.c | 27 ++++++++++++---------------
> 1 file changed, 12 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index 1235405..2f19b15 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -42,6 +42,7 @@
> #define DUALSHOCK4_CONTROLLER_BT BIT(6)
>
> #define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER | DUALSHOCK4_CONTROLLER_USB)
> +#define SONY_FF_SUPPORT (SIXAXIS_CONTROLLER_USB | DUALSHOCK4_CONTROLLER_USB)
>
> #define MAX_LEDS 4
>
> @@ -499,6 +500,7 @@ struct sony_sc {
> __u8 right;
> #endif
>
> + __u8 worker_initialized;
> __u8 led_state[MAX_LEDS];
> __u8 led_count;
> };
> @@ -993,22 +995,11 @@ static int sony_init_ff(struct hid_device *hdev)
> return input_ff_create_memless(input_dev, NULL, sony_play_effect);
> }
>
> -static void sony_destroy_ff(struct hid_device *hdev)
> -{
> - struct sony_sc *sc = hid_get_drvdata(hdev);
> -
> - cancel_work_sync(&sc->state_worker);
> -}
> -
> #else
> static int sony_init_ff(struct hid_device *hdev)
> {
> return 0;
> }
> -
> -static void sony_destroy_ff(struct hid_device *hdev)
> -{
> -}
> #endif
>
> static int sony_set_output_report(struct sony_sc *sc, int req_id, int req_size)
> @@ -1077,6 +1068,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
> if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
> hdev->hid_output_raw_report = sixaxis_usb_output_raw_report;
> ret = sixaxis_set_operational_usb(hdev);
> +
> + sc->worker_initialized = 1;
> INIT_WORK(&sc->state_worker, sixaxis_state_worker);
> }
> else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
> @@ -1087,6 +1080,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
> if (ret < 0)
> goto err_stop;
>
> + sc->worker_initialized = 1;
> INIT_WORK(&sc->state_worker, dualshock4_state_worker);
> } else {
> ret = 0;
> @@ -1101,9 +1095,11 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
> goto err_stop;
> }
>
> - ret = sony_init_ff(hdev);
> - if (ret < 0)
> - goto err_stop;
> + if (sc->quirks & SONY_FF_SUPPORT) {
> + ret = sony_init_ff(hdev);
> + if (ret < 0)
> + goto err_stop;
> + }
>
> return 0;
> err_stop:
> @@ -1120,7 +1116,8 @@ static void sony_remove(struct hid_device *hdev)
> if (sc->quirks & SONY_LED_SUPPORT)
> sony_leds_remove(hdev);
>
> - sony_destroy_ff(hdev);
> + if (sc->worker_initialized)
> + cancel_work_sync(&sc->state_worker);
>
> hid_hw_stop(hdev);
> }
> --
> 1.8.5.3
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: sony: Fix work queue issues.
2014-02-19 18:41 ` David Herrmann
@ 2014-02-19 19:21 ` Frank Praznik
2014-02-19 22:22 ` David Herrmann
0 siblings, 1 reply; 6+ messages in thread
From: Frank Praznik @ 2014-02-19 19:21 UTC (permalink / raw)
To: David Herrmann; +Cc: open list:HID CORE LAYER, Jiri Kosina
On Wed, Feb 19, 2014 at 1:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi Frank
>
> On Wed, Feb 19, 2014 at 7:09 PM, Frank Praznik <frank.praznik@oh.rr.com> wrote:
>> Don't initialize force-feedback for devices that don't support it to avoid calls
>> to schedule_work() with an uninitialized work_struct.
>>
>> Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
>> is used for the LEDs even when force-feedback is disabled.
>>
>> Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.
>>
>> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
>
> Sorry, my comment might have been misleading. You have to add the "Cc:
> <stable@vger.kernel.org>" line underneath/above your "Signed-off-by".
> This will send a notice to the stable guys once the patch is applied
> in Linus' tree.
>
> But that's also described in the file Greg posted.
>
> Cheers
> David
>
Actually, does this even need to go into stable? The issue doesn't
exist below kernel 3.14 since the LED system wasn't added until commit
0a286ef278529f2bc4f4bb27c4cf99c05999c818 in December. Could this just
go into for-3.14/upstream-fixes and for-linus with the other pending
fixes?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: sony: Fix work queue issues.
2014-02-19 19:21 ` Frank Praznik
@ 2014-02-19 22:22 ` David Herrmann
0 siblings, 0 replies; 6+ messages in thread
From: David Herrmann @ 2014-02-19 22:22 UTC (permalink / raw)
To: Frank Praznik; +Cc: open list:HID CORE LAYER, Jiri Kosina
Hi
On Wed, Feb 19, 2014 at 8:21 PM, Frank Praznik <frank.praznik@oh.rr.com> wrote:
> On Wed, Feb 19, 2014 at 1:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote:
>> Hi Frank
>>
>> On Wed, Feb 19, 2014 at 7:09 PM, Frank Praznik <frank.praznik@oh.rr.com> wrote:
>>> Don't initialize force-feedback for devices that don't support it to avoid calls
>>> to schedule_work() with an uninitialized work_struct.
>>>
>>> Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
>>> is used for the LEDs even when force-feedback is disabled.
>>>
>>> Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.
>>>
>>> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
>>
>> Sorry, my comment might have been misleading. You have to add the "Cc:
>> <stable@vger.kernel.org>" line underneath/above your "Signed-off-by".
>> This will send a notice to the stable guys once the patch is applied
>> in Linus' tree.
>>
>> But that's also described in the file Greg posted.
>>
>> Cheers
>> David
>>
> Actually, does this even need to go into stable? The issue doesn't
> exist below kernel 3.14 since the LED system wasn't added until commit
> 0a286ef278529f2bc4f4bb27c4cf99c05999c818 in December. Could this just
> go into for-3.14/upstream-fixes and for-linus with the other pending
> fixes?
Sure.
Thanks
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: sony: Fix work queue issues.
2014-02-19 18:09 [PATCH] HID: sony: Fix work queue issues Frank Praznik
2014-02-19 18:27 ` Greg KH
2014-02-19 18:41 ` David Herrmann
@ 2014-02-20 13:15 ` Jiri Kosina
2 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2014-02-20 13:15 UTC (permalink / raw)
To: Frank Praznik; +Cc: linux-input, stable, dh.herrmann
On Wed, 19 Feb 2014, Frank Praznik wrote:
> Don't initialize force-feedback for devices that don't support it to avoid calls
> to schedule_work() with an uninitialized work_struct.
>
> Move the cancel_work_sync() call out of sony_destroy_ff() since the state worker
> is used for the LEDs even when force-feedback is disabled.
>
> Remove sony_destroy_ff() to avoid a compiler warning since it is no longer used.
>
> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
Queued for 3.14 (without the -stable annotation), thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-20 13:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 18:09 [PATCH] HID: sony: Fix work queue issues Frank Praznik
2014-02-19 18:27 ` Greg KH
2014-02-19 18:41 ` David Herrmann
2014-02-19 19:21 ` Frank Praznik
2014-02-19 22:22 ` David Herrmann
2014-02-20 13:15 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).