Deal with Red Hat backporting request_firmware_nowait change.
authorIan Abbott <abbotti@mev.co.uk>
Thu, 31 May 2012 09:47:10 +0000 (10:47 +0100)
committerIan Abbott <abbotti@mev.co.uk>
Thu, 31 May 2012 09:47:10 +0000 (10:47 +0100)
An extra 'gfp' parameter was added to request_firmware_nowait() in the
vanilla 2.6.33 kernel and the current <linux/firmware.h> 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 <linux/firmware.h> compatibility header to
check this macro instead of checking the kernel version directly.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
configure.ac
include/linux/firmware.h
m4/as-linux.m4

index 85a9f77030c5192735b8f347af9bb8fa05018807..7f788b7ff11e8b2851dbc1ec8e2ab4b32e5d0d3d 100644 (file)
@@ -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],
index 70687bd14e77eb8d804772b340bcb4a23ec4a636..514b86304f5d141dd30bf509a45317dcb8d333d7 100644 (file)
@@ -8,7 +8,14 @@
 
 #include_next <linux/firmware.h>
 
-#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
index 93107ea92627858d5d986ed08aa9f04e57fc9f5d..65e2a16eca5ff7a0743f0016dcd1e823ca325a5f 100644 (file)
@@ -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
+])