Re: [PATCH] HID: hid-stadiaff: add support for Stadia force feedback
From: Fabio Baltieri
Date: Fri May 05 2023 - 05:28:17 EST
Hi,
On Thu, Apr 13, 2023 at 06:00:33PM +0200, Benjamin Tissoires wrote:
> > drivers/hid/Kconfig | 7 ++
> > drivers/hid/Makefile | 1 +
> > drivers/hid/hid-ids.h | 1 +
> > drivers/hid/hid-stadiaff.c | 132 +++++++++++++++++++++++++++++++++++++
>
> Mind renaming this hid-google-stadiaff.c?
> It's hard to know that stadia is from Google otherwise.
Sure thing.
> > +static int stadiaff_play(struct input_dev *dev, void *data,
> > + struct ff_effect *effect)
> > +{
> > + struct hid_device *hid = input_get_drvdata(dev);
> > + struct stadiaff_device *stadiaff = hid_get_drvdata(hid);
> > + struct hid_field *rumble_field = stadiaff->report->field[0];
> > +
> > + rumble_field->value[0] = effect->u.rumble.strong_magnitude;
> > + rumble_field->value[1] = effect->u.rumble.weak_magnitude;
> > +
> > + schedule_work(&stadiaff->work);
>
> It seems weird that you don't have any locking in place here.
> What if you are sending a report (in stadiaff_work) while having your
> _play() function called at the same time?
Yeah you are right, I somehow missed the whole locking story, sending a
v2 with that added.
> > +static void stadia_remove(struct hid_device *hid)
> > +{
> > + struct stadiaff_device *stadiaff = hid_get_drvdata(hid);
> > +
> > + cancel_work_sync(&stadiaff->work);
>
> What if you have a ff play event scheduled right here? Don't you need
> some way of forcing the work to not be scheduled once again?
Good point, adding that as well for v2, took the pattern from other
existing drivers.
Thanks for the review,
Fabio
--
Fabio Baltieri