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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tetsuo,

On Mon, Jul 26, 2021 at 1:40 PM Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On 2021/07/27 2:40, Luiz Augusto von Dentz wrote:
> >> 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);
}

>
> >            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.
>
> >
> >> +       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



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux