public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Fabio Baltieri <fabiobaltieri@chromium.org>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] HID: hid-stadiaff: add support for Stadia force feedback
Date: Fri, 5 May 2023 09:27:52 +0000	[thread overview]
Message-ID: <ZFTMGKwbH2P3uMIp@google.com> (raw)
In-Reply-To: <20230413160033.buwdbysbbc2hgu6o@mail.corp.redhat.com>

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

      reply	other threads:[~2023-05-05  9:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 10:33 [PATCH] HID: hid-stadiaff: add support for Stadia force feedback Fabio Baltieri
2023-04-13 16:00 ` Benjamin Tissoires
2023-05-05  9:27   ` Fabio Baltieri [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZFTMGKwbH2P3uMIp@google.com \
    --to=fabiobaltieri@chromium.org \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox