From patchwork Fri Oct 9 11:54:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis de Bethencourt X-Patchwork-Id: 7361071 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 103DF9F32B for ; Fri, 9 Oct 2015 11:55:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 377282088E for ; Fri, 9 Oct 2015 11:55:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58B912084C for ; Fri, 9 Oct 2015 11:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757944AbbJILzG (ORCPT ); Fri, 9 Oct 2015 07:55:06 -0400 Received: from lists.s-osg.org ([54.187.51.154]:48017 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757905AbbJILzF (ORCPT ); Fri, 9 Oct 2015 07:55:05 -0400 Received: from snow.theccd.local (unknown [89.101.192.72]) by lists.s-osg.org (Postfix) with ESMTPSA id 8C66D462A0; Fri, 9 Oct 2015 04:55:02 -0700 (PDT) From: Luis de Bethencourt To: linux-kernel@vger.kernel.org Cc: jikos@kernel.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org, Luis de Bethencourt Subject: [PATCH] HID: hiddev: change hiddev_connect() to return bool Date: Fri, 9 Oct 2015 12:54:56 +0100 Message-Id: <1444391696-1920-1-git-send-email-luisbg@osg.samsung.com> X-Mailer: git-send-email 2.5.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Luis de Bethencourt --- 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(-) 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; } /*