Fix broken libiWmxSDK callback parameter handling
authorInaky Perez-Gonzalez <inaky@linux.intel.com>
Thu, 8 Oct 2009 04:08:48 +0000 (13:08 +0900)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 10 Oct 2009 12:41:47 +0000 (14:41 +0200)
libiWmxSDK broke AGAIN the callback model, by passing a 'device_id'
pointer that is not the original the callback was registered
with.

This makes it impossible to obtain the 'wmxsdk' that contains said
'device_id'.

Thus, implemented device_id_to_wmxsdk() by iterating over the list of
known wmxsdks looking for an index match.

plugins/iwmxsdk.c

index 52437f5..f8a0501 100644 (file)
@@ -47,7 +47,14 @@ static struct wmxsdk *g_iwmx_sdk_devs[IWMX_SDK_DEV_MAX];
 
 static struct wmxsdk *deviceid_to_wmxsdk(WIMAX_API_DEVICE_ID *device_id)
 {
-       return container_of(device_id, struct wmxsdk, device_id);
+       unsigned cnt;
+       for (cnt = 0; cnt < IWMX_SDK_DEV_MAX; cnt++) {
+               struct wmxsdk *wmxsdk = g_iwmx_sdk_devs[cnt];
+               if (wmxsdk &&
+                   wmxsdk->device_id.deviceIndex == device_id->deviceIndex)
+                       return wmxsdk;
+       }
+       return NULL;
 }
 
 static WIMAX_API_DEVICE_ID g_api;