From 61271b62c0cb01f06005b0de837292fd1c904fd7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 6 Jul 2009 18:01:06 -0700 Subject: [PATCH] Add missing bits to get compat-wireless to compile on 2.6.26 Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.27.c | 45 ++++++++++++++++++++++++++++++++++++++++-- compat/compat-2.6.27.h | 29 ++++++++++++++++++++------- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c index c2716807eb77..d072f646a579 100644 --- a/compat/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -15,6 +15,9 @@ #include #include #include +#include +#include + /* rfkill notification chain */ #define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill @@ -23,20 +26,47 @@ /* * e5899e1b7d73e67de758a32174a859cc2586c0b9 made pci_pme_capable() external, * it was defined internally, some drivers want access to this information. + * + * Unfortunately the old kernels do not have ->pm_cap or ->pme_support so + * we have to call the PCI routines directly. */ /** * pci_pme_capable - check the capability of PCI device to generate PME# * @dev: PCI device to handle. * @state: PCI state from which device will issue PME#. + * + * This is the backport code for older kernels for compat-wireless, we read stuff + * from the initialization stuff from pci_pm_init(). */ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) { - if (!dev->pm_cap) + int pm; + u16 pmc = 0; + u16 pme_support; /* as from the pci dev */ + /* find PCI PM capability in list */ + pm = pci_find_capability(dev, PCI_CAP_ID_PM); + if (!pm) + return false; + + if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { + dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", + pmc & PCI_PM_CAP_VER_MASK); + return false; + } + + pmc &= PCI_PM_CAP_PME_MASK; + + if (!pmc) return false; - return !!(dev->pme_support & (1 << state)); + pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; + + /* Check device's ability to generate PME# */ + + return !!(pme_support & (1 << state)); } +EXPORT_SYMBOL(pci_pme_capable); /** * mmc_align_data_size - pads a transfer size to a more optimal value @@ -65,6 +95,17 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) } EXPORT_SYMBOL(mmc_align_data_size); +/* + * Calculate the maximum byte mode transfer size + */ +static inline unsigned int sdio_max_byte_size(struct sdio_func *func) +{ + unsigned int mval = (unsigned int) min(func->card->host->max_seg_size, + func->card->host->max_blk_size); + mval = min(mval, func->max_blksize); + return min(mval, 512u); /* maximum size for byte mode */ +} + /** * sdio_align_size - pads a transfer size to a more optimal value * @func: SDIO function diff --git a/compat/compat-2.6.27.h b/compat/compat-2.6.27.h index c60ee44ccf52..cfce4e273fd8 100644 --- a/compat/compat-2.6.27.h +++ b/compat/compat-2.6.27.h @@ -8,14 +8,35 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) #include -#include #include #include #include #include +#include #include +#define PCI_PM_CAP_PME_SHIFT 11 + +/* + * On older kernels we do not have net_device Multi Queue support, but + * since we no longer use MQ on mac80211 we can simply use the 0 queue. + * Note that if other fullmac drivers make use of this they then need + * to be backported somehow or deal with just 1 queueue from MQ. + */ +static inline void netif_tx_wake_all_queues(struct net_device *dev) +{ + netif_wake_queue(dev); +} +static inline void netif_tx_start_all_queues(struct net_device *dev) +{ + netif_start_queue(dev); +} +static inline void netif_tx_stop_all_queues(struct net_device *dev) +{ + netif_stop_queue(dev); +} + bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); /* @@ -45,12 +66,6 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); #define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr) #define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr) -/* This is from include/linux/rfkill.h */ -#define RFKILL_STATE_SOFT_BLOCKED RFKILL_STATE_OFF -#define RFKILL_STATE_UNBLOCKED RFKILL_STATE_ON -/* This one is new */ -#define RFKILL_STATE_HARD_BLOCKED 2 - /* This is from include/linux/ieee80211.h */ #define IEEE80211_HT_CAP_DSSSCCK40 0x1000 -- 2.30.2