Skip to content

Commit

Permalink
HID: usbhid: Use pr_<level> and remove unnecessary OOM messages
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Joe Perches authored and Jiri Kosina committed Mar 6, 2017
1 parent 933bfe4 commit 52150c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
16 changes: 7 additions & 9 deletions drivers/hid/usbhid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,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);

Expand Down Expand Up @@ -1081,8 +1080,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 and joysticks. */
Expand Down Expand Up @@ -1468,10 +1467,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);
Expand Down Expand Up @@ -1649,7 +1647,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:
Expand Down
11 changes: 4 additions & 7 deletions drivers/hid/usbhid/hid-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
}
}

Expand Down

0 comments on commit 52150c7

Please sign in to comment.