linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: usbhid: Use pr_<level> and remove unnecessary OOM messages
@ 2017-03-02  1:35 Joe Perches
  2017-03-06  9:50 ` Benjamin Tissoires
  2017-03-06 13:40 ` Jiri Kosina
  0 siblings, 2 replies; 3+ messages in thread
From: Joe Perches @ 2017-03-02  1:35 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires; +Cc: linux-usb, linux-input, linux-kernel

Use a more common logging style and remove the unnecessary
OOM messages as there is default dump_stack when OOM.

Miscellanea:

o Hoist an assignment in an if
o Realign arguments
o Realign a deeply indented if descendent above a printk

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/hid/usbhid/hid-core.c   | 16 +++++++---------
 drivers/hid/usbhid/hid-quirks.c | 11 ++++-------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 961bc6fdd2d9..cd98db6cf94f 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1004,10 +1004,9 @@ static int usbhid_parse(struct hid_device *hid)
 		return -EINVAL;
 	}
 
-	if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) {
-		dbg_hid("couldn't allocate rdesc memory\n");
+	rdesc = kmalloc(rsize, GFP_KERNEL);
+	if (!rdesc)
 		return -ENOMEM;
-	}
 
 	hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);
 
@@ -1077,8 +1076,8 @@ static int usbhid_start(struct hid_device *hid)
 		if (hid->quirks & HID_QUIRK_FULLSPEED_INTERVAL &&
 		    dev->speed == USB_SPEED_HIGH) {
 			interval = fls(endpoint->bInterval*8);
-			printk(KERN_INFO "%s: Fixing fullspeed to highspeed interval: %d -> %d\n",
-			       hid->name, endpoint->bInterval, interval);
+			pr_info("%s: Fixing fullspeed to highspeed interval: %d -> %d\n",
+				hid->name, endpoint->bInterval, interval);
 		}
 
 		/* Change the polling interval of mice. */
@@ -1456,10 +1455,9 @@ static int hid_post_reset(struct usb_interface *intf)
 	 * the size of the HID report descriptor has not changed.
 	 */
 	rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL);
-	if (!rdesc) {
-		dbg_hid("couldn't allocate rdesc memory (post_reset)\n");
+	if (!rdesc)
 		return -ENOMEM;
-	}
+
 	status = hid_get_class_descriptor(dev,
 				interface->desc.bInterfaceNumber,
 				HID_DT_REPORT, rdesc, hid->dev_rsize);
@@ -1637,7 +1635,7 @@ static int __init hid_init(void)
 	retval = usb_register(&hid_driver);
 	if (retval)
 		goto usb_register_fail;
-	printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
+	pr_info(KBUILD_MODNAME ": " DRIVER_DESC "\n");
 
 	return 0;
 usb_register_fail:
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index d6847a664446..9287ab03e117 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -237,10 +237,8 @@ static int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct,
 	}
 
 	q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL);
-	if (!q_new) {
-		dbg_hid("Could not allocate quirks_list_struct\n");
+	if (!q_new)
 		return -ENOMEM;
-	}
 
 	q_new->hid_bl_item.idVendor = idVendor;
 	q_new->hid_bl_item.idProduct = idProduct;
@@ -306,10 +304,9 @@ int usbhid_quirks_init(char **quirks_param)
 				&idVendor, &idProduct, &quirks);
 
 		if (m != 3 ||
-				usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) {
-			printk(KERN_WARNING
-					"Could not parse HID quirk module param %s\n",
-					quirks_param[n]);
+		    usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) {
+			pr_warn("Could not parse HID quirk module param %s\n",
+				quirks_param[n]);
 		}
 	}
 
-- 
2.10.0.rc2.1.g053435c

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

* Re: [PATCH] HID: usbhid: Use pr_<level> and remove unnecessary OOM messages
  2017-03-02  1:35 [PATCH] HID: usbhid: Use pr_<level> and remove unnecessary OOM messages Joe Perches
@ 2017-03-06  9:50 ` Benjamin Tissoires
  2017-03-06 13:40 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Tissoires @ 2017-03-06  9:50 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jiri Kosina, linux-usb, linux-input, linux-kernel

On Mar 01 2017 or thereabouts, Joe Perches wrote:
> Use a more common logging style and remove the unnecessary
> OOM messages as there is default dump_stack when OOM.
> 
> Miscellanea:
> 
> o Hoist an assignment in an if
> o Realign arguments
> o Realign a deeply indented if descendent above a printk
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Looks good to me:
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

> ---
>  drivers/hid/usbhid/hid-core.c   | 16 +++++++---------
>  drivers/hid/usbhid/hid-quirks.c | 11 ++++-------
>  2 files changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
> index 961bc6fdd2d9..cd98db6cf94f 100644
> --- a/drivers/hid/usbhid/hid-core.c
> +++ b/drivers/hid/usbhid/hid-core.c
> @@ -1004,10 +1004,9 @@ static int usbhid_parse(struct hid_device *hid)
>  		return -EINVAL;
>  	}
>  
> -	if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) {
> -		dbg_hid("couldn't allocate rdesc memory\n");
> +	rdesc = kmalloc(rsize, GFP_KERNEL);
> +	if (!rdesc)
>  		return -ENOMEM;
> -	}
>  
>  	hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);
>  
> @@ -1077,8 +1076,8 @@ static int usbhid_start(struct hid_device *hid)
>  		if (hid->quirks & HID_QUIRK_FULLSPEED_INTERVAL &&
>  		    dev->speed == USB_SPEED_HIGH) {
>  			interval = fls(endpoint->bInterval*8);
> -			printk(KERN_INFO "%s: Fixing fullspeed to highspeed interval: %d -> %d\n",
> -			       hid->name, endpoint->bInterval, interval);
> +			pr_info("%s: Fixing fullspeed to highspeed interval: %d -> %d\n",
> +				hid->name, endpoint->bInterval, interval);
>  		}
>  
>  		/* Change the polling interval of mice. */
> @@ -1456,10 +1455,9 @@ static int hid_post_reset(struct usb_interface *intf)
>  	 * the size of the HID report descriptor has not changed.
>  	 */
>  	rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL);
> -	if (!rdesc) {
> -		dbg_hid("couldn't allocate rdesc memory (post_reset)\n");
> +	if (!rdesc)
>  		return -ENOMEM;
> -	}
> +
>  	status = hid_get_class_descriptor(dev,
>  				interface->desc.bInterfaceNumber,
>  				HID_DT_REPORT, rdesc, hid->dev_rsize);
> @@ -1637,7 +1635,7 @@ static int __init hid_init(void)
>  	retval = usb_register(&hid_driver);
>  	if (retval)
>  		goto usb_register_fail;
> -	printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
> +	pr_info(KBUILD_MODNAME ": " DRIVER_DESC "\n");
>  
>  	return 0;
>  usb_register_fail:
> diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
> index d6847a664446..9287ab03e117 100644
> --- a/drivers/hid/usbhid/hid-quirks.c
> +++ b/drivers/hid/usbhid/hid-quirks.c
> @@ -237,10 +237,8 @@ static int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct,
>  	}
>  
>  	q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL);
> -	if (!q_new) {
> -		dbg_hid("Could not allocate quirks_list_struct\n");
> +	if (!q_new)
>  		return -ENOMEM;
> -	}
>  
>  	q_new->hid_bl_item.idVendor = idVendor;
>  	q_new->hid_bl_item.idProduct = idProduct;
> @@ -306,10 +304,9 @@ int usbhid_quirks_init(char **quirks_param)
>  				&idVendor, &idProduct, &quirks);
>  
>  		if (m != 3 ||
> -				usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) {
> -			printk(KERN_WARNING
> -					"Could not parse HID quirk module param %s\n",
> -					quirks_param[n]);
> +		    usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) {
> +			pr_warn("Could not parse HID quirk module param %s\n",
> +				quirks_param[n]);
>  		}
>  	}
>  
> -- 
> 2.10.0.rc2.1.g053435c
> 

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

* Re: [PATCH] HID: usbhid: Use pr_<level> and remove unnecessary OOM messages
  2017-03-02  1:35 [PATCH] HID: usbhid: Use pr_<level> and remove unnecessary OOM messages Joe Perches
  2017-03-06  9:50 ` Benjamin Tissoires
@ 2017-03-06 13:40 ` Jiri Kosina
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2017-03-06 13:40 UTC (permalink / raw)
  To: Joe Perches; +Cc: Benjamin Tissoires, linux-usb, linux-input, linux-kernel

On Wed, 1 Mar 2017, Joe Perches wrote:

> Use a more common logging style and remove the unnecessary
> OOM messages as there is default dump_stack when OOM.
> 
> Miscellanea:
> 
> o Hoist an assignment in an if
> o Realign arguments
> o Realign a deeply indented if descendent above a printk
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied to for-4.12/upstream. Thanks,

-- 
Jiri Kosina
SUSE Labs

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

end of thread, other threads:[~2017-03-06 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-02  1:35 [PATCH] HID: usbhid: Use pr_<level> and remove unnecessary OOM messages Joe Perches
2017-03-06  9:50 ` Benjamin Tissoires
2017-03-06 13:40 ` Jiri Kosina

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