From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3F98C4332F for ; Sun, 8 Sep 2019 12:46:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE9C2218AF for ; Sun, 8 Sep 2019 12:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946768; bh=Tk8dIqRke1IbYjoHn69l7nfqUpiVrAjm93Y2qhs4iEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=HV+DkUDihFw4KlDwVpUfoZbLNV8BaReTXgTl8uKXnU0tZ8KselaYKKdKPgSgURoaJ FXoWhKWzfDsVSoHIDH8aMXcwrNq5NDokstk+VhO2Uf578zEyCYwVB7vrSEwW/DTWKC +56cxX9iOw+AgNWvpPBYeILvUE3A43U2EuabjHKI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730290AbfIHMqH (ORCPT ); Sun, 8 Sep 2019 08:46:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:33558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729546AbfIHMqG (ORCPT ); Sun, 8 Sep 2019 08:46:06 -0400 Received: from localhost (unknown [62.28.240.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D0FB6218AF; Sun, 8 Sep 2019 12:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946766; bh=Tk8dIqRke1IbYjoHn69l7nfqUpiVrAjm93Y2qhs4iEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sHNmXYtlkXIcklvft5B3/GW6uSryojaijvizssE9t8AKXRw5GOaFILg3I1qBNaCo2 y8hKXXAC0kpmGebbzvLomwQ5sLbwFXYRb72ZJvF2cdwIdbKDvwSJEEQ1G81HGkBshD IorQY1OvNaev7UkDXf825jKM3DMtbhKvn0UPD40k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabian Henneke , Marcel Holtmann , Sasha Levin Subject: [PATCH 4.14 05/40] Bluetooth: hidp: Let hidp_send_message return number of queued bytes Date: Sun, 8 Sep 2019 13:41:38 +0100 Message-Id: <20190908121115.759608557@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121114.260662089@linuxfoundation.org> References: <20190908121114.260662089@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 48d9cc9d85dde37c87abb7ac9bbec6598ba44b56 ] Let hidp_send_message return the number of successfully queued bytes instead of an unconditional 0. With the return value fixed to 0, other drivers relying on hidp, such as hidraw, can not return meaningful values from their respective implementations of write(). In particular, with the current behavior, a hidraw device's write() will have different return values depending on whether the device is connected via USB or Bluetooth, which makes it harder to abstract away the transport layer. Signed-off-by: Fabian Henneke Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- net/bluetooth/hidp/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index b21fcc838784d..f6bffb3a95116 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -101,6 +101,7 @@ static int hidp_send_message(struct hidp_session *session, struct socket *sock, { struct sk_buff *skb; struct sock *sk = sock->sk; + int ret; BT_DBG("session %p data %p size %d", session, data, size); @@ -114,13 +115,17 @@ static int hidp_send_message(struct hidp_session *session, struct socket *sock, } skb_put_u8(skb, hdr); - if (data && size > 0) + if (data && size > 0) { skb_put_data(skb, data, size); + ret = size; + } else { + ret = 0; + } skb_queue_tail(transmit, skb); wake_up_interruptible(sk_sleep(sk)); - return 0; + return ret; } static int hidp_send_ctrl_message(struct hidp_session *session, -- 2.20.1