Commit 787b306c authored by Johannes Berg's avatar Johannes Berg Committed by Marcel Holtmann

Bluetooth: avoid rebuilding hci_sock all the time

Instead, allow using string formatting with send_monitor_note()
and access init_utsname().
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 78b781ca
...@@ -25,9 +25,8 @@ ...@@ -25,9 +25,8 @@
/* Bluetooth HCI sockets. */ /* Bluetooth HCI sockets. */
#include <linux/export.h> #include <linux/export.h>
#include <linux/utsname.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <generated/compile.h>
#include <generated/utsrelease.h>
#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h> #include <net/bluetooth/hci_core.h>
...@@ -385,17 +384,26 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) ...@@ -385,17 +384,26 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event)
return skb; return skb;
} }
static void send_monitor_note(struct sock *sk, const char *text) static void __printf(2, 3)
send_monitor_note(struct sock *sk, const char *fmt, ...)
{ {
size_t len = strlen(text); size_t len;
struct hci_mon_hdr *hdr; struct hci_mon_hdr *hdr;
struct sk_buff *skb; struct sk_buff *skb;
va_list args;
va_start(args, fmt);
len = vsnprintf(NULL, 0, fmt, args);
va_end(args);
skb = bt_skb_alloc(len + 1, GFP_ATOMIC); skb = bt_skb_alloc(len + 1, GFP_ATOMIC);
if (!skb) if (!skb)
return; return;
strcpy(skb_put(skb, len + 1), text); va_start(args, fmt);
vsprintf(skb_put(skb, len), fmt, args);
*skb_put(skb, 1) = 0;
va_end(args);
__net_timestamp(skb); __net_timestamp(skb);
...@@ -897,9 +905,10 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, ...@@ -897,9 +905,10 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
*/ */
hci_sock_set_flag(sk, HCI_SOCK_TRUSTED); hci_sock_set_flag(sk, HCI_SOCK_TRUSTED);
send_monitor_note(sk, "Linux version " UTS_RELEASE send_monitor_note(sk, "Linux version %s (%s)",
" (" UTS_MACHINE ")"); init_utsname()->release,
send_monitor_note(sk, "Bluetooth subsystem version " init_utsname()->machine);
send_monitor_note(sk, "Bluetooth subsystem version %s",
BT_SUBSYS_VERSION); BT_SUBSYS_VERSION);
send_monitor_replay(sk); send_monitor_replay(sk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment