aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-03-13 13:38:43 -0700
committerBrian Behlendorf <[email protected]>2009-03-13 13:38:43 -0700
commit8123ac4f0d7409cae209858d01803fb2744b51b6 (patch)
tree7e2c28b3215d47eff289fcd309a62224427621fb
parenta0b5ae8acaaf63fa2378a6d062e66fdf99387625 (diff)
Added SPL_AC_5ARGS_DEVICE_CREATE autoconf configure check
As of 2.6.27 kernels the device_create() API changed to include a private data argument. This check detects which version of device_create() function the kernel has and properly defines spl_device_create() to use the correct prototype.
-rw-r--r--config/spl-build.m422
-rwxr-xr-xconfigure68
-rw-r--r--configure.ac1
-rw-r--r--include/spl-device.h9
-rw-r--r--spl_config.h.in3
5 files changed, 102 insertions, 1 deletions
diff --git a/config/spl-build.m4 b/config/spl-build.m4
index f2dc7fa9e..d0cf86d9a 100644
--- a/config/spl-build.m4
+++ b/config/spl-build.m4
@@ -504,6 +504,28 @@ AC_DEFUN([SPL_AC_DEVICE_CREATE], [
])
dnl #
+dnl # 2.6.27 API change,
+dnl # device_create() uses 5 args, new 'drvdata' argument.
+dnl #
+AC_DEFUN([SPL_AC_5ARGS_DEVICE_CREATE], [
+ AC_MSG_CHECKING([whether device_create() wants 5 args])
+ tmp_flags="$EXTRA_KCFLAGS"
+ EXTRA_KCFLAGS="-Werror"
+ SPL_LINUX_TRY_COMPILE([
+ #include <linux/device.h>
+ ],[
+ device_create(NULL, NULL, 0, NULL, "%d", 1);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_5ARGS_DEVICE_CREATE, 1,
+ [device_create wants 5 args])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+ EXTRA_KCFLAGS="$tmp_flags"
+])
+
+dnl #
dnl # 2.6.13 API change, check whether class_device_create() is available.
dnl # Class_device_create() was introduced in 2.6.13 and depricated
dnl # class_simple_device_add() which was fully removed in 2.6.13.
diff --git a/configure b/configure
index 92dd8d732..0467b602d 100755
--- a/configure
+++ b/configure
@@ -19788,6 +19788,74 @@ _ACEOF
+ echo "$as_me:$LINENO: checking whether device_create() wants 5 args" >&5
+echo $ECHO_N "checking whether device_create() wants 5 args... $ECHO_C" >&6
+ tmp_flags="$EXTRA_KCFLAGS"
+ EXTRA_KCFLAGS="-Werror"
+
+
+cat >conftest.c <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+
+ #include <linux/device.h>
+
+int
+main (void)
+{
+
+ device_create(NULL, NULL, 0, NULL, "%d", 1);
+
+ ;
+ return 0;
+}
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build
+ echo "obj-m := conftest.o" >build/Makefile
+ if { ac_try='cp conftest.c build && make modules CC="$CC" LINUXINCLUDE="-Iinclude -Iinclude2 -I$LINUX/include -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_5ARGS_DEVICE_CREATE 1
+_ACEOF
+
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+
+
+fi
+
+ rm -Rf build
+
+
+ EXTRA_KCFLAGS="$tmp_flags"
+
+
echo "$as_me:$LINENO: checking whether symbol class_device_create is exported" >&5
echo $ECHO_N "checking whether symbol class_device_create is exported... $ECHO_C" >&6
grep -q -E '[[:space:]]class_device_create[[:space:]]' $LINUX_OBJ/Module.symvers 2>/dev/null
diff --git a/configure.ac b/configure.ac
index 7409cba6e..623d54dd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,7 @@ SPL_AC_TASK_CURR
SPL_AC_CTL_UNNUMBERED
SPL_AC_FLS64
SPL_AC_DEVICE_CREATE
+SPL_AC_5ARGS_DEVICE_CREATE
SPL_AC_CLASS_DEVICE_CREATE
SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
diff --git a/include/spl-device.h b/include/spl-device.h
index d18aedf07..c82f65dfe 100644
--- a/include/spl-device.h
+++ b/include/spl-device.h
@@ -13,8 +13,15 @@ typedef struct device spl_device;
#define spl_class_create(mod, name) class_create(mod, name)
#define spl_class_destroy(cls) class_destroy(cls)
-#define spl_device_create(cls, parent, devt, device, fmt, args...) \
+
+# ifdef HAVE_5ARGS_DEVICE_CREATE
+# define spl_device_create(cls, parent, devt, drvdata, fmt, args...) \
+ device_create(cls, parent, devt, drvdata, fmt, ## args)
+# else
+# define spl_device_create(cls, parent, devt, drvdata, fmt, args...) \
device_create(cls, parent, devt, fmt, ## args)
+# endif
+
#define spl_device_destroy(cls, cls_dev, devt) \
device_destroy(cls, devt)
diff --git a/spl_config.h.in b/spl_config.h.in
index 931539c81..f2895054d 100644
--- a/spl_config.h.in
+++ b/spl_config.h.in
@@ -21,6 +21,9 @@
/* on_each_cpu wants 3 args */
#undef HAVE_3ARGS_ON_EACH_CPU
+/* device_create wants 5 args */
+#undef HAVE_5ARGS_DEVICE_CREATE
+
/* kernel defines atomic64_t */
#undef HAVE_ATOMIC64_T