0005-Fix-build-on-Linux-6.3.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From c4969d756eac041758856b99a1084158c06beb7e Mon Sep 17 00:00:00 2001
  2. From: Brahmajit Das <brahmajit.xyz@gmail.com>
  3. Date: Thu, 22 Jun 2023 15:52:18 +0000
  4. Subject: [PATCH] drivers/dahdi: fix build with clang-16
  5. clang-16 enables -Werror=incompatible-pointer-types (along with buch of
  6. other warnings) by default, thus resulting in errors such as:
  7. /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
  8. pointer types initializing 'int (*)(const struct device *, struct kobj_uevent_env *)' with an expression of type
  9. 'int (struct device *, struct kobj_uevent_env *)' [-Wincompatible-function-pointer-types]
  10. .uevent = span_uevent,
  11. ^~~~~~~~~~~
  12. /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
  13. pointer types initializing 'int (*)(const struct device *, struct kobj_uevent_env *)' with an expression of type
  14. 'int (struct device *, struct kobj_uevent_env *)' [-Wincompatible-function-pointer-types]
  15. .uevent = device_uevent,
  16. ^~~~~~~~~~~~~
  17. 2 errors generated.
  18. This is due the change in bus_type strcut made in upstream commit
  19. https://github.com/torvalds/linux/commit/2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6.
  20. Where they make uevent take a const *, as the strcut should not be
  21. modifying the device that is passed into it.
  22. This patch modifes some of the fucntions parameter types, making dahdi
  23. possible to be built with clang-16.
  24. Bug: https://bugs.gentoo.org/906179
  25. Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
  26. Upstream: https://github.com/asterisk/dahdi-linux/pull/21
  27. [Bernd: updated patch for compatibility with kernel < 6.3]
  28. Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
  29. ---
  30. drivers/dahdi/dahdi-sysfs.c | 12 ++++++++++--
  31. drivers/dahdi/wctc4xxp/base.c | 2 +-
  32. drivers/dahdi/xpp/xbus-sysfs.c | 4 ++++
  33. 3 files changed, 15 insertions(+), 3 deletions(-)
  34. diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c
  35. index ca29ddba..38236929 100644
  36. --- a/drivers/dahdi/dahdi-sysfs.c
  37. +++ b/drivers/dahdi/dahdi-sysfs.c
  38. @@ -47,7 +47,7 @@ static int span_match(struct device *dev, struct device_driver *driver)
  39. return 1;
  40. }
  41. -static inline struct dahdi_span *dev_to_span(struct device *dev)
  42. +static inline struct dahdi_span *dev_to_span(const struct device *dev)
  43. {
  44. return dev_get_drvdata(dev);
  45. }
  46. @@ -68,7 +68,11 @@ static inline struct dahdi_span *dev_to_span(struct device *dev)
  47. return err; \
  48. } while (0)
  49. +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
  50. static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv)
  51. +#else
  52. +static int span_uevent(const struct device *dev, struct kobj_uevent_env *kenv)
  53. +#endif
  54. {
  55. struct dahdi_span *span;
  56. @@ -415,7 +419,7 @@ static struct {
  57. unsigned int clean_chardev:1;
  58. } should_cleanup;
  59. -static inline struct dahdi_device *to_ddev(struct device *dev)
  60. +static inline struct dahdi_device *to_ddev(const struct device *dev)
  61. {
  62. return container_of(dev, struct dahdi_device, dev);
  63. }
  64. @@ -438,7 +442,11 @@ static inline struct dahdi_device *to_ddev(struct device *dev)
  65. return err; \
  66. } while (0)
  67. +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
  68. static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv)
  69. +#else
  70. +static int device_uevent(const struct device *dev, struct kobj_uevent_env *kenv)
  71. +#endif
  72. {
  73. struct dahdi_device *ddev;
  74. diff --git a/drivers/dahdi/wctc4xxp/base.c b/drivers/dahdi/wctc4xxp/base.c
  75. index ec6fc436..db70ea7e 100644
  76. --- a/drivers/dahdi/wctc4xxp/base.c
  77. +++ b/drivers/dahdi/wctc4xxp/base.c
  78. @@ -643,7 +643,7 @@ wctc4xxp_net_register(struct wcdte *wc)
  79. return -ENOMEM;
  80. priv = netdev_priv(netdev);
  81. priv->wc = wc;
  82. - memcpy(netdev->dev_addr, our_mac, sizeof(our_mac));
  83. + memcpy((void *)netdev->dev_addr, our_mac, sizeof(our_mac));
  84. # ifdef HAVE_NET_DEVICE_OPS
  85. netdev->netdev_ops = &wctc4xxp_netdev_ops;
  86. diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
  87. index d8c11dc3..11b3ed3e 100644
  88. --- a/drivers/dahdi/xpp/xbus-sysfs.c
  89. +++ b/drivers/dahdi/xpp/xbus-sysfs.c
  90. @@ -418,7 +418,11 @@ static int astribank_match(struct device *dev, struct device_driver *driver)
  91. return err; \
  92. } while (0)
  93. +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
  94. static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv)
  95. +#else
  96. +static int astribank_uevent(const struct device *dev, struct kobj_uevent_env *kenv)
  97. +#endif
  98. {
  99. xbus_t *xbus;
  100. extern char *initdir;