From: Jim C. <jim...@gm...> - 2012-04-17 20:42:27
|
Merge one function (acx_interrupt) into merge.c which is identical in mem.c and pci.c. Comment out old fn-signatures in mem.c and pci.c, and add new ones (w/o the (pci|mem) part of the name. Probably should just move them to merge.h, and drop them from fn-sigs. Signed-off-by: Jim Cromie <jim...@gm...> --- Makefile | 2 +- mem.c | 66 ++--------------------------------------- merge.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pci.c | 68 ++---------------------------------------- 4 files changed, 106 insertions(+), 128 deletions(-) create mode 100644 merge.c diff --git a/Makefile b/Makefile index c1d906f..c2eaffd 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ ifneq ($(KERNELRELEASE),) acx-mac80211-obj-$(CONFIG_ACX_MAC80211_PCI) += pci.o acx-mac80211-obj-$(CONFIG_ACX_MAC80211_USB) += usb.o acx-mac80211-obj-$(CONFIG_ACX_MAC80211_MEM) += mem.o - acx-mac80211-objs := common.o $(acx-mac80211-obj-y) + acx-mac80211-objs := common.o $(acx-mac80211-obj-y) merge.o else # Otherwise we were called directly from the command line: the kernel build diff --git a/mem.c b/mem.c index d7bd025..f49a297 100644 --- a/mem.c +++ b/mem.c @@ -212,7 +212,8 @@ int acx100mem_set_tx_level(acx_device_t *adev, u8 level_dbm); static void acxmem_irq_enable(acx_device_t *adev); static void acxmem_irq_disable(acx_device_t *adev); void acxmem_irq_work(struct work_struct *work); -static irqreturn_t acxmem_interrupt(int irq, void *dev_id); +// static irqreturn_t acxmem_interrupt(int irq, void *dev_id); +irqreturn_t acx_interrupt(int irq, void *dev_id); static void acxmem_handle_info_irq(acx_device_t *adev); void acxmem_set_interrupt_mask(acx_device_t *adev); @@ -3666,67 +3667,6 @@ void acxmem_irq_work(struct work_struct *work) } -// OW TODO Copy of pci: possible merging. -static irqreturn_t acxmem_interrupt(int irq, void *dev_id) -{ - acx_device_t *adev = dev_id; - unsigned long flags; - u16 irqreason; - u16 irqmasked; - - if (!adev) - return IRQ_NONE; - - // On a shared irq line, irqs should only be for us, when enabled them - if (!adev->irqs_active) - return IRQ_NONE; - - FN_ENTER; - - spin_lock_irqsave(&adev->spinlock, flags); - - /* We only get an irq-signal for IO_ACX_IRQ_MASK unmasked irq reasons. - * However masked irq reasons we still read with IO_ACX_IRQ_REASON or - * IO_ACX_IRQ_STATUS_NON_DES - */ - irqreason = read_reg16(adev, IO_ACX_IRQ_STATUS_NON_DES); - irqmasked = irqreason & ~adev->irq_mask; - log(L_IRQ, "irqstatus=%04X, irqmasked=%04X,\n", irqreason, irqmasked); - - if (unlikely(irqreason == 0xffff)) { - /* 0xffff value hints at missing hardware, - * so don't do anything. - * Not very clean, but other drivers do the same... */ - log(L_IRQ, "irqstatus=FFFF: Device removed?: IRQ_NONE\n"); - goto none; - } - - /* Our irq-signals are the ones, that were triggered by the IO_ACX_IRQ_MASK - * unmasked irqs. - */ - if (!irqmasked) { - /* We are on a shared IRQ line and it wasn't our IRQ */ - log(L_IRQ, "irqmasked zero: IRQ_NONE\n"); - goto none; - } - - // Mask all irqs, until we handle them. We will unmask them later in the tasklet. - write_reg16(adev, IO_ACX_IRQ_MASK, HOST_INT_MASK_ALL); - write_flush(adev); - acx_schedule_task(adev, 0); - - spin_unlock_irqrestore(&adev->spinlock, flags); - FN_EXIT0; - return IRQ_HANDLED; - - none: - - spin_unlock_irqrestore(&adev->spinlock, flags); - FN_EXIT0; - return IRQ_NONE; - -} - /* * acxmem_handle_info_irq */ @@ -4662,7 +4602,7 @@ static int __devinit acxmem_probe(struct platform_device *pdev) { log(L_IRQ | L_INIT, "using IRQ %d\n", adev->irq); /* request shared IRQ handler */ - if (request_irq(adev->irq, acxmem_interrupt, + if (request_irq(adev->irq, acx_interrupt, IRQF_SHARED, KBUILD_MODNAME, adev)) { diff --git a/merge.c b/merge.c new file mode 100644 index 0000000..1b2f211 --- /dev/null +++ b/merge.c @@ -0,0 +1,98 @@ +#include <linux/version.h> + +#include <linux/compiler.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/sched.h> +#include <linux/types.h> +#include <linux/skbuff.h> +#include <linux/slab.h> +#include <linux/irq.h> +#include <linux/interrupt.h> +#include <linux/wireless.h> +#include <linux/netdevice.h> +#include <linux/ioport.h> +#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/vmalloc.h> +#include <linux/workqueue.h> +#include <linux/nl80211.h> + +#include <net/iw_handler.h> +#include <net/mac80211.h> + +#include <asm/io.h> + +/* this will be problematic when combined with PCI macro. + acx_struct_dev.h defines iobase field 2x, with different types, for + MEM and PCI includes. Punt for now.. +*/ +#define ACX_MAC80211_MEM +// #define ACX_MAC80211_PCI + +#include "acx.h" +#include "mem-inlines.h" + +// identical from pci.c, mem.c +irqreturn_t acx_interrupt(int irq, void *dev_id) +{ + acx_device_t *adev = dev_id; + unsigned long flags; + u16 irqreason; + u16 irqmasked; + + if (!adev) + return IRQ_NONE; + + // On a shared irq line, irqs should only be for us, when enabled them + if (!adev->irqs_active) + return IRQ_NONE; + + FN_ENTER; + + spin_lock_irqsave(&adev->spinlock, flags); + + /* We only get an irq-signal for IO_ACX_IRQ_MASK unmasked irq reasons. + * However masked irq reasons we still read with IO_ACX_IRQ_REASON or + * IO_ACX_IRQ_STATUS_NON_DES + */ + irqreason = read_reg16(adev, IO_ACX_IRQ_STATUS_NON_DES); + irqmasked = irqreason & ~adev->irq_mask; + log(L_IRQ, "irqstatus=%04X, irqmasked=%04X,\n", irqreason, irqmasked); + + if (unlikely(irqreason == 0xffff)) { + /* 0xffff value hints at missing hardware, + * so don't do anything. + * Not very clean, but other drivers do the same... */ + log(L_IRQ, "irqstatus=FFFF: Device removed?: IRQ_NONE\n"); + goto none; + } + + /* Our irq-signals are the ones, that were triggered by the IO_ACX_IRQ_MASK + * unmasked irqs. + */ + if (!irqmasked) { + /* We are on a shared IRQ line and it wasn't our IRQ */ + log(L_IRQ, "irqmasked zero: IRQ_NONE\n"); + goto none; + } + + // Mask all irqs, until we handle them. We will unmask them later in the tasklet. + write_reg16(adev, IO_ACX_IRQ_MASK, HOST_INT_MASK_ALL); + write_flush(adev); + acx_schedule_task(adev, 0); + + spin_unlock_irqrestore(&adev->spinlock, flags); + FN_EXIT0; + return IRQ_HANDLED; +none: + spin_unlock_irqrestore(&adev->spinlock, flags); + FN_EXIT0; + return IRQ_NONE; +} + +irqreturn_t acxmem_interrupt(int irq, void *dev_id) +{ + return acx_interrupt(irq, dev_id); +} diff --git a/pci.c b/pci.c index d73e1de..95f1d66 100644 --- a/pci.c +++ b/pci.c @@ -143,7 +143,8 @@ static txhostdesc_t *acxpci_get_txhostdesc(acx_device_t * adev, txdesc_t * txdes static void acxpci_irq_enable(acx_device_t * adev); static void acxpci_irq_disable(acx_device_t * adev); void acxpci_irq_work(struct work_struct *work); -static irqreturn_t acxpci_interrupt(int irq, void *dev_id); +// static irqreturn_t acxpci_interrupt(int irq, void *dev_id); +irqreturn_t acx_interrupt(int irq, void *dev_id); static void acxpci_handle_info_irq(acx_device_t * adev); void acxpci_set_interrupt_mask(acx_device_t * adev); @@ -2537,67 +2538,6 @@ void acxpci_irq_work(struct work_struct *work) } - -static irqreturn_t acxpci_interrupt(int irq, void *dev_id) -{ - acx_device_t *adev = dev_id; - unsigned long flags; - u16 irqreason; - u16 irqmasked; - - if (!adev) - return IRQ_NONE; - - // On a shared irq line, irqs should only be for us, when enabled them - if (!adev->irqs_active) - return IRQ_NONE; - - FN_ENTER; - - spin_lock_irqsave(&adev->spinlock, flags); - - /* We only get an irq-signal for IO_ACX_IRQ_MASK unmasked irq reasons. - * However masked irq reasons we still read with IO_ACX_IRQ_REASON or - * IO_ACX_IRQ_STATUS_NON_DES - */ - irqreason = read_reg16(adev, IO_ACX_IRQ_STATUS_NON_DES); - irqmasked = irqreason & ~adev->irq_mask; - log(L_IRQ, "irqstatus=%04X, irqmasked=%04X,\n", irqreason, irqmasked); - - if (unlikely(irqreason == 0xffff)) { - /* 0xffff value hints at missing hardware, - * so don't do anything. - * Not very clean, but other drivers do the same... */ - log(L_IRQ, "irqstatus=FFFF: Device removed?: IRQ_NONE\n"); - goto none; - } - - /* Our irq-signals are the ones, that were triggered by the IO_ACX_IRQ_MASK - * unmasked irqs. - */ - if (!irqmasked) { - /* We are on a shared IRQ line and it wasn't our IRQ */ - log(L_IRQ, "irqmasked zero: IRQ_NONE\n"); - goto none; - } - - // Mask all irqs, until we handle them. We will unmask them later in the tasklet. - write_reg16(adev, IO_ACX_IRQ_MASK, HOST_INT_MASK_ALL); - write_flush(adev); - acx_schedule_task(adev, 0); - - spin_unlock_irqrestore(&adev->spinlock, flags); - FN_EXIT0; - return IRQ_HANDLED; - - none: - - spin_unlock_irqrestore(&adev->spinlock, flags); - FN_EXIT0; - return IRQ_NONE; - -} - /* * acxpci_handle_info_irq */ @@ -3455,7 +3395,7 @@ acxpci_probe(struct pci_dev *pdev, const struct pci_device_id *id) } /* request shared IRQ handler */ - if (request_irq(adev->irq, acxpci_interrupt, IRQF_SHARED, KBUILD_MODNAME, + if (request_irq(adev->irq, acx_interrupt, IRQF_SHARED, KBUILD_MODNAME, adev)) { pr_acx("%s: request_irq FAILED\n", wiphy_name(adev->ieee->wiphy)); result = -EAGAIN; @@ -4073,7 +4013,7 @@ static __devinit int vlynq_probe(struct vlynq_device *vdev, /* request shared IRQ handler */ if (request_irq - (adev->irq, acxpci_interrupt, IRQF_SHARED, KBUILD_MODNAME, adev)) { + (adev->irq, acx_interrupt, IRQF_SHARED, KBUILD_MODNAME, adev)) { pr_acx("%s: request_irq FAILED\n", wiphy_name(adev->ieee->wiphy)); result = -EAGAIN; goto done; -- 1.7.8.1 |