linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hidp: Let hidp_send_message return number of queued bytes
@ 2019-07-15 17:40 Fabian Henneke
  2019-07-15 19:37 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Fabian Henneke @ 2019-07-15 17:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, johan.hedberg

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 <fabian.henneke@gmail.com>
---
 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 a442e21f3894..69af11f98e4a 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hidp: Let hidp_send_message return number of queued bytes
  2019-07-15 17:40 [PATCH] hidp: Let hidp_send_message return number of queued bytes Fabian Henneke
@ 2019-07-15 19:37 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2019-07-15 19:37 UTC (permalink / raw)
  To: Fabian Henneke; +Cc: linux-bluetooth, Johan Hedberg

Hi Fabian,

> 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 <fabian.henneke@gmail.com>
> ---
> net/bluetooth/hidp/core.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-15 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15 17:40 [PATCH] hidp: Let hidp_send_message return number of queued bytes Fabian Henneke
2019-07-15 19:37 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).