Skip to content

Commit 8bccc69

Browse files
committed
3.17: Change conditional compilation of devm_add_action_or_reset
While this function was indeed added in v4.6 of the Linux kernel, it has also been backported to RHEL 7.9. Because RHEL declares itself to use a 3.10 kernel, however, the compile fails with the following error about a redefined symbol: ./3.17/wacom_sys.c:66:12: error: redefinition of ‘devm_add_action_or_reset’ static int devm_add_action_or_reset(struct device *dev, ^ In file included from include/linux/input.h:22:0, from include/linux/hid.h:35, from /home/mocaw/input-wacom/3.17/wacom_wac.h:7, from /home/mocaw/input-wacom/3.17/wacom_sys.c:6: include/linux/device.h:683:19: note: previous definition of ‘devm_add_action_or_reset’ was here static inline int devm_add_action_or_reset(struct device *dev, ^ This commit adds a configure-time check for this function (like we do for the power_supply APIs) so that code will compile properly regardless of the declared kernel version. Signed-off-by: Jason Gerecke <[email protected]>
1 parent cffc2ec commit 8bccc69

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

3.17/wacom_sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static bool wacom_is_using_usb_driver(struct hid_device *hdev)
6262
usb_for_each_dev(hdev, __wacom_is_usb_parent);
6363
}
6464

65-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0)
65+
#ifndef WACOM_DEVM_OR_RESET
6666
static int devm_add_action_or_reset(struct device *dev,
6767
void (*action)(void *), void *data)
6868
{

configure.ac

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,21 @@ struct power_supply_desc test;
205205
AC_MSG_RESULT([pre-v4.1])
206206
])
207207

208+
dnl RedHat enterprise Linux 7.9 backports devm functions from 4.6
209+
AC_MSG_CHECKING(devm_add_action_or_reset)
210+
WACOM_LINUX_TRY_COMPILE([
211+
#include <linux/device.h>
212+
int devm_add_action_or_reset(struct device *dev, void (*action)(void *), void *data) { return 0; }
213+
],[
214+
],[
215+
HAVE_DEVM_ADD_OR_RESET=no
216+
AC_MSG_RESULT([no])
217+
],[
218+
HAVE_DEVM_ADD_OR_RESET=yes
219+
AC_MSG_RESULT([yes])
220+
AC_DEFINE([WACOM_DEVM_OR_RESET], [], [kernel defines devm_add_action_or_reset from v4.6+])
221+
])
222+
208223
dnl Check which version of the driver we should compile
209224
AC_DEFUN([WCM_EXPLODE], [$(echo "$1" | awk '{split($[0],x,"[[^0-9]]"); printf("%03d%03d%03d\n",x[[1]],x[[2]],x[[3]]);}')])
210225
EXPLODED_VER="WCM_EXPLODE($MODUTS)"

0 commit comments

Comments
 (0)