wlan: Add helper function hdd_priv_get_data for "compat" support
Compat handling is required for some ioctl handlers when used in
32U/64K environment.
Adding a common function hdd_priv_get_data() for compat handling
so that when the driver is part of 64-bit kernel, handlers can
use it to work with 32-bit userspace applications
Change-Id: Ifb1e2022301e6b34ae9c1a7aca89a891642d834e
CRs-Fixed: 681631
diff --git a/CORE/HDD/inc/wlan_hdd_wext.h b/CORE/HDD/inc/wlan_hdd_wext.h
index 6788375..b858ed6 100644
--- a/CORE/HDD/inc/wlan_hdd_wext.h
+++ b/CORE/HDD/inc/wlan_hdd_wext.h
@@ -386,6 +386,9 @@
extern int iw_set_three_ints_getnone(struct net_device *dev, struct iw_request_info *info,
union iwreq_data *wrqu, char *extra);
+extern int hdd_priv_get_data(struct iw_point *p_priv_data,
+ union iwreq_data *wrqu);
+
extern VOS_STATUS wlan_hdd_get_linkspeed_for_peermac(hdd_adapter_t *pAdapter,
tSirMacAddr macAddress);
void hdd_clearRoamProfileIe( hdd_adapter_t *pAdapter);
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c
index 03d96db..bed3179 100644
--- a/CORE/HDD/src/wlan_hdd_wext.c
+++ b/CORE/HDD/src/wlan_hdd_wext.c
@@ -616,6 +616,49 @@
/**---------------------------------------------------------------------------
+ \brief hdd_priv_get_data -
+
+ Helper function to get compatible struct iw_point passed to ioctl
+
+ \param - p_priv_data - pointer to iw_point struct to be filled
+ wrqu - Pointer to IOCTL Data received from userspace
+
+ \return - 0 if p_priv_data successfully filled
+ error otherwise
+
+ --------------------------------------------------------------------------*/
+int hdd_priv_get_data(struct iw_point *p_priv_data,
+ union iwreq_data *wrqu)
+{
+ if ((NULL == p_priv_data) || (NULL == wrqu)) {
+ return -EINVAL;
+ }
+
+#ifdef CONFIG_COMPAT
+ if (is_compat_task()) {
+ struct compat_iw_point *p_compat_priv_data;
+
+ /* Compat task: typecast to compat structure and copy the members. */
+ p_compat_priv_data = (struct compat_iw_point *) &wrqu->data;
+
+ p_priv_data->pointer = compat_ptr(p_compat_priv_data->pointer);
+ p_priv_data->length = p_compat_priv_data->length;
+ p_priv_data->flags = p_compat_priv_data->flags;
+ } else {
+#endif /* #ifdef CONFIG_COMPAT */
+
+ /* Non compat task: directly copy the structure. */
+ memcpy(p_priv_data, &wrqu->data, sizeof(struct iw_point));
+
+#ifdef CONFIG_COMPAT
+ }
+#endif /* #ifdef CONFIG_COMPAT */
+
+ return 0;
+}
+
+/**---------------------------------------------------------------------------
+
\brief hdd_wlan_get_version() -
This function use to get Wlan Driver, Firmware, & Hardware Version.