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 F3FEBC4332F for ; Sun, 8 Sep 2019 12:50:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC3FD21A49 for ; Sun, 8 Sep 2019 12:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947045; bh=BDvf22p4KU00IGDfpcqeWyUuwRPJWPNJhTSf+CQatsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=I5Jz2L0AFbLHplo46RtCbSqReyekEaFGBnqnJ3QYkMliz82HHN8qr7MF10flwvR/b 4raUEzDZKaGvN0k7XfBiO9PCHnPM/ezSB5CGiCHwLf1/qyAYeJhqWOCK5gfjJTIki4 M9wJMgPiC3h+pbWVvcoJ6eZTjYP/PkyuxIOMy4q8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732248AbfIHMuo (ORCPT ); Sun, 8 Sep 2019 08:50:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:41742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732231AbfIHMun (ORCPT ); Sun, 8 Sep 2019 08:50:43 -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 84C50218AC; Sun, 8 Sep 2019 12:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947043; bh=BDvf22p4KU00IGDfpcqeWyUuwRPJWPNJhTSf+CQatsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AOC367zIpjMKNU3eNJch4iK+TroVHLJxtQvdsiCKYoZiqKj6gACqI7oC9jEK92KoI i4VKXa/zXIhmMWR0knZId+yUSQTi4p4lcwlnNc6HTQyGj9WXQgzguBhFa+JsPvzsPC sz4WcV+YIO/qMw0LhylXxcIfhRvPnRo48gz+Or64= 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 5.2 38/94] Bluetooth: hidp: Let hidp_send_message return number of queued bytes Date: Sun, 8 Sep 2019 13:41:34 +0100 Message-Id: <20190908121151.529315142@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121150.420989666@linuxfoundation.org> References: <20190908121150.420989666@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 5abd423b55fa9..8d889969ae7ed 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