[PATCH 12/74] backports: adjust namespace argument const

Johannes Berg <[email protected]> Fri, 24 May 2024 19:07:24 +0200
Newsgroups org.kernel.vger.backports
Message-ID <20240524190906.2fce117fbf36.Iedd62c5e3204ee9d1ba2b370a930d19409d7ef37@changeid>
From: Gregory Greenman <[email protected]>

Signed-off-by: Gregory Greenman <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
---
 backport/backport-include/linux/device.h |  6 ++++++
 patches/0108-namespace-arg-const.cocci   | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 patches/0108-namespace-arg-const.cocci

diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h
index 46f2190b06c4..1e5a5534340e 100644
--- a/backport/backport-include/linux/device.h
+++ b/backport/backport-include/linux/device.h
@@ -7,4 +7,10 @@
 	struct device_attribute dev_attr_##_name = __ATTR_RW_MODE(_name, 0600)
 #endif
 
+#if LINUX_VERSION_IS_LESS(6,2,0)
+#define __ns_const
+#else
+#define __ns_const const
+#endif
+
 #endif /* __BACKPORT_DEVICE_H_ */
diff --git a/patches/0108-namespace-arg-const.cocci b/patches/0108-namespace-arg-const.cocci
new file mode 100644
index 000000000000..a03f32c0010e
--- /dev/null
+++ b/patches/0108-namespace-arg-const.cocci
@@ -0,0 +1,20 @@
+@ns@
+identifier cls, fn;
+identifier __class =~ "class";
+@@
+struct __class cls  = {
+	.namespace = fn,
+	...
+};
+
+@@
+identifier ns.fn, d;
+attribute name __ns_const;
+@@
+fn(
+-const struct device *d
++__ns_const struct device *d
+ )
+{
+	...
+}
-- 
2.45.1