kumquat-buildroot/package/dahdi-linux/0005-Fix-build-on-Linux-6.3.patch
Bernd Kuhls 353c06849b package/dahdi-linux: fix build with kernel < 6.3
Buildroot commit 840b552746 added a patch
from upstream bug tracker which fixes build with kernel >= 6.3 but broke
the build with earlier kernels.

This patch adds additional code for compatibility with kernel < 6.3.

Fixes:
http://autobuild.buildroot.net/results/c8c/c8c51153d3a61842d57a2a4be3dc75ec9964e41c/

Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-07-10 18:13:38 +02:00

117 lines
4.5 KiB
Diff

From c4969d756eac041758856b99a1084158c06beb7e Mon Sep 17 00:00:00 2001
From: Brahmajit Das <brahmajit.xyz@gmail.com>
Date: Thu, 22 Jun 2023 15:52:18 +0000
Subject: [PATCH] drivers/dahdi: fix build with clang-16
clang-16 enables -Werror=incompatible-pointer-types (along with buch of
other warnings) by default, thus resulting in errors such as:
/var/tmp/portage/net-misc/dahdi-3.2.0/work/dahdi-linux-3.2.0/drivers/dahdi/dahdi-sysfs.c:272:20: error: incompatible function
pointer types initializing 'int (*)(const struct device *, struct kobj_uevent_env *)' with an expression of type
'int (struct device *, struct kobj_uevent_env *)' [-Wincompatible-function-pointer-types]
.uevent = span_uevent,
^~~~~~~~~~~
/var/tmp/portage/net-misc/dahdi-3.2.0/work/dahdi-linux-3.2.0/drivers/dahdi/dahdi-sysfs.c:709:20: error: incompatible function
pointer types initializing 'int (*)(const struct device *, struct kobj_uevent_env *)' with an expression of type
'int (struct device *, struct kobj_uevent_env *)' [-Wincompatible-function-pointer-types]
.uevent = device_uevent,
^~~~~~~~~~~~~
2 errors generated.
This is due the change in bus_type strcut made in upstream commit
https://github.com/torvalds/linux/commit/2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6.
Where they make uevent take a const *, as the strcut should not be
modifying the device that is passed into it.
This patch modifes some of the fucntions parameter types, making dahdi
possible to be built with clang-16.
Bug: https://bugs.gentoo.org/906179
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
Upstream: https://github.com/asterisk/dahdi-linux/pull/21
[Bernd: updated patch for compatibility with kernel < 6.3]
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
---
drivers/dahdi/dahdi-sysfs.c | 12 ++++++++++--
drivers/dahdi/wctc4xxp/base.c | 2 +-
drivers/dahdi/xpp/xbus-sysfs.c | 4 ++++
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c
index ca29ddba..38236929 100644
--- a/drivers/dahdi/dahdi-sysfs.c
+++ b/drivers/dahdi/dahdi-sysfs.c
@@ -47,7 +47,7 @@ static int span_match(struct device *dev, struct device_driver *driver)
return 1;
}
-static inline struct dahdi_span *dev_to_span(struct device *dev)
+static inline struct dahdi_span *dev_to_span(const struct device *dev)
{
return dev_get_drvdata(dev);
}
@@ -68,7 +68,11 @@ static inline struct dahdi_span *dev_to_span(struct device *dev)
return err; \
} while (0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv)
+#else
+static int span_uevent(const struct device *dev, struct kobj_uevent_env *kenv)
+#endif
{
struct dahdi_span *span;
@@ -415,7 +419,7 @@ static struct {
unsigned int clean_chardev:1;
} should_cleanup;
-static inline struct dahdi_device *to_ddev(struct device *dev)
+static inline struct dahdi_device *to_ddev(const struct device *dev)
{
return container_of(dev, struct dahdi_device, dev);
}
@@ -438,7 +442,11 @@ static inline struct dahdi_device *to_ddev(struct device *dev)
return err; \
} while (0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv)
+#else
+static int device_uevent(const struct device *dev, struct kobj_uevent_env *kenv)
+#endif
{
struct dahdi_device *ddev;
diff --git a/drivers/dahdi/wctc4xxp/base.c b/drivers/dahdi/wctc4xxp/base.c
index ec6fc436..db70ea7e 100644
--- a/drivers/dahdi/wctc4xxp/base.c
+++ b/drivers/dahdi/wctc4xxp/base.c
@@ -643,7 +643,7 @@ wctc4xxp_net_register(struct wcdte *wc)
return -ENOMEM;
priv = netdev_priv(netdev);
priv->wc = wc;
- memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
+ memcpy((void *)netdev->dev_addr, our_mac, sizeof(our_mac));
# ifdef HAVE_NET_DEVICE_OPS
netdev->netdev_ops = &wctc4xxp_netdev_ops;
diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
index d8c11dc3..11b3ed3e 100644
--- a/drivers/dahdi/xpp/xbus-sysfs.c
+++ b/drivers/dahdi/xpp/xbus-sysfs.c
@@ -418,7 +418,11 @@ static int astribank_match(struct device *dev, struct device_driver *driver)
return err; \
} while (0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv)
+#else
+static int astribank_uevent(const struct device *dev, struct kobj_uevent_env *kenv)
+#endif
{
xbus_t *xbus;
extern char *initdir;