From: Brian Behlendorf Date: Fri, 13 Mar 2009 20:38:43 +0000 (-0700) Subject: Added SPL_AC_5ARGS_DEVICE_CREATE autoconf configure check X-Git-Tag: zfs-0.8.0-rc1~152^2~721 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8123ac4f0d7409cae209858d01803fb2744b51b6;p=zfs 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. --- 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 @@ -503,6 +503,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 + ],[ + 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 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 + +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