From 85bd8ba985dafe7794525b05f0a8afdf79e5f21e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 31 May 2012 10:47:10 +0100 Subject: [PATCH] Deal with Red Hat backporting request_firmware_nowait change. An extra 'gfp' parameter was added to request_firmware_nowait() in the vanilla 2.6.33 kernel and the current compatibility header checks for this kernel version. Unfortunately, Red Hat backported the change to their 2.6.32 kernel so the code in our compatibility header breaks on those kernels. Add a simple configure test to see if the gfp parameter is required and use this to define CONFIG_COMEDI_REQUEST_FIRMWARE_NOWAIT_HAS_GFP if it is required. Change out compatibility header to check this macro instead of checking the kernel version directly. Signed-off-by: Ian Abbott --- configure.ac | 7 +++++++ include/linux/firmware.h | 14 ++++++++------ m4/as-linux.m4 | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 85a9f770..7f788b7f 100644 --- a/configure.ac +++ b/configure.ac @@ -164,6 +164,13 @@ if test "$HAVE_GENERIC_BOOL_TYPE" = "yes" ; then AC_DEFINE([CONFIG_COMEDI_HAVE_GENERIC_BOOL_TYPE],[true],[Define if Linux kernel source has generic 'bool' type in linux/types.h]) fi +COMEDI_CHECK_REQUEST_FIRMWARE_NOWAIT_HAS_GFP([$LINUX_SRC_DIR], + [REQUEST_FIRMWARE_NOWAIT_HAS_GFP="yes"], + [REQUEST_FIRMWARE_NOWAIT_HAS_GFP="no"]) +if test "$REQUEST_FIRMWARE_NOWAIT_HAS_GFP" = "yes" ; then + AC_DEFINE([CONFIG_COMEDI_REQUEST_FIRMWARE_NOWAIT_HAS_GFP],[true],[Define if Linux kernel 'request_firmware_nowait' function has 'gfp' parameter]) +fi + AS_CHECK_LINUX_CONFIG_OPTION([CONFIG_USB],[HAVE_USB="yes"],[HAVE_USB="yes"],[HAVE_USB="no"]) AM_CONDITIONAL([CONFIG_USB],[test "$HAVE_USB" = "yes"]) AC_ARG_ENABLE([usb],[ --disable-usb Disable support for USB devices], diff --git a/include/linux/firmware.h b/include/linux/firmware.h index 70687bd1..514b8630 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h @@ -8,7 +8,14 @@ #include_next -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) +#ifdef CONFIG_COMEDI_REQUEST_FIRMWARE_NOWAIT_HAS_GFP + +/* Define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw) for use in the callback function + * of request_firmware_nowait(). This version just calls + * release_firmware(fw). */ +#define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw) release_firmware(fw) + +#else /* Redefine request_firmware_nowait() to add gfp parameter. This will be * ignored for kernel versions prior to 2.6.33. */ @@ -29,11 +36,6 @@ static inline int comedi_internal_request_firmware_nowait( /* Define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw) for use in the callback function * of request_firmware_nowait(). This version does nothing. */ #define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw) do; while (0) -#else -/* Define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw) for use in the callback function - * of request_firmware_nowait(). This version just calls - * release_firmware(fw). */ -#define COMEDI_RELEASE_FIRMWARE_NOWAIT(fw) release_firmware(fw) #endif #endif diff --git a/m4/as-linux.m4 b/m4/as-linux.m4 index 93107ea9..65e2a16e 100644 --- a/m4/as-linux.m4 +++ b/m4/as-linux.m4 @@ -971,3 +971,23 @@ AC_DEFUN([COMEDI_CHECK_HAVE_GENERIC_BOOL_TYPE], $3 fi ]) + +# COMEDI_CHECK_REQUEST_FIRMWARE_NOWAIT_HAS_GFP([LINUX_SOURCE_PATH], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# ------------------------------------------------------------- +# Check if the kernel's request_firmware_nowait() function has the gfp +# parameter. This was added in vanilla 2.6.33 but Red Hat backported it +# to their 2.6.32 kernel. +AC_DEFUN([COMEDI_CHECK_REQUEST_FIRMWARE_NOWAIT_HAS_GFP], +[ + AC_REQUIRE([AC_PROG_EGREP]) + AC_MSG_CHECKING([$1 for gfp parameter in request_firmware_nowait()]) + $EGREP -q gfp_t "$1/include/linux/firmware.h" + if (($?)); then + AC_MSG_RESULT([no]) + $3 + else + AC_MSG_RESULT([yes]) + $2 + fi +]) -- 2.26.2