diff mbox

HID: hiddev: change hiddev_connect() to return bool

Message ID 1444391696-1920-1-git-send-email-luisbg@osg.samsung.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Luis de Bethencourt Oct. 9, 2015, 11:54 a.m. UTC
Since hid_connect() only cares about hiddev_connect() succeeding or
failing, there is no need for this function to return an int and it can
return a bool instead.

Suggested-by: Jiri Kosina <jikos@kernel.org>
Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---

Hi,

The suggestion to change the return type of the function was made in:
https://lkml.org/lkml/2015/10/5/330

In relation to hiddev_connect() returning the wrong errno code.

Thanks,
Luis

 drivers/hid/hid-core.c      |  2 +-
 drivers/hid/usbhid/hiddev.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

kernel test robot Oct. 9, 2015, 12:12 p.m. UTC | #1
Hi Luis,

[auto build test ERROR on v4.3-rc4 -- if it's inappropriate base, please ignore]

config: x86_64-lkp (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> drivers/hid/usbhid/hiddev.c:878:6: error: conflicting types for 'hiddev_connect'
    bool hiddev_connect(struct hid_device *hid, unsigned int force)
         ^
   In file included from drivers/hid/usbhid/hiddev.c:35:0:
   include/linux/hiddev.h:41:5: note: previous declaration of 'hiddev_connect' was here
    int hiddev_connect(struct hid_device *hid, unsigned int force);
        ^

vim +/hiddev_connect +878 drivers/hid/usbhid/hiddev.c

   872		.minor_base =	HIDDEV_MINOR_BASE,
   873	};
   874	
   875	/*
   876	 * This is where hid.c calls us to connect a hid device to the hiddev driver
   877	 */
 > 878	bool hiddev_connect(struct hid_device *hid, unsigned int force)
   879	{
   880		struct hiddev *hiddev;
   881		struct usbhid_device *usbhid = hid->driver_data;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index efed99f..a8f3624 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1631,7 +1631,7 @@  int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 		hdev->claimed |= HID_CLAIMED_INPUT;
 
 	if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
-			!hdev->hiddev_connect(hdev,
+			hdev->hiddev_connect(hdev,
 				connect_mask & HID_CONNECT_HIDDEV_FORCE))
 		hdev->claimed |= HID_CLAIMED_HIDDEV;
 	if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev))
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 2f1ddca..d715632 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -875,7 +875,7 @@  static struct usb_class_driver hiddev_class = {
 /*
  * This is where hid.c calls us to connect a hid device to the hiddev driver
  */
-int hiddev_connect(struct hid_device *hid, unsigned int force)
+bool hiddev_connect(struct hid_device *hid, unsigned int force)
 {
 	struct hiddev *hiddev;
 	struct usbhid_device *usbhid = hid->driver_data;
@@ -890,11 +890,11 @@  int hiddev_connect(struct hid_device *hid, unsigned int force)
 				break;
 
 		if (i == hid->maxcollection)
-			return -1;
+			return false;
 	}
 
 	if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
-		return -1;
+		return false;
 
 	init_waitqueue_head(&hiddev->wait);
 	INIT_LIST_HEAD(&hiddev->list);
@@ -908,9 +908,9 @@  int hiddev_connect(struct hid_device *hid, unsigned int force)
 		hid_err(hid, "Not able to get a minor for this device\n");
 		hid->hiddev = NULL;
 		kfree(hiddev);
-		return -1;
+		return false;
 	}
-	return 0;
+	return true;
 }
 
 /*