From 035f1dbc9f7bbc1cfa0da2c24564a99f02ef1094 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 7 Jul 2009 15:28:14 -0700 Subject: [PATCH] Simply rfkill backport by using macros By using direct macros for the calls such as: define rfkill_blocked backport_rfkill_blocked we can simpify the backport of rfkill. This works well as the number of arguments we use will always remain constant as we are providing our own implemention of rfkill. This reduces the size of compat.diff, makes it easier to maintain. Note that compat.diff was also broken as we forgot to use rdev instead of dev on the core.c patch but since we're removing it we don't bother to fix it. I note this in case we want to revert this patch later. This has been compile-tested on 2.6.27. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.31.h | 22 +++++- compat/compat.diff | 152 ----------------------------------------- 2 files changed, 19 insertions(+), 155 deletions(-) diff --git a/compat/compat-2.6.31.h b/compat/compat-2.6.31.h index cbe9752e651d..885c8392cc00 100644 --- a/compat/compat-2.6.31.h +++ b/compat/compat-2.6.31.h @@ -11,9 +11,21 @@ #include #include -#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN -#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104 -#endif +/* + * This is our backported header, we map actual rfkill calls + * to backported calls. + */ +#include + +#define rfkill_blocked backport_rfkill_blocked +#define rfkill_alloc backport_rfkill_alloc +#define rfkill_register backport_rfkill_register +#define rfkill_resume_polling backport_rfkill_resume_polling +#define rfkill_pause_polling backport_rfkill_pause_polling +#define rfkill_unregister backport_rfkill_unregister +#define rfkill_destroy backport_rfkill_destroy +#define rfkill_set_hw_state backport_rfkill_set_hw_state +#define rfkill_blocked backport_rfkill_blocked #ifndef ERFKILL #if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC) @@ -37,6 +49,10 @@ #define NETDEV_PRE_UP 0x000D #endif +#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN +#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104 +#endif + /* * Added via adf30907d63893e4208dfe3f5c88ae12bc2f25d5 * diff --git a/compat/compat.diff b/compat/compat.diff index 0ef0709ce92c..f16ac406b5ca 100644 --- a/compat/compat.diff +++ b/compat/compat.diff @@ -1163,120 +1163,6 @@ /* causes rfkill_start() to be called */ error = input_register_handle(handle); ---- a/net/wireless/core.c 2009-07-07 13:38:34.043690488 -0700 -+++ b/net/wireless/core.c 2009-07-07 13:55:32.547465059 -0700 -@@ -254,7 +254,11 @@ - struct cfg80211_registered_device *rdev; - - rdev = container_of(work, struct cfg80211_registered_device, rfkill_sync); -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill)); -+#else -+ cfg80211_rfkill_set_block(drv, backport_rfkill_blocked(drv->rfkill)); -+#endif - } - - static void cfg80211_process_events(struct wireless_dev *wdev) -@@ -376,9 +380,15 @@ - rdev->wiphy.dev.platform_data = rdev; - - rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block; -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - rdev->rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev), - &rdev->wiphy.dev, RFKILL_TYPE_WLAN, - &rdev->rfkill_ops, rdev); -+#else -+ drv->rfkill = backport_rfkill_alloc(dev_name(&drv->wiphy.dev), -+ &drv->wiphy.dev, RFKILL_TYPE_WLAN, -+ &drv->rfkill_ops, drv); -+#endif - - if (!rdev->rfkill) { - kfree(rdev); -@@ -463,7 +473,11 @@ - if (res) - return res; - -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - res = rfkill_register(rdev->rfkill); -+#else -+ res = backport_rfkill_register(drv->rfkill); -+#endif - if (res) - goto out_rm_dev; - -@@ -511,7 +525,11 @@ - if (!rdev->ops->rfkill_poll) - return; - rdev->rfkill_ops.poll = cfg80211_rfkill_poll; -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - rfkill_resume_polling(rdev->rfkill); -+#else -+ backport_rfkill_resume_polling(drv->rfkill); -+#endif - } - EXPORT_SYMBOL(wiphy_rfkill_start_polling); - -@@ -519,7 +537,11 @@ - { - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); - -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - rfkill_pause_polling(rdev->rfkill); -+#else -+ backport_rfkill_pause_polling(drv->rfkill); -+#endif - } - EXPORT_SYMBOL(wiphy_rfkill_stop_polling); - -@@ -527,7 +549,11 @@ - { - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); - -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - rfkill_unregister(rdev->rfkill); -+#else -+ backport_rfkill_unregister(drv->rfkill); -+#endif - - /* protect the device list */ - mutex_lock(&cfg80211_mutex); -@@ -570,7 +596,11 @@ - void cfg80211_dev_free(struct cfg80211_registered_device *rdev) - { - struct cfg80211_internal_bss *scan, *tmp; -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - rfkill_destroy(rdev->rfkill); -+#else -+ backport_rfkill_destroy(drv->rfkill); -+#endif - mutex_destroy(&rdev->mtx); - mutex_destroy(&rdev->devlist_mtx); - list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list) -@@ -588,7 +618,11 @@ - { - struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); - -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - if (rfkill_set_hw_state(rdev->rfkill, blocked)) -+#else -+ if (backport_rfkill_set_hw_state(drv->rfkill, blocked)) -+#endif - schedule_work(&rdev->rfkill_sync); - } - EXPORT_SYMBOL(wiphy_rfkill_set_hw_state); -@@ -694,7 +728,11 @@ - case NETDEV_PRE_UP: - if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype))) - return notifier_from_errno(-EOPNOTSUPP); -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - if (rfkill_blocked(rdev->rfkill)) -+#else -+ if (backport_rfkill_blocked(rdev->rfkill)) -+#endif - return notifier_from_errno(-ERFKILL); - break; - } --- a/net/wireless/core.h 2009-07-07 13:32:53.367707921 -0700 +++ b/net/wireless/core.h 2009-07-07 13:32:53.943703622 -0700 @@ -11,7 +11,11 @@ @@ -1351,44 +1237,6 @@ kref_put(&res->ref, bss_release); } else { /* this "consumes" the reference */ ---- a/net/wireless/wext-compat.c 2009-07-06 18:53:30.026197522 -0700 -+++ b/net/wireless/wext-compat.c 2009-07-06 18:53:31.098236302 -0700 -@@ -738,7 +738,11 @@ - - /* only change when not disabling */ - if (!data->txpower.disabled) { -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - rfkill_set_sw_state(rdev->rfkill, false); -+#else -+ backport_rfkill_set_sw_state(rdev->rfkill, false); -+#endif - - if (data->txpower.fixed) { - /* -@@ -763,7 +767,11 @@ - } - } - } else { -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - rfkill_set_sw_state(rdev->rfkill, true); -+#else -+ backport_rfkill_set_sw_state(rdev->rfkill, true); -+#endif - schedule_work(&rdev->rfkill_sync); - return 0; - } -@@ -794,7 +802,11 @@ - - /* well... oh well */ - data->txpower.fixed = 1; -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) - data->txpower.disabled = rfkill_blocked(rdev->rfkill); -+#else -+ data->txpower.disabled = backport_rfkill_blocked(rdev->rfkill); -+#endif - data->txpower.value = val; - data->txpower.flags = IW_TXPOW_DBM; - --- a/drivers/net/wireless/Makefile 2009-07-06 12:53:07.479194884 -0700 +++ b/drivers/net/wireless/Makefile 2009-07-06 12:54:42.026195576 -0700 @@ -5,43 +5,16 @@ -- 2.30.2