Skip to content

Commit

Permalink
catfish: Add bluetooth_6lowpan
Browse files Browse the repository at this point in the history
This is intended to be a first step to implementing a generic data
transfer profile over Bluetooth as described here:
AsteroidOS/asteroid-btsyncd#22

Signed-off-by: Ed Beroset <beroset@ieee.org>
  • Loading branch information
beroset committed Oct 10, 2023
1 parent ab78cea commit 598e51f
Show file tree
Hide file tree
Showing 16 changed files with 715 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 2fda810cc01e25a24877dce1058885cf2dad6c7e Mon Sep 17 00:00:00 2001
From 20a37dcc4c1c2c071268790494153d9108aebebb Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dmueller@suse.com>
Date: Tue, 14 Jan 2020 18:53:41 +0100
Subject: [PATCH] scripts/dtc: Remove redundant YYLOC global declaration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 2627bcd9bdfb2769f20a64c88931839ae4284bac Mon Sep 17 00:00:00 2001
From d39d6394e0137c1002ce9b523cfc1f71cc7d4061 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Darrel=20Gri=C3=ABt?= <dgriet@gmail.com>
Date: Tue, 17 May 2022 22:20:45 +0200
Subject: [PATCH] usb: gadget: include gadget folder to fix compilation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 7d03a308da5c7b427edd641610aaf6feaa4c1663 Mon Sep 17 00:00:00 2001
From 5a2d129de462fd77a5fbeae91d128a935107ce70 Mon Sep 17 00:00:00 2001
From: MagneFire <IDaNLContact@gmail.com>
Date: Wed, 3 Nov 2021 12:42:48 +0100
Subject: [PATCH] char: bbd2.0: Fix include error.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From a79befbbde55d81301c459702e654d6b714c064c Mon Sep 17 00:00:00 2001
From 47059bf004d00ff4cbfaa3b29511b936413ca1a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Darrel=20Gri=C3=ABt?= <dgriet@gmail.com>
Date: Sun, 4 Sep 2022 17:08:45 +0200
Subject: [PATCH] Backport mainline 4.1 Bluetooth subsystem
Expand All @@ -7,6 +7,7 @@ Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Darrel Griët <dgriet@gmail.com>

---
drivers/bluetooth/hci_h4.c | 140 +-
drivers/bluetooth/hci_ldisc.c | 134 +-
Expand Down Expand Up @@ -31112,6 +31113,3 @@ index 86a683a8b491..6cf872563ea7 100644
+#endif
+
#endif /* __SMP_H */
--
2.36.1

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From c199fcff42cbc559de3418d3348e6841867c94ce Mon Sep 17 00:00:00 2001
From 20558045bef883b7fb1a5f695669ba04b28dabf8 Mon Sep 17 00:00:00 2001
From: MagneFire <IDaNLContact@gmail.com>
Date: Sun, 28 Nov 2021 21:29:31 +0100
Subject: [PATCH] Focaltech: Delay when sending wakeup event.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 3d7bc36e2cf0752e134e3cc9d10d027c1e8683b9 Mon Sep 17 00:00:00 2001
From 5eb31c2f94b00b4fff1e779fc4a64cde66f46cf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Darrel=20Gri=C3=ABt?= <dgriet@gmail.com>
Date: Sun, 13 Nov 2022 23:29:48 +0100
Subject: [PATCH] dts: msm8909w: Enable more GPU clock frequencies.
Expand All @@ -7,6 +7,7 @@ Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Darrel Griët <dgriet@gmail.com>

---
arch/arm/boot/dts/qcom/msm8909w-gpu.dtsi | 26 +++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
Expand Down Expand Up @@ -55,6 +56,3 @@ index ff2806d9bcd6..8a126fda3b69 100644
};

};
--
2.38.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 0798c68764dbfa7e0536e660736e6ee0733201f6 Mon Sep 17 00:00:00 2001
From: Ed Beroset <beroset@ieee.org>
Date: Fri, 6 Oct 2023 11:59:35 -0400
Subject: [PATCH] Add missing BT_6LOWPAN option to bluetooth Kconfig

This adds the BT_6LOWPAN option back in. It may have been deleted by
accident.

Signed-off-by: Ed Beroset <beroset@ieee.org>

---
net/bluetooth/Kconfig | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig
index 81f837f6d934..b8c794b87523 100644
--- a/net/bluetooth/Kconfig
+++ b/net/bluetooth/Kconfig
@@ -58,6 +58,12 @@ config BT_LE
depends on BT
default y

+config BT_6LOWPAN
+ tristate "Bluetooth 6LoWPAN support"
+ depends on BT_LE && 6LOWPAN
+ help
+ IPv6 compression over Bluetooth Low Energy.
+
config BT_SELFTEST
bool "Bluetooth self testing support"
depends on BT && DEBUG_KERNEL
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 0a8b03d82f56395807bad2af3da8d518a6272ccb Mon Sep 17 00:00:00 2001
From: Ed Beroset <beroset@ieee.org>
Date: Fri, 6 Oct 2023 12:08:29 -0400
Subject: [PATCH] Restore bluetooth_6lowpan to Makefile

I'm not sure why or how this was removed, but it's required for using
6lowpan over Bluetooth.

Signed-off-by: Ed Beroset <beroset@ieee.org>

---
net/bluetooth/Makefile | 3 +++
1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile
index c85a6afc6fe1..9a8ea232d28f 100644
--- a/net/bluetooth/Makefile
+++ b/net/bluetooth/Makefile
@@ -7,6 +7,9 @@ obj-$(CONFIG_BT_RFCOMM) += rfcomm/
obj-$(CONFIG_BT_BNEP) += bnep/
obj-$(CONFIG_BT_CMTP) += cmtp/
obj-$(CONFIG_BT_HIDP) += hidp/
+obj-$(CONFIG_BT_6LOWPAN) += bluetooth_6lowpan.o
+
+bluetooth_6lowpan-y := 6lowpan.o

bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \
hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From d5ef82215b6e08ec806ce9be4e3852fbae4370d5 Mon Sep 17 00:00:00 2001
From: Ed Beroset <beroset@ieee.org>
Date: Fri, 6 Oct 2023 21:04:29 -0400
Subject: [PATCH] Move const to the right location

This fixes a small bug in the code in which a duplicate const
declaration was apparently intended to be a const pointer to a const
location.

Signed-off-by: Ed Beroset <beroset@ieee.org>

---
include/linux/msm_mhi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/msm_mhi.h b/include/linux/msm_mhi.h
index 08dc3a23abfa..a5ffa23a32d0 100644
--- a/include/linux/msm_mhi.h
+++ b/include/linux/msm_mhi.h
@@ -107,7 +107,7 @@ struct mhi_cb_info {

struct mhi_client_info_t {
enum MHI_CLIENT_CHANNEL chan;
- const struct device const *dev;
+ const struct device * const dev;
const char *node_name;
void (*mhi_client_cb)(struct mhi_cb_info *);
bool pre_allocate;
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
From 1f625d36e52c2df876bfac4ec0267339411b32ee Mon Sep 17 00:00:00 2001
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Date: Wed, 6 Feb 2019 18:56:27 +0100
Subject: [PATCH] include/linux/module.h: copy __init/__exit attrs to
init/cleanup_module

The upcoming GCC 9 release extends the -Wmissing-attributes warnings
(enabled by -Wall) to C and aliases: it warns when particular function
attributes are missing in the aliases but not in their target.

In particular, it triggers for all the init/cleanup_module
aliases in the kernel (defined by the module_init/exit macros),
ending up being very noisy.

These aliases point to the __init/__exit functions of a module,
which are defined as __cold (among other attributes). However,
the aliases themselves do not have the __cold attribute.

Since the compiler behaves differently when compiling a __cold
function as well as when compiling paths leading to calls
to __cold functions, the warning is trying to point out
the possibly-forgotten attribute in the alias.

In order to keep the warning enabled, we decided to silence
this case. Ideally, we would mark the aliases directly
as __init/__exit. However, there are currently around 132 modules
in the kernel which are missing __init/__exit in their init/cleanup
functions (either because they are missing, or for other reasons,
e.g. the functions being called from somewhere else); and
a section mismatch is a hard error.

A conservative alternative was to mark the aliases as __cold only.
However, since we would like to eventually enforce __init/__exit
to be always marked, we chose to use the new __copy function
attribute (introduced by GCC 9 as well to deal with this).
With it, we copy the attributes used by the target functions
into the aliases. This way, functions that were not marked
as __init/__exit won't have their aliases marked either,
and therefore there won't be a section mismatch.

Note that the warning would go away marking either the extern
declaration, the definition, or both. However, we only mark
the definition of the alias, since we do not want callers
(which only see the declaration) to be compiled as if the function
was __cold (and therefore the paths leading to those calls
would be assumed to be unlikely).

Link: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/
Link: https://lore.kernel.org/lkml/20190206175627.GA20399@gmail.com/
Suggested-by: Martin Sebor <msebor@gcc.gnu.org>
Acked-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

Signed-off-by: Ed Beroset <beroset@ieee.org>

---
include/linux/init.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 28ec4d128413..d68791117bd9 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -331,13 +331,13 @@ void __init parse_early_options(char *cmdline);
#define module_init(initfn) \
static inline initcall_t __inittest(void) \
{ return initfn; } \
- int init_module(void) __attribute__((alias(#initfn)));
+ int init_module(void) __copy(initfn) __attribute__((alias(#initfn)));

/* This is only required if you want to be unloadable. */
#define module_exit(exitfn) \
static inline exitcall_t __exittest(void) \
{ return exitfn; } \
- void cleanup_module(void) __attribute__((alias(#exitfn)));
+ void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn)));

#define __setup_param(str, unique_id, fn) /* nothing */
#define __setup(str, func) /* nothing */
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
From 688a10561ed649dde940030f0d102f3c4698d781 Mon Sep 17 00:00:00 2001
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Date: Fri, 6 Oct 2023 22:27:17 -0400
Subject: [PATCH] Compiler Attributes: add support for __copy (gcc >= 9)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From the GCC manual:

copy
copy(function)

The copy attribute applies the set of attributes with which function
has been declared to the declaration of the function to which
the attribute is applied. The attribute is designed for libraries
that define aliases or function resolvers that are expected
to specify the same set of attributes as their targets. The copy
attribute can be used with functions, variables, or types. However,
the kind of symbol to which the attribute is applied (either
function or variable) must match the kind of symbol to which
the argument refers. The copy attribute copies only syntactic and
semantic attributes but not attributes that affect a symbol’s
linkage or visibility such as alias, visibility, or weak.
The deprecated attribute is also not copied.

https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

The upcoming GCC 9 release extends the -Wmissing-attributes warnings
(enabled by -Wall) to C and aliases: it warns when particular function
attributes are missing in the aliases but not in their target, e.g.:

void __cold f(void) {}
void __alias("f") g(void);

diagnoses:

warning: 'g' specifies less restrictive attribute than
its target 'f': 'cold' [-Wmissing-attributes]

Using __copy(f) we can copy the __cold attribute from f to g:

void __cold f(void) {}
void __copy(f) __alias("f") g(void);

This attribute is most useful to deal with situations where an alias
is declared but we don't know the exact attributes the target has.

For instance, in the kernel, the widely used module_init/exit macros
define the init/cleanup_module aliases, but those cannot be marked
always as __init/__exit since some modules do not have their
functions marked as such.

Suggested-by: Martin Sebor <msebor@gcc.gnu.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

Link: https://github.com/torvalds/linux/commit/c0d9782f5b6d7157635ae2fd782a4b27d55a6013
Link: https://github.com/ojeda/linux/commit/8803fd49f7f86efa39b60957c74ccf98690ae2ab

Signed-off-by: Ed Beroset <beroset@ieee.org>

---
include/linux/compiler.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 4c981adac770..682e8c0a95e5 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -50,6 +50,29 @@ extern void __chk_io_ptr(const volatile void __iomem *);

#ifdef __KERNEL__

+/*
+ * Minimal backport of compiler_attributes.h to add support for __copy
+ * to v4.9.y so that we can use it in init/exit_module to avoid
+ * -Werror=missing-attributes errors on GCC 9.
+ */
+#ifndef __has_attribute
+# define __has_attribute(x) __GCC4_has_attribute_##x
+# define __GCC4_has_attribute___copy__ 0
+#endif
+
+/*
+ * Optional: only supported since gcc >= 9
+ * Optional: not supported by clang
+ * Optional: not supported by icc
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-copy-function-attribute
+ */
+#if __has_attribute(__copy__)
+# define __copy(symbol) __attribute__((__copy__(symbol)))
+#else
+# define __copy(symbol)
+#endif
+
#ifdef __GNUC__
#include <linux/compiler-gcc.h>
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
From d4cee5cd8f9f9b18be074fa8b6e3a6b10bca7c05 Mon Sep 17 00:00:00 2001
From: Ed Beroset <beroset@ieee.org>
Date: Sat, 7 Oct 2023 11:42:34 -0400
Subject: [PATCH] Fix alignment of struct members

With newer versions (>9) of gcc, the compiler correctly warns that
"taking address of packed member of 'struct diag_mempool_t' may result
in an unaligned pointer value [-Waddress-of-packed-member]."

A similar warning comes up for dci_pkt_req_entry_t.

This removes the __packed attribute from both structs to address that
problem.

Signed-off-by: Ed Beroset <beroset@ieee.org>

---
drivers/char/diag/diag_dci.h | 4 ++--
drivers/char/diag/diagmem.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/diag/diag_dci.h b/drivers/char/diag/diag_dci.h
index a9e2d35cc50a..bf988c5fff23 100644
--- a/drivers/char/diag/diag_dci.h
+++ b/drivers/char/diag/diag_dci.h
@@ -95,7 +95,7 @@ struct dci_pkt_req_entry_t {
int uid;
int tag;
struct list_head track;
-} __packed;
+};

struct diag_dci_reg_tbl_t {
int client_id;
@@ -164,7 +164,7 @@ struct diag_dci_health_stats_proc {
int client_id;
struct diag_dci_health_stats health;
int proc;
-} __packed;
+};

struct diag_dci_peripherals_t {
int proc;
diff --git a/drivers/char/diag/diagmem.h b/drivers/char/diag/diagmem.h
index d097a3799e9a..77ef3003559e 100644
--- a/drivers/char/diag/diagmem.h
+++ b/drivers/char/diag/diagmem.h
@@ -50,7 +50,7 @@ struct diag_mempool_t {
unsigned int poolsize;
int count;
spinlock_t lock;
-} __packed;
+};

extern struct diag_mempool_t diag_mempools[NUM_MEMORY_POOLS];

Loading

0 comments on commit 598e51f

Please sign in to comment.