linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: quirks: simplify quirk handling.
@ 2020-09-21 11:30 Pavel Machek
  2020-09-21 11:38 ` Greg KH
  2020-09-23 16:28 ` Kars Mulder
  0 siblings, 2 replies; 5+ messages in thread
From: Pavel Machek @ 2020-09-21 11:30 UTC (permalink / raw)
  To: gregkh, stern, kai.heng.feng, johan, tomasz, jonathan, kerneldev,
	linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]

Simplify quirk handling.

Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>

diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index f232914de5fd..167b6ac428a3 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -56,18 +56,13 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
 		if (val[i] == ',')
 			quirk_count++;
 
-	if (quirk_list) {
-		kfree(quirk_list);
-		quirk_list = NULL;
-	}
-
+	kfree(quirk_list);
 	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
 			     GFP_KERNEL);
 	if (!quirk_list) {
 		quirk_count = 0;
-		mutex_unlock(&quirk_mutex);
-		kfree(val);
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto unlock;
 	}
 
 	for (i = 0, p = val; p && *p;) {
@@ -153,7 +148,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
 	mutex_unlock(&quirk_mutex);
 	kfree(val);
 
-	return 0;
+	return err;
 }
 
 static const struct kernel_param_ops quirks_param_ops = {

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: quirks: simplify quirk handling.
  2020-09-21 11:30 [PATCH] USB: quirks: simplify quirk handling Pavel Machek
@ 2020-09-21 11:38 ` Greg KH
  2020-09-21 11:47   ` Pavel Machek
  2020-09-23 16:28 ` Kars Mulder
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2020-09-21 11:38 UTC (permalink / raw)
  To: Pavel Machek
  Cc: stern, kai.heng.feng, johan, tomasz, jonathan, kerneldev,
	linux-usb, linux-kernel

On Mon, Sep 21, 2020 at 01:30:39PM +0200, Pavel Machek wrote:
> Simplify quirk handling.

In what way?

Please be more descriptive in your changelog and resend.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: quirks: simplify quirk handling.
  2020-09-21 11:38 ` Greg KH
@ 2020-09-21 11:47   ` Pavel Machek
  2020-09-21 11:52     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2020-09-21 11:47 UTC (permalink / raw)
  To: Greg KH
  Cc: Pavel Machek, stern, kai.heng.feng, johan, tomasz, jonathan,
	kerneldev, linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

On Mon 2020-09-21 13:38:00, Greg KH wrote:
> On Mon, Sep 21, 2020 at 01:30:39PM +0200, Pavel Machek wrote:
> > Simplify quirk handling.
> 
> In what way?
> 
> Please be more descriptive in your changelog and resend.

Have you looked at the patch below? Please apply the patch. You are
free to edit the changelog if you feel the need.

								Pavel
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: quirks: simplify quirk handling.
  2020-09-21 11:47   ` Pavel Machek
@ 2020-09-21 11:52     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2020-09-21 11:52 UTC (permalink / raw)
  To: Pavel Machek
  Cc: stern, kai.heng.feng, johan, tomasz, jonathan, kerneldev,
	linux-usb, linux-kernel

On Mon, Sep 21, 2020 at 01:47:29PM +0200, Pavel Machek wrote:
> On Mon 2020-09-21 13:38:00, Greg KH wrote:
> > On Mon, Sep 21, 2020 at 01:30:39PM +0200, Pavel Machek wrote:
> > > Simplify quirk handling.
> > 
> > In what way?
> > 
> > Please be more descriptive in your changelog and resend.
> 
> Have you looked at the patch below? Please apply the patch. You are
> free to edit the changelog if you feel the need.

I am also free to ignore patches with changelogs that do not say
anything of consequence, which I will do here.

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] USB: quirks: simplify quirk handling.
  2020-09-21 11:30 [PATCH] USB: quirks: simplify quirk handling Pavel Machek
  2020-09-21 11:38 ` Greg KH
@ 2020-09-23 16:28 ` Kars Mulder
  1 sibling, 0 replies; 5+ messages in thread
From: Kars Mulder @ 2020-09-23 16:28 UTC (permalink / raw)
  To: Pavel Machek
  Cc: gregkh, stern, kai.heng.feng, johan, tomasz, jonathan, linux-usb,
	linux-kernel

On Monday, September 21, 2020 13:30 CEST, Pavel Machek <pavel@denx.de> wrote: 
> Simplify quirk handling.

This patch seems to contain two different "simplifications" in one.
I have no objections against the first simplification:

-	if (quirk_list) {
-		kfree(quirk_list);
-		quirk_list = NULL;
-	}
-
+	kfree(quirk_list);
 	quirk_list = kcalloc(quirk_count, sizeof(struct quirk_entry),
 			     GFP_KERNEL);

Since kfree() does nothing to nullpointers, all lines that are cut seem
to be superfluous.

The second simplification does not seem to introduce any new bugs as far
as I can tell. Due to lack of experience, I shall refrain from commenting
on whether or not it simplifies things.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-23 16:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 11:30 [PATCH] USB: quirks: simplify quirk handling Pavel Machek
2020-09-21 11:38 ` Greg KH
2020-09-21 11:47   ` Pavel Machek
2020-09-21 11:52     ` Greg KH
2020-09-23 16:28 ` Kars Mulder

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).