Add work around Intel WiMAX SDK API breakage
authorInaky Perez-Gonzalez <inaky@linux.intel.com>
Thu, 8 Oct 2009 02:33:14 +0000 (11:33 +0900)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 10 Oct 2009 12:35:49 +0000 (14:35 +0200)
Release of the Intel WiMAX SDK 1.5 breaks source compatibility from
1.4 by removing WIMAX_API_DEVICE_STATUS_Connection_Idle.

Rather than fight a useless fight, work aronud it with an autoconf
test and a few (ugly) #ifdefs.

configure.ac
plugins/iwmx.c
plugins/iwmxsdk.c

index aa61ba2..25ada26 100644 (file)
@@ -223,6 +223,15 @@ if (test "${enable_iwmx}" = "yes"); then
        PKG_CONFIG_PATH=""
        AC_SUBST(IWMXSDK_CFLAGS)
        AC_SUBST(IWMXSDK_LIBS)
+        CPPFLAGS_save=$CPPFLAGS
+        CPPFLAGS="$IWMXSDK_CFLAGS $CPPFLAGS"
+        AH_TEMPLATE([HAVE_IWMXSDK_STATUS_IDLE],
+                    [WIMAX_API_DEVICE_STATUS_Connection_Idle is present])
+        AC_CHECK_DECL(WIMAX_API_DEVICE_STATUS_Connection_Idle,
+                      [AC_DEFINE([HAVE_IWMXSDK_STATUS_IDLE], [1], [])],
+                      [],
+                      [[#include <WiMaxType.h>]])
+        CPPFLAGS=$CPPFLAGS_save
 fi
 AM_CONDITIONAL(IWMX, test "${enable_iwmx}" = "yes")
 
index ccbd1d2..74e9786 100644 (file)
@@ -299,6 +299,7 @@ void __iwmx_cm_state_change(struct wmxsdk *wmxsdk,
         * For practical effects, some states are the same
         */
 
+#if HAVE_IWMXSDK_STATUS_IDLE
        /* Conection_Idle is the same as Data_Connected */
        if (__old_status == WIMAX_API_DEVICE_STATUS_Connection_Idle)
                old_status = WIMAX_API_DEVICE_STATUS_Data_Connected;
@@ -308,7 +309,7 @@ void __iwmx_cm_state_change(struct wmxsdk *wmxsdk,
                new_status = WIMAX_API_DEVICE_STATUS_Data_Connected;
        else
                new_status = __new_status;
-
+#endif /* #if HAVE_IWMXSDK_STATUS_IDLE */
        /* Radio off: all are just RF_OFF_SW (the highest) */
        switch (__old_status) {
        case WIMAX_API_DEVICE_STATUS_RF_OFF_HW_SW:
index 60466e5..7888c09 100644 (file)
@@ -98,8 +98,10 @@ const char *iwmx_sdk_dev_status_to_str(WIMAX_API_DEVICE_STATUS status)
                return "Connection in progress";
        case WIMAX_API_DEVICE_STATUS_Data_Connected:
                return "Layer 2 connected";
+#if HAVE_IWMXSDK_STATUS_IDLE
        case WIMAX_API_DEVICE_STATUS_Connection_Idle:
                return "Idle connection";
+#endif /* #if HAVE_IWMXSDK_STATUS_IDLE */
        default:
                return "unknown state";
        }
@@ -298,7 +300,9 @@ int iwmx_sdk_rf_state_set(struct wmxsdk *wmxsdk, WIMAX_API_RF_STATE rf_state)
        case WIMAX_API_DEVICE_STATUS_Scanning:
        case WIMAX_API_DEVICE_STATUS_Connecting:
        case WIMAX_API_DEVICE_STATUS_Data_Connected:
+#if HAVE_IWMXSDK_STATUS_IDLE
        case WIMAX_API_DEVICE_STATUS_Connection_Idle:
+#endif
                if (rf_state == WIMAX_API_RF_ON) {
                        result = 0;
                        DBG("radio is already on\n");
@@ -346,7 +350,10 @@ static void __iwmx_sdk_connect_cb(struct WIMAX_API_DEVICE_ID *device_id,
        status = iwmx_cm_status_get(wmxsdk);
        if (resp == WIMAX_API_CONNECTION_SUCCESS) {
                if (status != WIMAX_API_DEVICE_STATUS_Data_Connected
-                   && status != WIMAX_API_DEVICE_STATUS_Connection_Idle)
+#if HAVE_IWMXSDK_STATUS_IDLE
+                   && status != WIMAX_API_DEVICE_STATUS_Connection_Idle
+#endif
+                       )
                        connman_error("wmxsdk: error: connect worked, but state"
                                      " didn't change (now it is %d [%s])\n",
                                      status,
@@ -406,7 +413,9 @@ int iwmx_sdk_connect(struct wmxsdk *wmxsdk, struct connman_network *nw)
                result = -EINPROGRESS;
                goto error_cant_do;
        case WIMAX_API_DEVICE_STATUS_Data_Connected:
+#if HAVE_IWMXSDK_STATUS_IDLE
        case WIMAX_API_DEVICE_STATUS_Connection_Idle:
+#endif
                connman_error("wmxsdk: BUG? need to disconnect?\n");
                result = -EINVAL;
                goto error_cant_do;
@@ -459,7 +468,10 @@ static void __iwmx_sdk_disconnect_cb(struct WIMAX_API_DEVICE_ID *device_id,
        status = iwmx_cm_status_get(wmxsdk);
        if (resp == WIMAX_API_CONNECTION_SUCCESS) {
                if (status == WIMAX_API_DEVICE_STATUS_Data_Connected
-                   || status == WIMAX_API_DEVICE_STATUS_Connection_Idle)
+#if HAVE_IWMXSDK_STATUS_IDLE
+                   || status == WIMAX_API_DEVICE_STATUS_Connection_Idle
+#endif
+                       )
                        connman_error("wmxsdk: error: disconnect worked, "
                                      "but state didn't change (now it is "
                                      "%d [%s])\n", status,
@@ -510,7 +522,9 @@ int iwmx_sdk_disconnect(struct wmxsdk *wmxsdk)
                goto error_cant_do;
        case WIMAX_API_DEVICE_STATUS_Connecting:
        case WIMAX_API_DEVICE_STATUS_Data_Connected:
+#if HAVE_IWMXSDK_STATUS_IDLE
        case WIMAX_API_DEVICE_STATUS_Connection_Idle:
+#endif
                break;
        default:
                g_assert(1);