From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: Marcus Folkesson <marcus.folkesson@gmail.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: pxrc - simplify mutex handling with guard macro
Date: Fri, 1 Dec 2023 15:33:24 -0800 [thread overview]
Message-ID: <ZWptRAQ0OoK7RpDu@google.com> (raw)
In-Reply-To: <ZWnfsjIukIbAvQ-l@hovoldconsulting.com>
On Fri, Dec 01, 2023 at 02:29:22PM +0100, Johan Hovold wrote:
> On Fri, Dec 01, 2023 at 01:08:45PM +0100, Marcus Folkesson wrote:
> > Use the guard(mutex) macro for handle mutex lock/unlocks.
> >
> > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
>
> A couple of drive-by comments below.
>
> > ---
> > drivers/input/joystick/pxrc.c | 27 +++++++++++----------------
> > 1 file changed, 11 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/input/joystick/pxrc.c b/drivers/input/joystick/pxrc.c
> > index ea2bf5951d67..3c3bf7179b46 100644
> > --- a/drivers/input/joystick/pxrc.c
> > +++ b/drivers/input/joystick/pxrc.c
> > @@ -5,15 +5,17 @@
> > * Copyright (C) 2018 Marcus Folkesson <marcus.folkesson@gmail.com>
> > */
> >
> > -#include <linux/kernel.h>
> > +#include <linux/cleanup.h>
> > #include <linux/errno.h>
> > -#include <linux/slab.h>
> > +#include <linux/input.h>
> > +#include <linux/kernel.h>
> > #include <linux/module.h>
> > +#include <linux/mutex.h>
> > +#include <linux/slab.h>
> > #include <linux/uaccess.h>
> > +
> > #include <linux/usb.h>
> > #include <linux/usb/input.h>
> > -#include <linux/mutex.h>
> > -#include <linux/input.h>
>
> Looks like an unrelated change.
>
> > #define PXRC_VENDOR_ID 0x1781
> > #define PXRC_PRODUCT_ID 0x0898
> > @@ -89,25 +91,20 @@ static int pxrc_open(struct input_dev *input)
> > dev_err(&pxrc->intf->dev,
> > "%s - usb_submit_urb failed, error: %d\n",
> > __func__, retval);
> > - retval = -EIO;
> > - goto out;
> > + return -EIO;
> > }
> >
> > pxrc->is_open = true;
> > -
> > -out:
> > - mutex_unlock(&pxrc->pm_mutex);
> > - return retval;
> > + return 0;
> > }
>
> Eh, this looks obviously broken. Did you not test this before
> submitting? I assume lockdep would complain loudly too.
>
> You're apparently the author of this driver and can test it, but I fear
> the coming onslaught of untested guard conversions from the "cleanup"
> crew. Not sure I find the result generally more readable either.
Yeah, for the code without conditions (like pxrc_close) the utility is
questionable, but I guess it is just a matter of getting used to the new
facilities...
Thanks.
--
Dmitry
prev parent reply other threads:[~2023-12-01 23:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 12:08 [PATCH] Input: pxrc - simplify mutex handling with guard macro Marcus Folkesson
2023-12-01 13:29 ` Johan Hovold
2023-12-01 13:48 ` Marcus Folkesson
2023-12-01 14:03 ` Johan Hovold
2023-12-01 23:33 ` Dmitry Torokhov [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=ZWptRAQ0OoK7RpDu@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=johan@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcus.folkesson@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).