public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-usb@vger.kernel.org, kernel-janitors@vger.kernel.org
Cc: "Alan Stern" <stern@rowland.harvard.edu>,
	"Eugene Korenevsky" <ekorenevsky@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Günter Röck" <linux@roeck-us.net>,
	"Jaejoong Kim" <climbbb.kim@gmail.com>,
	"Johan Hovold" <johan@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Mathias Nyman" <mathias.nyman@linux.intel.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] USB: core: Improve unlocking of a mutex in two functions
Date: Sun, 05 Nov 2017 08:29:22 +0000	[thread overview]
Message-ID: <1923596b-ce14-7b80-6148-f67143b4a367@users.sourceforge.net> (raw)
In-Reply-To: <CAMuHMdUXn4YVPBFCoqmwcdU7eTWO5jy2ZXZQaAxPi1P5bM4q2A@mail.gmail.com>

>> @@ -5529,8 +5528,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
>>                 dev_err(&udev->dev,
>>                         "can't restore configuration #%d (error=%d)\n",
>>                         udev->actconfig->desc.bConfigurationValue, ret);
>> -               mutex_unlock(hcd->bandwidth_mutex);
>> -               goto re_enumerate;
>> +               goto unlock;
>>         }
>>         mutex_unlock(hcd->bandwidth_mutex);
>>         usb_set_device_state(udev, USB_STATE_CONFIGURED);
>> @@ -5583,6 +5581,8 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
>>         udev->bos = bos;
>>         return 0;
>>
>> +unlock:
>> +       mutex_unlock(hcd->bandwidth_mutex);
> 
> This makes it harder for the reader,

I am curious if the view on the preferred code readability can be clarified further.


> as the mutex_unlock() is now far below the block
> of code that's protected by the lock.

I got an other software development opinion for this aspect.
Can the label be clear enough about the shown purpose already?

Regards,
Markus

      parent reply	other threads:[~2017-11-05  8:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-04 20:12 [PATCH] USB: core: Improve unlocking of a mutex in two functions SF Markus Elfring
2017-11-04 23:25 ` Geert Uytterhoeven
2017-11-05  7:30   ` Greg Kroah-Hartman
2017-11-05  9:33     ` SF Markus Elfring
2017-11-05  8:29   ` SF Markus Elfring [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=1923596b-ce14-7b80-6148-f67143b4a367@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=climbbb.kim@gmail.com \
    --cc=corbet@lwn.net \
    --cc=ekorenevsky@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mchehab@kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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