Thread (5 messages) flat view 5 messages, 3 authors, 2021-07-27

Re: [PATCH] Bluetooth: use helper function for monitor's open/close notifications

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2021-07-26 21:26:17

Hi Tetsuo,

On Mon, Jul 26, 2021 at 1:40 PM Tetsuo Handa
[off-list ref] wrote:
On 2021/07/27 2:40, Luiz Augusto von Dentz wrote:
quoted
quoted
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 786a06a232fd..fc2336855dab 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -295,6 +295,11 @@ void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
        read_unlock(&hci_sk_list.lock);
 }

+static void __hci_send_to_monitor(struct sk_buff *skb)
+{
We can probably have the checks of NULL skb added directly here and
perhaps kfree_skb as well since it seems it is always a copy that is
sent here,
The NULL skb check is in hci_monitor_ctrl_open() and hci_monitor_ctrl_close().
The purpose of __hci_send_to_monitor() is to hide common arguments.
All instances that call into it do seem to have the NULL check and
kfree, in fact hci_monitor_ctrl_open and hci_monitor_ctrl_close do
exactly the same thing:

+       if (skb) {
+               __hci_send_to_monitor(skb);
+               kfree_skb(skb);
+       }

Perhap we can call it hci_send_ctrl_to_monitor:

static void hci_send_ctrl_to_monitor(struct sk_buff *skb)
{
       if (!skb)
           return;

       hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, HCI_SOCK_TRUSTED, NULL);

       kfree_skb(skb);
}
quoted
           the hci_send_to_monitor don't have __ prefix so I wonder
why you have chosen to use it?
Only to avoid name conflict with hci_send_to_monitor(). I thought that
the __ prefix is fine because hci_send_to_monitor() also calls this function.
Please suggest whatever name you want to use.
quoted
quoted
+       hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, HCI_SOCK_TRUSTED, NULL);
+}
+
 /* Send frame to monitor socket */
 void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb)
 {

-- 
Luiz Augusto von Dentz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help