Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2671386ybl; Thu, 29 Aug 2019 11:15:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvjiKuwht24b0i61lgeBVXqLCMeDonizRPRdcfO63kNcAbHVq0hccT7ZzQ8gCpOHa0rEd0 X-Received: by 2002:a63:4846:: with SMTP id x6mr9635958pgk.332.1567102530466; Thu, 29 Aug 2019 11:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567102530; cv=none; d=google.com; s=arc-20160816; b=lGr4vItvY+sveZMcLV3m0SwHDMtu5S4LHHNX8PxwFN5vzzfT0e9KvAHX34j+R7OgU4 OUJLEdTwseX91IhqGtswOIjLTfrhNLBFiQz1CaI2LCXNKVJf6QBywbNjI3C7n4KNvnKF /T3kPeLrx3liar6IGsx2T8w5+jrC1vwUrlfhkQ3yvDZChN/lI2Qp9GbQDpStmGCwof15 HEwSEnyob2F55My4vTFqwuuwyWs3ZkmK0H/ck3Y7MoSQzySflCnZLWqPnWQ+/frhuxf8 dG8xYgp9W4U7Rd7EQ/N67BeWXukycr/My1zAgXc21ONoQ8/CLRq/dz2tZkusl6SDifGy yxIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ckwGcc6Gt7pG5U7BQtbgdU5CKnTLbxKeJcbAw3ueDIw=; b=BFPSC3QeUQCsJg1wINRanz3PbLLfaFD86b7e/XQYoIkPnxSlWzmBIn6mEZ+TNEMFS6 shV8WmiMRAXnjZeIwoAcLb/CZa/dmgmBq8q2cc1+jHS2FhUJrBI3cYEu1o8EmWYcAxcI kOCHMDJNpxf5fYna2dp7khVjgn/UJ3BpuUB2aDcl0BAmPSHrEGkRE/Pd/2uS++1yB4P6 EDHmtTRhHXz69YwXFwJMytZypVAUXNHiUMT/Q61oSitnSn0GLYBv2GK4OT8Obi3ojDXj SDqx1hDs3hcRKb9VtwE7r34RG9Ocj7kAilXgGNiVG3eNdde1FamXegEySJ7GF6hq/EA/ 2v0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Kg5/ZzHO"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b36si2456549pla.403.2019.08.29.11.15.14; Thu, 29 Aug 2019 11:15:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Kg5/ZzHO"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728637AbfH2SN4 (ORCPT + 99 others); Thu, 29 Aug 2019 14:13:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:55594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728571AbfH2SNv (ORCPT ); Thu, 29 Aug 2019 14:13:51 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3EB1F2189D; Thu, 29 Aug 2019 18:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102431; bh=0iVUGstZBn+OwfLZQ5q8c/fwqNEgVLv+IjmNObfZN5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kg5/ZzHOxpO9h3MSv/PqkI8mUIZrSWKR2SE1QOYthG1eHlEiZMSqoY6oXLVfPpgC9 h8cvLCIANZg0W9qAMtTLAmXJFzBzlaUdjU/dTk7CYQYvf01pY8eMOn1zbr2fLoTChH GRKrODpVlFm2JhlnyLolqq6Q7Ozw+uxgrICtVoQU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Fabian Henneke , Marcel Holtmann , Sasha Levin , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 20/76] Bluetooth: hidp: Let hidp_send_message return number of queued bytes Date: Thu, 29 Aug 2019 14:12:15 -0400 Message-Id: <20190829181311.7562-20-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fabian Henneke [ 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