diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-21 12:48:55 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-21 12:48:55 -0700 |
commit | c8d1a126924fcbc1d61ceb830226e0c7afdcc841 (patch) | |
tree | d3f3c850481c33b7f433175e83a189f958b1b868 /drivers/staging/vme | |
parent | d7dbf4ffee1c7a17e2e5b5f01efe76fbd1671db6 (diff) | |
parent | 107c161b7ddeeb7da43509cc6b29211885ccd9af (diff) |
Merge staging-next tree into Linus's latest version
Conflicts:
drivers/staging/arlan/arlan-main.c
drivers/staging/comedi/drivers/cb_das16_cs.c
drivers/staging/cx25821/cx25821-alsa.c
drivers/staging/dt3155/dt3155_drv.c
drivers/staging/hv/hv.c
drivers/staging/netwave/netwave_cs.c
drivers/staging/wavelan/wavelan.c
drivers/staging/wavelan/wavelan_cs.c
drivers/staging/wlags49_h2/wl_cs.c
This required a bit of hand merging due to the conflicts
that happened in the later .34-rc releases, as well as
some staging driver changing coming in through other trees
(v4l and pcmcia).
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/vme')
-rw-r--r-- | drivers/staging/vme/boards/vme_vmivme7805.c | 1 | ||||
-rw-r--r-- | drivers/staging/vme/bridges/vme_ca91cx42.c | 115 | ||||
-rw-r--r-- | drivers/staging/vme/bridges/vme_tsi148.c | 396 | ||||
-rw-r--r-- | drivers/staging/vme/bridges/vme_tsi148.h | 26 | ||||
-rw-r--r-- | drivers/staging/vme/devices/vme_user.c | 18 | ||||
-rw-r--r-- | drivers/staging/vme/vme.c | 4 |
6 files changed, 295 insertions, 265 deletions
diff --git a/drivers/staging/vme/boards/vme_vmivme7805.c b/drivers/staging/vme/boards/vme_vmivme7805.c index 843c9edde555..80eaa0c4fe1c 100644 --- a/drivers/staging/vme/boards/vme_vmivme7805.c +++ b/drivers/staging/vme/boards/vme_vmivme7805.c @@ -10,7 +10,6 @@ * option) any later version. */ -#include <linux/version.h> #include <linux/module.h> #include <linux/types.h> #include <linux/errno.h> diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c index b159ea58adf7..0c82eb47a28d 100644 --- a/drivers/staging/vme/bridges/vme_ca91cx42.c +++ b/drivers/staging/vme/bridges/vme_ca91cx42.c @@ -26,9 +26,9 @@ #include <linux/spinlock.h> #include <linux/sched.h> #include <linux/slab.h> -#include <asm/time.h> -#include <asm/io.h> -#include <asm/uaccess.h> +#include <linux/time.h> +#include <linux/io.h> +#include <linux/uaccess.h> #include "../vme.h" #include "../vme_bridge.h" @@ -94,31 +94,35 @@ static u32 ca91cx42_IACK_irqhandler(struct ca91cx42_driver *bridge) return CA91CX42_LINT_SW_IACK; } -static u32 ca91cx42_VERR_irqhandler(struct ca91cx42_driver *bridge) +static u32 ca91cx42_VERR_irqhandler(struct vme_bridge *ca91cx42_bridge) { int val; + struct ca91cx42_driver *bridge; + + bridge = ca91cx42_bridge->driver_priv; val = ioread32(bridge->base + DGCS); if (!(val & 0x00000800)) { - printk(KERN_ERR "ca91c042: ca91cx42_VERR_irqhandler DMA Read " - "Error DGCS=%08X\n", val); + dev_err(ca91cx42_bridge->parent, "ca91cx42_VERR_irqhandler DMA " + "Read Error DGCS=%08X\n", val); } return CA91CX42_LINT_VERR; } -static u32 ca91cx42_LERR_irqhandler(struct ca91cx42_driver *bridge) +static u32 ca91cx42_LERR_irqhandler(struct vme_bridge *ca91cx42_bridge) { int val; + struct ca91cx42_driver *bridge; - val = ioread32(bridge->base + DGCS); + bridge = ca91cx42_bridge->driver_priv; - if (!(val & 0x00000800)) { - printk(KERN_ERR "ca91c042: ca91cx42_LERR_irqhandler DMA Read " - "Error DGCS=%08X\n", val); + val = ioread32(bridge->base + DGCS); - } + if (!(val & 0x00000800)) + dev_err(ca91cx42_bridge->parent, "ca91cx42_LERR_irqhandler DMA " + "Read Error DGCS=%08X\n", val); return CA91CX42_LINT_LERR; } @@ -176,9 +180,9 @@ static irqreturn_t ca91cx42_irqhandler(int irq, void *ptr) if (stat & CA91CX42_LINT_SW_IACK) serviced |= ca91cx42_IACK_irqhandler(bridge); if (stat & CA91CX42_LINT_VERR) - serviced |= ca91cx42_VERR_irqhandler(bridge); + serviced |= ca91cx42_VERR_irqhandler(ca91cx42_bridge); if (stat & CA91CX42_LINT_LERR) - serviced |= ca91cx42_LERR_irqhandler(bridge); + serviced |= ca91cx42_LERR_irqhandler(ca91cx42_bridge); if (stat & (CA91CX42_LINT_VIRQ1 | CA91CX42_LINT_VIRQ2 | CA91CX42_LINT_VIRQ3 | CA91CX42_LINT_VIRQ4 | CA91CX42_LINT_VIRQ5 | CA91CX42_LINT_VIRQ6 | @@ -326,9 +330,12 @@ int ca91cx42_slave_set(struct vme_slave_resource *image, int enabled, unsigned int i, addr = 0, granularity; unsigned int temp_ctl = 0; unsigned int vme_bound, pci_offset; + struct vme_bridge *ca91cx42_bridge; struct ca91cx42_driver *bridge; - bridge = image->parent->driver_priv; + ca91cx42_bridge = image->parent; + + bridge = ca91cx42_bridge->driver_priv; i = image->number; @@ -353,7 +360,7 @@ int ca91cx42_slave_set(struct vme_slave_resource *image, int enabled, case VME_USER3: case VME_USER4: default: - printk(KERN_ERR "Invalid address space\n"); + dev_err(ca91cx42_bridge->parent, "Invalid address space\n"); return -EINVAL; break; } @@ -371,15 +378,18 @@ int ca91cx42_slave_set(struct vme_slave_resource *image, int enabled, granularity = 0x10000; if (vme_base & (granularity - 1)) { - printk(KERN_ERR "Invalid VME base alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME base " + "alignment\n"); return -EINVAL; } if (vme_bound & (granularity - 1)) { - printk(KERN_ERR "Invalid VME bound alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME bound " + "alignment\n"); return -EINVAL; } if (pci_offset & (granularity - 1)) { - printk(KERN_ERR "Invalid PCI Offset alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid PCI Offset " + "alignment\n"); return -EINVAL; } @@ -491,7 +501,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, /* Find pci_dev container of dev */ if (ca91cx42_bridge->parent == NULL) { - printk(KERN_ERR "Dev entry NULL\n"); + dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n"); return -EINVAL; } pdev = container_of(ca91cx42_bridge->parent, struct pci_dev, dev); @@ -515,8 +525,8 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, if (image->bus_resource.name == NULL) { image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_KERNEL); if (image->bus_resource.name == NULL) { - printk(KERN_ERR "Unable to allocate memory for resource" - " name\n"); + dev_err(ca91cx42_bridge->parent, "Unable to allocate " + "memory for resource name\n"); retval = -ENOMEM; goto err_name; } @@ -533,8 +543,8 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, &(image->bus_resource), size, size, PCIBIOS_MIN_MEM, 0, NULL, NULL); if (retval) { - printk(KERN_ERR "Failed to allocate mem resource for " - "window %d size 0x%lx start 0x%lx\n", + dev_err(ca91cx42_bridge->parent, "Failed to allocate mem " + "resource for window %d size 0x%lx start 0x%lx\n", image->number, (unsigned long)size, (unsigned long)image->bus_resource.start); goto err_resource; @@ -543,7 +553,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, image->kern_base = ioremap_nocache( image->bus_resource.start, size); if (image->kern_base == NULL) { - printk(KERN_ERR "Failed to remap resource\n"); + dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n"); retval = -ENOMEM; goto err_remap; } @@ -582,9 +592,12 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, unsigned int i, granularity = 0; unsigned int temp_ctl = 0; unsigned long long pci_bound, vme_offset, pci_base; + struct vme_bridge *ca91cx42_bridge; struct ca91cx42_driver *bridge; - bridge = image->parent->driver_priv; + ca91cx42_bridge = image->parent; + + bridge = ca91cx42_bridge->driver_priv; i = image->number; @@ -595,12 +608,14 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, /* Verify input data */ if (vme_base & (granularity - 1)) { - printk(KERN_ERR "Invalid VME Window alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME Window " + "alignment\n"); retval = -EINVAL; goto err_window; } if (size & (granularity - 1)) { - printk(KERN_ERR "Invalid VME Window alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME Window " + "alignment\n"); retval = -EINVAL; goto err_window; } @@ -614,8 +629,8 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, retval = ca91cx42_alloc_resource(image, size); if (retval) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Unable to allocate memory for resource " - "name\n"); + dev_err(ca91cx42_bridge->parent, "Unable to allocate memory " + "for resource name\n"); retval = -ENOMEM; goto err_res; } @@ -658,7 +673,7 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, break; default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid data width\n"); + dev_err(ca91cx42_bridge->parent, "Invalid data width\n"); retval = -EINVAL; goto err_dwidth; break; @@ -690,7 +705,7 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, case VME_USER4: default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid address space\n"); + dev_err(ca91cx42_bridge->parent, "Invalid address space\n"); retval = -EINVAL; goto err_aspace; break; @@ -921,12 +936,14 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, struct vme_dma_vme *vme_attr; dma_addr_t desc_ptr; int retval = 0; + struct device *dev; + + dev = list->parent->parent->parent; /* XXX descriptor must be aligned on 64-bit boundaries */ - entry = (struct ca91cx42_dma_entry *) - kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL); + entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL); if (entry == NULL) { - printk(KERN_ERR "Failed to allocate memory for dma resource " + dev_err(dev, "Failed to allocate memory for dma resource " "structure\n"); retval = -ENOMEM; goto err_mem; @@ -934,7 +951,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, /* Test descriptor alignment */ if ((unsigned long)&(entry->descriptor) & CA91CX42_DCPP_M) { - printk("Descriptor not aligned to 16 byte boundary as " + dev_err(dev, "Descriptor not aligned to 16 byte boundary as " "required: %p\n", &(entry->descriptor)); retval = -EINVAL; goto err_align; @@ -955,7 +972,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, if ((vme_attr->aspace & ~(VME_A16 | VME_A24 | VME_A32 | VME_USER1 | VME_USER2)) != 0) { - printk(KERN_ERR "Unsupported cycle type\n"); + dev_err(dev, "Unsupported cycle type\n"); retval = -EINVAL; goto err_aspace; } @@ -963,7 +980,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, if ((vme_attr->cycle & ~(VME_SCT | VME_BLT | VME_SUPER | VME_USER | VME_PROG | VME_DATA)) != 0) { - printk(KERN_ERR "Unsupported cycle type\n"); + dev_err(dev, "Unsupported cycle type\n"); retval = -EINVAL; goto err_cycle; } @@ -972,7 +989,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, if (!(((src->type == VME_DMA_PCI) && (dest->type == VME_DMA_VME)) || ((src->type == VME_DMA_VME) && (dest->type == VME_DMA_PCI)))) { - printk(KERN_ERR "Cannot perform transfer with this " + dev_err(dev, "Cannot perform transfer with this " "source-destination combination\n"); retval = -EINVAL; goto err_direct; @@ -997,7 +1014,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dctl |= CA91CX42_DCTL_VDW_D64; break; default: - printk(KERN_ERR "Invalid data width\n"); + dev_err(dev, "Invalid data width\n"); return -EINVAL; } @@ -1019,7 +1036,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dctl |= CA91CX42_DCTL_VAS_USER2; break; default: - printk(KERN_ERR "Invalid address space\n"); + dev_err(dev, "Invalid address space\n"); return -EINVAL; break; } @@ -1079,12 +1096,13 @@ int ca91cx42_dma_list_exec(struct vme_dma_list *list) int retval = 0; dma_addr_t bus_addr; u32 val; - + struct device *dev; struct ca91cx42_driver *bridge; ctrlr = list->parent; bridge = ctrlr->parent->driver_priv; + dev = ctrlr->parent->parent; mutex_lock(&(ctrlr->mtx)); @@ -1140,7 +1158,7 @@ int ca91cx42_dma_list_exec(struct vme_dma_list *list) if (val & (CA91CX42_DGCS_LERR | CA91CX42_DGCS_VERR | CA91CX42_DGCS_PERR)) { - printk(KERN_ERR "ca91c042: DMA Error. DGCS=%08X\n", val); + dev_err(dev, "ca91c042: DMA Error. DGCS=%08X\n", val); val = ioread32(bridge->base + DCTL); } @@ -1476,7 +1494,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* We want to support more than one of each bridge so we need to * dynamically allocate the bridge structure */ - ca91cx42_bridge = kmalloc(sizeof(struct vme_bridge), GFP_KERNEL); + ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); if (ca91cx42_bridge == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " @@ -1485,9 +1503,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_struct; } - memset(ca91cx42_bridge, 0, sizeof(struct vme_bridge)); - - ca91cx42_device = kmalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); + ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); if (ca91cx42_device == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " @@ -1496,8 +1512,6 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_driver; } - memset(ca91cx42_device, 0, sizeof(struct ca91cx42_driver)); - ca91cx42_bridge->driver_priv = ca91cx42_device; /* Enable the device */ @@ -1665,9 +1679,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev_info(&pdev->dev, "Slot ID is %d\n", ca91cx42_slot_get(ca91cx42_bridge)); - if (ca91cx42_crcsr_init(ca91cx42_bridge, pdev)) { + if (ca91cx42_crcsr_init(ca91cx42_bridge, pdev)) dev_err(&pdev->dev, "CR/CSR configuration failed.\n"); - } /* Need to save ca91cx42_bridge pointer locally in link list for use in * ca91cx42_remove() diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c index 783051f59f19..abe88a380b72 100644 --- a/drivers/staging/vme/bridges/vme_tsi148.c +++ b/drivers/staging/vme/bridges/vme_tsi148.c @@ -26,9 +26,9 @@ #include <linux/spinlock.h> #include <linux/sched.h> #include <linux/slab.h> -#include <asm/time.h> -#include <asm/io.h> -#include <asm/uaccess.h> +#include <linux/time.h> +#include <linux/io.h> +#include <linux/uaccess.h> #include "../vme.h" #include "../vme_bridge.h" @@ -40,27 +40,6 @@ static void tsi148_remove(struct pci_dev *); static void __exit tsi148_exit(void); -int tsi148_slave_set(struct vme_slave_resource *, int, unsigned long long, - unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t); -int tsi148_slave_get(struct vme_slave_resource *, int *, unsigned long long *, - unsigned long long *, dma_addr_t *, vme_address_t *, vme_cycle_t *); - -int tsi148_master_get(struct vme_master_resource *, int *, unsigned long long *, - unsigned long long *, vme_address_t *, vme_cycle_t *, vme_width_t *); -int tsi148_master_set(struct vme_master_resource *, int, unsigned long long, - unsigned long long, vme_address_t, vme_cycle_t, vme_width_t); -ssize_t tsi148_master_read(struct vme_master_resource *, void *, size_t, - loff_t); -ssize_t tsi148_master_write(struct vme_master_resource *, void *, size_t, - loff_t); -unsigned int tsi148_master_rmw(struct vme_master_resource *, unsigned int, - unsigned int, unsigned int, loff_t); -int tsi148_dma_list_add (struct vme_dma_list *, struct vme_dma_attr *, - struct vme_dma_attr *, size_t); -int tsi148_dma_list_exec(struct vme_dma_list *); -int tsi148_dma_list_empty(struct vme_dma_list *); -int tsi148_generate_irq(int, int); - /* Module parameter */ static int err_chk; static int geoid; @@ -122,7 +101,7 @@ static u32 tsi148_LM_irqhandler(struct tsi148_driver *bridge, u32 stat) u32 serviced = 0; for (i = 0; i < 4; i++) { - if(stat & TSI148_LCSR_INTS_LMS[i]) { + if (stat & TSI148_LCSR_INTS_LMS[i]) { /* We only enable interrupts if the callback is set */ bridge->lm_callback[i](i); serviced |= TSI148_LCSR_INTC_LMC[i]; @@ -137,16 +116,20 @@ static u32 tsi148_LM_irqhandler(struct tsi148_driver *bridge, u32 stat) * * XXX This functionality is not exposed up though API. */ -static u32 tsi148_MB_irqhandler(struct tsi148_driver *bridge, u32 stat) +static u32 tsi148_MB_irqhandler(struct vme_bridge *tsi148_bridge, u32 stat) { int i; u32 val; u32 serviced = 0; + struct tsi148_driver *bridge; + + bridge = tsi148_bridge->driver_priv; for (i = 0; i < 4; i++) { - if(stat & TSI148_LCSR_INTS_MBS[i]) { + if (stat & TSI148_LCSR_INTS_MBS[i]) { val = ioread32be(bridge->base + TSI148_GCSR_MBOX[i]); - printk("VME Mailbox %d received: 0x%x\n", i, val); + dev_err(tsi148_bridge->parent, "VME Mailbox %d received" + ": 0x%x\n", i, val); serviced |= TSI148_LCSR_INTC_MBC[i]; } } @@ -157,19 +140,22 @@ static u32 tsi148_MB_irqhandler(struct tsi148_driver *bridge, u32 stat) /* * Display error & status message when PERR (PCI) exception interrupt occurs. */ -static u32 tsi148_PERR_irqhandler(struct tsi148_driver *bridge) +static u32 tsi148_PERR_irqhandler(struct vme_bridge *tsi148_bridge) { - printk(KERN_ERR - "PCI Exception at address: 0x%08x:%08x, attributes: %08x\n", + struct tsi148_driver *bridge; + + bridge = tsi148_bridge->driver_priv; + + dev_err(tsi148_bridge->parent, "PCI Exception at address: 0x%08x:%08x, " + "attributes: %08x\n", ioread32be(bridge->base + TSI148_LCSR_EDPAU), ioread32be(bridge->base + TSI148_LCSR_EDPAL), - ioread32be(bridge->base + TSI148_LCSR_EDPAT) - ); - printk(KERN_ERR - "PCI-X attribute reg: %08x, PCI-X split completion reg: %08x\n", + ioread32be(bridge->base + TSI148_LCSR_EDPAT)); + + dev_err(tsi148_bridge->parent, "PCI-X attribute reg: %08x, PCI-X split " + "completion reg: %08x\n", ioread32be(bridge->base + TSI148_LCSR_EDPXA), - ioread32be(bridge->base + TSI148_LCSR_EDPXS) - ); + ioread32be(bridge->base + TSI148_LCSR_EDPXS)); iowrite32be(TSI148_LCSR_EDPAT_EDPCL, bridge->base + TSI148_LCSR_EDPAT); @@ -196,22 +182,21 @@ static u32 tsi148_VERR_irqhandler(struct vme_bridge *tsi148_bridge) reg_join(error_addr_high, error_addr_low, &error_addr); /* Check for exception register overflow (we have lost error data) */ - if(error_attrib & TSI148_LCSR_VEAT_VEOF) { - printk(KERN_ERR "VME Bus Exception Overflow Occurred\n"); + if (error_attrib & TSI148_LCSR_VEAT_VEOF) { + dev_err(tsi148_bridge->parent, "VME Bus Exception Overflow " + "Occurred\n"); } - error = (struct vme_bus_error *)kmalloc(sizeof (struct vme_bus_error), - GFP_ATOMIC); + error = kmalloc(sizeof(struct vme_bus_error), GFP_ATOMIC); if (error) { error->address = error_addr; error->attributes = error_attrib; list_add_tail(&(error->list), &(tsi148_bridge->vme_errors)); } else { - printk(KERN_ERR - "Unable to alloc memory for VMEbus Error reporting\n"); - printk(KERN_ERR - "VME Bus Error at address: 0x%llx, attributes: %08x\n", - error_addr, error_attrib); + dev_err(tsi148_bridge->parent, "Unable to alloc memory for " + "VMEbus Error reporting\n"); + dev_err(tsi148_bridge->parent, "VME Bus Error at address: " + "0x%llx, attributes: %08x\n", error_addr, error_attrib); } /* Clear Status */ @@ -244,10 +229,9 @@ static u32 tsi148_VIRQ_irqhandler(struct vme_bridge *tsi148_bridge, for (i = 7; i > 0; i--) { if (stat & (1 << i)) { /* - * Note: Even though the registers are defined - * as 32-bits in the spec, we only want to issue - * 8-bit IACK cycles on the bus, read from offset - * 3. + * Note: Even though the registers are defined as + * 32-bits in the spec, we only want to issue 8-bit + * IACK cycles on the bus, read from offset 3. */ vec = ioread8(bridge->base + TSI148_LCSR_VIACK[i] + 3); @@ -281,9 +265,8 @@ static irqreturn_t tsi148_irqhandler(int irq, void *ptr) /* Only look at unmasked interrupts */ stat &= enable; - if (unlikely(!stat)) { + if (unlikely(!stat)) return IRQ_NONE; - } /* Call subhandlers as appropriate */ /* DMA irqs */ @@ -298,11 +281,11 @@ static irqreturn_t tsi148_irqhandler(int irq, void *ptr) /* Mail box irqs */ if (stat & (TSI148_LCSR_INTS_MB3S | TSI148_LCSR_INTS_MB2S | TSI148_LCSR_INTS_MB1S | TSI148_LCSR_INTS_MB0S)) - serviced |= tsi148_MB_irqhandler(bridge, stat); + serviced |= tsi148_MB_irqhandler(tsi148_bridge, stat); /* PCI bus error */ if (stat & TSI148_LCSR_INTS_PERRS) - serviced |= tsi148_PERR_irqhandler(bridge); + serviced |= tsi148_PERR_irqhandler(tsi148_bridge); /* VME bus error */ if (stat & TSI148_LCSR_INTS_VERRS) @@ -346,8 +329,8 @@ static int tsi148_irq_init(struct vme_bridge *tsi148_bridge) IRQF_SHARED, driver_name, tsi148_bridge); if (result) { - dev_err(&pdev->dev, "Can't get assigned pci irq vector %02X\n", - pdev->irq); + dev_err(tsi148_bridge->parent, "Can't get assigned pci irq " + "vector %02X\n", pdev->irq); return result; } @@ -515,7 +498,9 @@ static struct vme_bus_error *tsi148_find_error(struct vme_bridge *tsi148_bridge, /* Iterate through errors */ list_for_each(err_pos, &(tsi148_bridge->vme_errors)) { vme_err = list_entry(err_pos, struct vme_bus_error, list); - if((vme_err->address >= address) && (vme_err->address < bound)){ + if ((vme_err->address >= address) && + (vme_err->address < bound)) { + valid = vme_err; break; } @@ -548,7 +533,9 @@ static void tsi148_clear_errors(struct vme_bridge *tsi148_bridge, list_for_each_safe(err_pos, temp, &(tsi148_bridge->vme_errors)) { vme_err = list_entry(err_pos, struct vme_bus_error, list); - if((vme_err->address >= address) && (vme_err->address < bound)){ + if ((vme_err->address >= address) && + (vme_err->address < bound)) { + list_del(err_pos); kfree(vme_err); } @@ -568,9 +555,11 @@ int tsi148_slave_set(struct vme_slave_resource *image, int enabled, unsigned int vme_bound_low, vme_bound_high; unsigned int pci_offset_low, pci_offset_high; unsigned long long vme_bound, pci_offset; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = image->parent->driver_priv; + tsi148_bridge = image->parent; + bridge = tsi148_bridge->driver_priv; i = image->number; @@ -597,7 +586,7 @@ int tsi148_slave_set(struct vme_slave_resource *image, int enabled, case VME_USER3: case VME_USER4: default: - printk("Invalid address space\n"); + dev_err(tsi148_bridge->parent, "Invalid address space\n"); return -EINVAL; break; } @@ -615,15 +604,16 @@ int tsi148_slave_set(struct vme_slave_resource *image, int enabled, reg_split(pci_offset, &pci_offset_high, &pci_offset_low); if (vme_base_low & (granularity - 1)) { - printk("Invalid VME base alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME base alignment\n"); return -EINVAL; } if (vme_bound_low & (granularity - 1)) { - printk("Invalid VME bound alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME bound alignment\n"); return -EINVAL; } if (pci_offset_low & (granularity - 1)) { - printk("Invalid PCI Offset alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid PCI Offset " + "alignment\n"); return -EINVAL; } @@ -815,12 +805,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, tsi148_bridge = image->parent; - /* Find pci_dev container of dev */ - if (tsi148_bridge->parent == NULL) { - printk("Dev entry NULL\n"); - return -EINVAL; - } - pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev); + pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev); existing_size = (unsigned long long)(image->bus_resource.end - image->bus_resource.start); @@ -839,15 +824,14 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, } /* Exit here if size is zero */ - if (size == 0) { + if (size == 0) return 0; - } if (image->bus_resource.name == NULL) { image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_KERNEL); if (image->bus_resource.name == NULL) { - printk(KERN_ERR "Unable to allocate memory for resource" - " name\n"); + dev_err(tsi148_bridge->parent, "Unable to allocate " + "memory for resource name\n"); retval = -ENOMEM; goto err_name; } @@ -864,8 +848,8 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, &(image->bus_resource), size, size, PCIBIOS_MIN_MEM, 0, NULL, NULL); if (retval) { - printk(KERN_ERR "Failed to allocate mem resource for " - "window %d size 0x%lx start 0x%lx\n", + dev_err(tsi148_bridge->parent, "Failed to allocate mem " + "resource for window %d size 0x%lx start 0x%lx\n", image->number, (unsigned long)size, (unsigned long)image->bus_resource.start); goto err_resource; @@ -874,7 +858,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, image->kern_base = ioremap_nocache( image->bus_resource.start, size); if (image->kern_base == NULL) { - printk(KERN_ERR "Failed to remap resource\n"); + dev_err(tsi148_bridge->parent, "Failed to remap resource\n"); retval = -ENOMEM; goto err_remap; } @@ -907,7 +891,7 @@ static void tsi148_free_resource(struct vme_master_resource *image) /* * Set the attributes of an outbound window. */ -int tsi148_master_set( struct vme_master_resource *image, int enabled, +int tsi148_master_set(struct vme_master_resource *image, int enabled, unsigned long long vme_base, unsigned long long size, vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth) { @@ -918,19 +902,24 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, unsigned int pci_bound_low, pci_bound_high; unsigned int vme_offset_low, vme_offset_high; unsigned long long pci_bound, vme_offset, pci_base; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = image->parent->driver_priv; + tsi148_bridge = image->parent; + + bridge = tsi148_bridge->driver_priv; /* Verify input data */ if (vme_base & 0xFFFF) { - printk(KERN_ERR "Invalid VME Window alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME Window " + "alignment\n"); retval = -EINVAL; goto err_window; } if ((size == 0) && (enabled != 0)) { - printk(KERN_ERR "Size must be non-zero for enabled windows\n"); + dev_err(tsi148_bridge->parent, "Size must be non-zero for " + "enabled windows\n"); retval = -EINVAL; goto err_window; } @@ -944,7 +933,7 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, retval = tsi148_alloc_resource(image, size); if (retval) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Unable to allocate memory for " + dev_err(tsi148_bridge->parent, "Unable to allocate memory for " "resource\n"); goto err_res; } @@ -971,19 +960,20 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, if (pci_base_low & 0xFFFF) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid PCI base alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid PCI base alignment\n"); retval = -EINVAL; goto err_gran; } if (pci_bound_low & 0xFFFF) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid PCI bound alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid PCI bound alignment\n"); retval = -EINVAL; goto err_gran; } if (vme_offset_low & 0xFFFF) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid VME Offset alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME Offset " + "alignment\n"); retval = -EINVAL; goto err_gran; } @@ -1029,8 +1019,8 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, temp_ctl |= TSI148_LCSR_OTAT_TM_2eSST; } if (cycle & VME_2eSSTB) { - printk(KERN_WARNING "Currently not setting Broadcast Select " - "Registers\n"); + dev_warn(tsi148_bridge->parent, "Currently not setting " + "Broadcast Select Registers\n"); temp_ctl &= ~TSI148_LCSR_OTAT_TM_M; temp_ctl |= TSI148_LCSR_OTAT_TM_2eSSTB; } @@ -1046,7 +1036,7 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, break; default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid data width\n"); + dev_err(tsi148_bridge->parent, "Invalid data width\n"); retval = -EINVAL; goto err_dwidth; } @@ -1083,7 +1073,7 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, break; default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid address space\n"); + dev_err(tsi148_bridge->parent, "Invalid address space\n"); retval = -EINVAL; goto err_aspace; break; @@ -1137,7 +1127,7 @@ err_window: * * XXX Not parsing prefetch information. */ -int __tsi148_master_get( struct vme_master_resource *image, int *enabled, +int __tsi148_master_get(struct vme_master_resource *image, int *enabled, unsigned long long *vme_base, unsigned long long *size, vme_address_t *aspace, vme_cycle_t *cycle, vme_width_t *dwidth) { @@ -1214,17 +1204,17 @@ int __tsi148_master_get( struct vme_master_resource *image, int *enabled, *cycle |= VME_2eSST320; /* Setup cycle types */ - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_SCT) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_SCT) *cycle |= VME_SCT; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_BLT) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_BLT) *cycle |= VME_BLT; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_MBLT) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_MBLT) *cycle |= VME_MBLT; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eVME) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eVME) *cycle |= VME_2eVME; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eSST) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSST) *cycle |= VME_2eSST; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eSSTB) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSSTB) *cycle |= VME_2eSSTB; if (ctl & TSI148_LCSR_OTAT_SUP) @@ -1247,7 +1237,7 @@ int __tsi148_master_get( struct vme_master_resource *image, int *enabled, } -int tsi148_master_get( struct vme_master_resource *image, int *enabled, +int tsi148_master_get(struct vme_master_resource *image, int *enabled, unsigned long long *vme_base, unsigned long long *size, vme_address_t *aspace, vme_cycle_t *cycle, vme_width_t *dwidth) { @@ -1289,7 +1279,7 @@ ssize_t tsi148_master_read(struct vme_master_resource *image, void *buf, vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset, count); - if(vme_err != NULL) { + if (vme_err != NULL) { dev_err(image->parent->parent, "First VME read error detected " "an at address 0x%llx\n", vme_err->address); retval = vme_err->address - (vme_base + offset); @@ -1352,9 +1342,9 @@ ssize_t tsi148_master_write(struct vme_master_resource *image, void *buf, vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset, count); - if(vme_err != NULL) { - printk("First VME write error detected an at address 0x%llx\n", - vme_err->address); + if (vme_err != NULL) { + dev_warn(tsi148_bridge->parent, "First VME write error detected" + " an at address 0x%llx\n", vme_err->address); retval = vme_err->address - (vme_base + offset); /* Clear down save errors in this address range */ tsi148_clear_errors(tsi148_bridge, aspace, vme_base + offset, @@ -1428,8 +1418,8 @@ unsigned int tsi148_master_rmw(struct vme_master_resource *image, return result; } -static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, - vme_cycle_t cycle, vme_width_t dwidth) +static int tsi148_dma_set_vme_src_attributes(struct device *dev, u32 *attr, + vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth) { /* Setup 2eSST speeds */ switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) { @@ -1445,23 +1435,24 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, } /* Setup cycle types */ - if (cycle & VME_SCT) { + if (cycle & VME_SCT) *attr |= TSI148_LCSR_DSAT_TM_SCT; - } - if (cycle & VME_BLT) { + + if (cycle & VME_BLT) *attr |= TSI148_LCSR_DSAT_TM_BLT; - } - if (cycle & VME_MBLT) { + + if (cycle & VME_MBLT) *attr |= TSI148_LCSR_DSAT_TM_MBLT; - } - if (cycle & VME_2eVME) { + + if (cycle & VME_2eVME) *attr |= TSI148_LCSR_DSAT_TM_2eVME; - } - if (cycle & VME_2eSST) { + + if (cycle & VME_2eSST) *attr |= TSI148_LCSR_DSAT_TM_2eSST; - } + if (cycle & VME_2eSSTB) { - printk("Currently not setting Broadcast Select Registers\n"); + dev_err(dev, "Currently not setting Broadcast Select " + "Registers\n"); *attr |= TSI148_LCSR_DSAT_TM_2eSSTB; } @@ -1474,7 +1465,7 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DSAT_DBW_32; break; default: - printk("Invalid data width\n"); + dev_err(dev, "Invalid data width\n"); return -EINVAL; } @@ -1508,7 +1499,7 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DSAT_AMODE_USER4; break; default: - printk("Invalid address space\n"); + dev_err(dev, "Invalid address space\n"); return -EINVAL; break; } @@ -1521,8 +1512,8 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, return 0; } -static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, - vme_cycle_t cycle, vme_width_t dwidth) +static int tsi148_dma_set_vme_dest_attributes(struct device *dev, u32 *attr, + vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth) { /* Setup 2eSST speeds */ switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) { @@ -1538,23 +1529,24 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, } /* Setup cycle types */ - if (cycle & VME_SCT) { + if (cycle & VME_SCT) *attr |= TSI148_LCSR_DDAT_TM_SCT; - } - if (cycle & VME_BLT) { + + if (cycle & VME_BLT) *attr |= TSI148_LCSR_DDAT_TM_BLT; - } - if (cycle & VME_MBLT) { + + if (cycle & VME_MBLT) *attr |= TSI148_LCSR_DDAT_TM_MBLT; - } - if (cycle & VME_2eVME) { + + if (cycle & VME_2eVME) *attr |= TSI148_LCSR_DDAT_TM_2eVME; - } - if (cycle & VME_2eSST) { + + if (cycle & VME_2eSST) *attr |= TSI148_LCSR_DDAT_TM_2eSST; - } + if (cycle & VME_2eSSTB) { - printk("Currently not setting Broadcast Select Registers\n"); + dev_err(dev, "Currently not setting Broadcast Select " + "Registers\n"); *attr |= TSI148_LCSR_DDAT_TM_2eSSTB; } @@ -1567,7 +1559,7 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DDAT_DBW_32; break; default: - printk("Invalid data width\n"); + dev_err(dev, "Invalid data width\n"); return -EINVAL; } @@ -1601,7 +1593,7 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DDAT_AMODE_USER4; break; default: - printk("Invalid address space\n"); + dev_err(dev, "Invalid address space\n"); return -EINVAL; break; } @@ -1617,7 +1609,7 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, /* * Add a link list descriptor to the list */ -int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, +int tsi148_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, struct vme_dma_attr *dest, size_t count) { struct tsi148_dma_entry *entry, *prev; @@ -1627,21 +1619,24 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, struct vme_dma_vme *vme_attr; dma_addr_t desc_ptr; int retval = 0; + struct vme_bridge *tsi148_bridge; + + tsi148_bridge = list->parent->parent; /* Descriptor must be aligned on 64-bit boundaries */ - entry = (struct tsi148_dma_entry *)kmalloc( - sizeof(struct tsi148_dma_entry), GFP_KERNEL); + entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL); if (entry == NULL) { - printk("Failed to allocate memory for dma resource " - "structure\n"); + dev_err(tsi148_bridge->parent, "Failed to allocate memory for " + "dma resource structure\n"); retval = -ENOMEM; goto err_mem; } /* Test descriptor alignment */ if ((unsigned long)&(entry->descriptor) & 0x7) { - printk("Descriptor not aligned to 8 byte boundary as " - "required: %p\n", &(entry->descriptor)); + dev_err(tsi148_bridge->parent, "Descriptor not aligned to 8 " + "byte boundary as required: %p\n", + &(entry->descriptor)); retval = -EINVAL; goto err_align; } @@ -1659,13 +1654,13 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dsal = pattern_attr->pattern; entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_PAT; /* Default behaviour is 32 bit pattern */ - if (pattern_attr->type & VME_DMA_PATTERN_BYTE) { + if (pattern_attr->type & VME_DMA_PATTERN_BYTE) entry->descriptor.dsat |= TSI148_LCSR_DSAT_PSZ; - } + /* It seems that the default behaviour is to increment */ - if ((pattern_attr->type & VME_DMA_PATTERN_INCREMENT) == 0) { + if ((pattern_attr->type & VME_DMA_PATTERN_INCREMENT) == 0) entry->descriptor.dsat |= TSI148_LCSR_DSAT_NIN; - } + break; case VME_DMA_PCI: pci_attr = (struct vme_dma_pci *)src->private; @@ -1686,13 +1681,13 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_VME; retval = tsi148_dma_set_vme_src_attributes( - &(entry->descriptor.dsat), vme_attr->aspace, - vme_attr->cycle, vme_attr->dwidth); - if(retval < 0 ) + tsi148_bridge->parent, &(entry->descriptor.dsat), + vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth); + if (retval < 0) goto err_source; break; default: - printk("Invalid source type\n"); + dev_err(tsi148_bridge->parent, "Invalid source type\n"); retval = -EINVAL; goto err_source; break; @@ -1724,13 +1719,13 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.ddat = TSI148_LCSR_DDAT_TYP_VME; retval = tsi148_dma_set_vme_dest_attributes( - &(entry->descriptor.ddat), vme_attr->aspace, - vme_attr->cycle, vme_attr->dwidth); - if(retval < 0 ) + tsi148_bridge->parent, &(entry->descriptor.ddat), + vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth); + if (retval < 0) goto err_dest; break; default: - printk("Invalid destination type\n"); + dev_err(tsi148_bridge->parent, "Invalid destination type\n"); retval = -EINVAL; goto err_dest; break; @@ -1743,7 +1738,7 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, list_add_tail(&(entry->list), &(list->entries)); /* Fill out previous descriptors "Next Address" */ - if(entry->list.prev != &(list->entries)){ + if (entry->list.prev != &(list->entries)) { prev = list_entry(entry->list.prev, struct tsi148_dma_entry, list); /* We need the bus address for the pointer */ @@ -1795,17 +1790,20 @@ int tsi148_dma_list_exec(struct vme_dma_list *list) dma_addr_t bus_addr; u32 bus_addr_high, bus_addr_low; u32 val, dctlreg = 0; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; ctrlr = list->parent; - bridge = ctrlr->parent->driver_priv; + tsi148_bridge = ctrlr->parent; + + bridge = tsi148_bridge->driver_priv; mutex_lock(&(ctrlr->mtx)); channel = ctrlr->number; - if (! list_empty(&(ctrlr->running))) { + if (!list_empty(&(ctrlr->running))) { /* * XXX We have an active DMA transfer and currently haven't * sorted out the mechanism for "pending" DMA transfers. @@ -1847,7 +1845,7 @@ int tsi148_dma_list_exec(struct vme_dma_list *list) TSI148_LCSR_OFFSET_DSTA); if (val & TSI148_LCSR_DSTA_VBE) { - printk(KERN_ERR "tsi148: DMA Error. DSTA=%08X\n", val); + dev_err(tsi148_bridge->parent, "DMA Error. DSTA=%08X\n", val); retval = -EIO; } @@ -1867,7 +1865,7 @@ int tsi148_dma_list_exec(struct vme_dma_list *list) int tsi148_dma_list_empty(struct vme_dma_list *list) { struct list_head *pos, *temp; - struct tsi148_dma_entry *entry; + struct tsi148_dma_entry *entry; /* detach and free each entry */ list_for_each_safe(pos, temp, &(list->entries)) { @@ -1876,7 +1874,7 @@ int tsi148_dma_list_empty(struct vme_dma_list *list) kfree(entry); } - return (0); + return 0; } /* @@ -1891,9 +1889,12 @@ int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, { u32 lm_base_high, lm_base_low, lm_ctl = 0; int i; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = lm->parent->driver_priv; + tsi148_bridge = lm->parent; + + bridge = tsi148_bridge->driver_priv; mutex_lock(&(lm->mtx)); @@ -1901,8 +1902,8 @@ int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, for (i = 0; i < lm->monitors; i++) { if (bridge->lm_callback[i] != NULL) { mutex_unlock(&(lm->mtx)); - printk("Location monitor callback attached, can't " - "reset\n"); + dev_err(tsi148_bridge->parent, "Location monitor " + "callback attached, can't reset\n"); return -EBUSY; } } @@ -1922,7 +1923,7 @@ int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, break; default: mutex_unlock(&(lm->mtx)); - printk("Invalid address space\n"); + dev_err(tsi148_bridge->parent, "Invalid address space\n"); return -EINVAL; break; } @@ -1969,18 +1970,18 @@ int tsi148_lm_get(struct vme_lm_resource *lm, unsigned long long *lm_base, if (lm_ctl & TSI148_LCSR_LMAT_EN) enabled = 1; - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A16) { + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A16) *aspace |= VME_A16; - } - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A24) { + + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A24) *aspace |= VME_A24; - } - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A32) { + + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A32) *aspace |= VME_A32; - } - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A64) { + + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A64) *aspace |= VME_A64; - } + if (lm_ctl & TSI148_LCSR_LMAT_SUPR) *cycle |= VME_SUPER; @@ -2005,9 +2006,12 @@ int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, void (*callback)(int)) { u32 lm_ctl, tmp; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = lm->parent->driver_priv; + tsi148_bridge = lm->parent; + + bridge = tsi148_bridge->driver_priv; mutex_lock(&(lm->mtx)); @@ -2015,14 +2019,15 @@ int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, lm_ctl = ioread32be(bridge->base + TSI148_LCSR_LMAT); if ((lm_ctl & (TSI148_LCSR_LMAT_PGM | TSI148_LCSR_LMAT_DATA)) == 0) { mutex_unlock(&(lm->mtx)); - printk("Location monitor not properly configured\n"); + dev_err(tsi148_bridge->parent, "Location monitor not properly " + "configured\n"); return -EINVAL; } /* Check that a callback isn't already attached */ if (bridge->lm_callback[monitor] != NULL) { mutex_unlock(&(lm->mtx)); - printk("Existing callback attached\n"); + dev_err(tsi148_bridge->parent, "Existing callback attached\n"); return -EBUSY; } @@ -2094,7 +2099,7 @@ int tsi148_lm_detach(struct vme_lm_resource *lm, int monitor) */ int tsi148_slot_get(struct vme_bridge *tsi148_bridge) { - u32 slot = 0; + u32 slot = 0; struct tsi148_driver *bridge; bridge = tsi148_bridge->driver_priv; @@ -2139,8 +2144,8 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge, bridge->crcsr_kernel = pci_alloc_consistent(pdev, VME_CRCSR_BUF_SIZE, &(bridge->crcsr_bus)); if (bridge->crcsr_kernel == NULL) { - dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR " - "image\n"); + dev_err(tsi148_bridge->parent, "Failed to allocate memory for " + "CR/CSR image\n"); return -ENOMEM; } @@ -2159,29 +2164,30 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge, if (cbar != vstat) { cbar = vstat; - dev_info(&pdev->dev, "Setting CR/CSR offset\n"); + dev_info(tsi148_bridge->parent, "Setting CR/CSR offset\n"); iowrite32be(cbar<<3, bridge->base + TSI148_CBAR); } - dev_info(&pdev->dev, "CR/CSR Offset: %d\n", cbar); + dev_info(tsi148_bridge->parent, "CR/CSR Offset: %d\n", cbar); crat = ioread32be(bridge->base + TSI148_LCSR_CRAT); if (crat & TSI148_LCSR_CRAT_EN) { - dev_info(&pdev->dev, "Enabling CR/CSR space\n"); + dev_info(tsi148_bridge->parent, "Enabling CR/CSR space\n"); iowrite32be(crat | TSI148_LCSR_CRAT_EN, bridge->base + TSI148_LCSR_CRAT); } else - dev_info(&pdev->dev, "CR/CSR already enabled\n"); + dev_info(tsi148_bridge->parent, "CR/CSR already enabled\n"); /* If we want flushed, error-checked writes, set up a window * over the CR/CSR registers. We read from here to safely flush * through VME writes. */ - if(err_chk) { + if (err_chk) { retval = tsi148_master_set(bridge->flush_image, 1, (vstat * 0x80000), 0x80000, VME_CRCSR, VME_SCT, VME_D16); if (retval) - dev_err(&pdev->dev, "Configuring flush image failed\n"); + dev_err(tsi148_bridge->parent, "Configuring flush image" + " failed\n"); } return 0; @@ -2224,8 +2230,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* If we want to support more than one of each bridge, we need to * dynamically generate this so we get one per device */ - tsi148_bridge = (struct vme_bridge *)kmalloc(sizeof(struct vme_bridge), - GFP_KERNEL); + tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); if (tsi148_bridge == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " "structure\n"); @@ -2233,9 +2238,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_struct; } - memset(tsi148_bridge, 0, sizeof(struct vme_bridge)); - - tsi148_device = kmalloc(sizeof(struct tsi148_driver), GFP_KERNEL); + tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL); if (tsi148_device == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " "structure\n"); @@ -2243,8 +2246,6 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_driver; } - memset(tsi148_device, 0, sizeof(struct tsi148_driver)); - tsi148_bridge->driver_priv = tsi148_device; /* Enable the device */ @@ -2301,10 +2302,10 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) * hence have one less master window resource available. */ master_num = TSI148_MAX_MASTER; - if(err_chk){ + if (err_chk) { master_num--; - tsi148_device->flush_image = (struct vme_master_resource *) + tsi148_device->flush_image = kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL); if (tsi148_device->flush_image == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for " @@ -2331,8 +2332,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add master windows to list */ INIT_LIST_HEAD(&(tsi148_bridge->master_resources)); for (i = 0; i < master_num; i++) { - master_image = (struct vme_master_resource *)kmalloc( - sizeof(struct vme_master_resource), GFP_KERNEL); + master_image = kmalloc(sizeof(struct vme_master_resource), + GFP_KERNEL); if (master_image == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for " "master resource structure\n"); @@ -2360,8 +2361,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add slave windows to list */ INIT_LIST_HEAD(&(tsi148_bridge->slave_resources)); for (i = 0; i < TSI148_MAX_SLAVE; i++) { - slave_image = (struct vme_slave_resource *)kmalloc( - sizeof(struct vme_slave_resource), GFP_KERNEL); + slave_image = kmalloc(sizeof(struct vme_slave_resource), + GFP_KERNEL); if (slave_image == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for " "slave resource structure\n"); @@ -2386,8 +2387,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add dma engines to list */ INIT_LIST_HEAD(&(tsi148_bridge->dma_resources)); for (i = 0; i < TSI148_MAX_DMA; i++) { - dma_ctrlr = (struct vme_dma_resource *)kmalloc( - sizeof(struct vme_dma_resource), GFP_KERNEL); + dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), + GFP_KERNEL); if (dma_ctrlr == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for " "dma resource structure\n"); @@ -2444,7 +2445,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) data = ioread32be(tsi148_device->base + TSI148_LCSR_VSTAT); dev_info(&pdev->dev, "Board is%s the VME system controller\n", - (data & TSI148_LCSR_VSTAT_SCONS)? "" : " not"); + (data & TSI148_LCSR_VSTAT_SCONS) ? "" : " not"); if (!geoid) dev_info(&pdev->dev, "VME geographical address is %d\n", data & TSI148_LCSR_VSTAT_GA_M); @@ -2504,7 +2505,8 @@ err_slave: err_master: /* resources are stored in link list */ list_for_each(pos, &(tsi148_bridge->master_resources)) { - master_image = list_entry(pos, struct vme_master_resource, list); + master_image = list_entry(pos, struct vme_master_resource, + list); list_del(pos); kfree(master_image); } @@ -2624,8 +2626,6 @@ static void tsi148_remove(struct pci_dev *pdev) static void __exit tsi148_exit(void) { pci_unregister_driver(&tsi148_driver); - - printk(KERN_DEBUG "Driver removed.\n"); } MODULE_PARM_DESC(err_chk, "Check for VME errors on reads and writes"); diff --git a/drivers/staging/vme/bridges/vme_tsi148.h b/drivers/staging/vme/bridges/vme_tsi148.h index 9e5f7fa1d744..bda64ef85754 100644 --- a/drivers/staging/vme/bridges/vme_tsi148.h +++ b/drivers/staging/vme/bridges/vme_tsi148.h @@ -579,7 +579,7 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, /* * Memory Base Address Lower Reg (CRG + $010) */ -#define TSI148_PCFS_MBARL_BASEL_M (0xFFFFF<<12) /* Base Addr Lower Mask */ +#define TSI148_PCFS_MBARL_BASEL_M (0xFFFFF<<12) /* Base Addr Lower Mask */ #define TSI148_PCFS_MBARL_PRE (1<<3) /* Prefetch */ #define TSI148_PCFS_MBARL_MTYPE_M (3<<1) /* Memory Type Mask */ #define TSI148_PCFS_MBARL_IOMEM (1<<0) /* I/O Space Indicator */ @@ -615,7 +615,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, */ #define TSI148_PCFS_PCIXSTAT_RSCEM (1<<29) /* Recieved Split Comp Error */ #define TSI148_PCFS_PCIXSTAT_DMCRS_M (7<<26) /* max Cumulative Read Size */ -#define TSI148_PCFS_PCIXSTAT_DMOST_M (7<<23) /* max outstanding Split Trans */ +#define TSI148_PCFS_PCIXSTAT_DMOST_M (7<<23) /* max outstanding Split Trans + */ #define TSI148_PCFS_PCIXSTAT_DMMRC_M (3<<21) /* max mem read byte count */ #define TSI148_PCFS_PCIXSTAT_DC (1<<20) /* Device Complexity */ #define TSI148_PCFS_PCIXSTAT_USC (1<<19) /* Unexpected Split comp */ @@ -703,7 +704,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VMCTRL_RMWEN (1<<20) /* RMW Enable */ -#define TSI148_LCSR_VMCTRL_ATO_M (7<<16) /* Master Access Time-out Mask */ +#define TSI148_LCSR_VMCTRL_ATO_M (7<<16) /* Master Access Time-out Mask + */ #define TSI148_LCSR_VMCTRL_ATO_32 (0<<16) /* 32 us */ #define TSI148_LCSR_VMCTRL_ATO_128 (1<<16) /* 128 us */ #define TSI148_LCSR_VMCTRL_ATO_512 (2<<16) /* 512 us */ @@ -733,14 +735,16 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VMCTRL_VTON_256 (6<<8) /* 256us */ #define TSI148_LCSR_VMCTRL_VTON_512 (7<<8) /* 512us */ -#define TSI148_LCSR_VMCTRL_VREL_M (3<<3) /* VMEbus Master Rel Mode Mask */ +#define TSI148_LCSR_VMCTRL_VREL_M (3<<3) /* VMEbus Master Rel Mode Mask + */ #define TSI148_LCSR_VMCTRL_VREL_T_D (0<<3) /* Time on or Done */ #define TSI148_LCSR_VMCTRL_VREL_T_R_D (1<<3) /* Time on and REQ or Done */ #define TSI148_LCSR_VMCTRL_VREL_T_B_D (2<<3) /* Time on and BCLR or Done */ #define TSI148_LCSR_VMCTRL_VREL_T_D_R (3<<3) /* Time on or Done and REQ */ #define TSI148_LCSR_VMCTRL_VFAIR (1<<2) /* VMEbus Master Fair Mode */ -#define TSI148_LCSR_VMCTRL_VREQL_M (3<<0) /* VMEbus Master Req Level Mask */ +#define TSI148_LCSR_VMCTRL_VREQL_M (3<<0) /* VMEbus Master Req Level Mask + */ /* * VMEbus Control Register CRG+$238 @@ -762,7 +766,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VCTRL_DLT_16384 (0xB<<24) /* 16384 VCLKS */ #define TSI148_LCSR_VCTRL_DLT_32768 (0xC<<24) /* 32768 VCLKS */ -#define TSI148_LCSR_VCTRL_NERBB (1<<20) /* No Early Release of Bus Busy */ +#define TSI148_LCSR_VCTRL_NERBB (1<<20) /* No Early Release of Bus Busy + */ #define TSI148_LCSR_VCTRL_SRESET (1<<17) /* System Reset */ #define TSI148_LCSR_VCTRL_LRESET (1<<16) /* Local Reset */ @@ -773,7 +778,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VCTRL_ATOEN (1<<7) /* Arbiter Time-out Enable */ #define TSI148_LCSR_VCTRL_ROBIN (1<<6) /* VMEbus Round Robin */ -#define TSI148_LCSR_VCTRL_GTO_M (7<<0) /* VMEbus Global Time-out Mask */ +#define TSI148_LCSR_VCTRL_GTO_M (7<<0) /* VMEbus Global Time-out Mask + */ #define TSI148_LCSR_VCTRL_GTO_8 (0<<0) /* 8 us */ #define TSI148_LCSR_VCTRL_GTO_16 (1<<0) /* 16 us */ #define TSI148_LCSR_VCTRL_GTO_32 (2<<0) /* 32 us */ @@ -794,7 +800,7 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VSTAT_ACFAILS (1<<9) /* AC fail status */ #define TSI148_LCSR_VSTAT_SCONS (1<<8) /* System Cont Status */ #define TSI148_LCSR_VSTAT_GAP (1<<5) /* Geographic Addr Parity */ -#define TSI148_LCSR_VSTAT_GA_M (0x1F<<0) /* Geographic Addr Mask */ +#define TSI148_LCSR_VSTAT_GA_M (0x1F<<0) /* Geographic Addr Mask */ /* * PCI Configuration Status Register CRG+$240 @@ -1341,7 +1347,7 @@ static const int TSI148_LCSR_INTC_MBC[4] = { TSI148_LCSR_INTC_MB0C, * DMA Next Link Address Lower */ #define TSI148_LCSR_DNLAL_DNLAL_M (0x3FFFFFF<<6) /* Address Mask */ -#define TSI148_LCSR_DNLAL_LLA (1<<0) /* Last Link Address Indicator */ +#define TSI148_LCSR_DNLAL_LLA (1<<0) /* Last Link Address Indicator */ /* * DMA 2eSST Broadcast Select @@ -1371,7 +1377,7 @@ static const int TSI148_LCSR_INTC_MBC[4] = { TSI148_LCSR_INTC_MB0C, #define TSI148_GCSR_GCTRL_MBI0S (1<<0) /* Mail box 0 Int Status */ #define TSI148_GCSR_GAP (1<<5) /* Geographic Addr Parity */ -#define TSI148_GCSR_GA_M (0x1F<<0) /* Geographic Address Mask */ +#define TSI148_GCSR_GA_M (0x1F<<0) /* Geographic Address Mask */ /* * CR/CSR Register Group diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 1ab9a985dfb9..bc16fc070fd3 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -31,6 +31,7 @@ #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/syscalls.h> +#include <linux/smp_lock.h> #include <linux/types.h> #include <asm/io.h> @@ -130,8 +131,7 @@ static int vme_user_release(struct inode *, struct file *); static ssize_t vme_user_read(struct file *, char *, size_t, loff_t *); static ssize_t vme_user_write(struct file *, const char *, size_t, loff_t *); static loff_t vme_user_llseek(struct file *, loff_t, int); -static int vme_user_ioctl(struct inode *, struct file *, unsigned int, - unsigned long); +static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long); static int __init vme_user_probe(struct device *, int, int); static int __exit vme_user_remove(struct device *, int, int); @@ -142,7 +142,7 @@ static struct file_operations vme_user_fops = { .read = vme_user_read, .write = vme_user_write, .llseek = vme_user_llseek, - .ioctl = vme_user_ioctl, + .unlocked_ioctl = vme_user_unlocked_ioctl, }; @@ -555,6 +555,18 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, return -EINVAL; } +static long +vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret; + + lock_kernel(); + ret = vme_user_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); + unlock_kernel(); + + return ret; +} + /* * Unallocate a previously allocated buffer diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index 934283a19ca5..093fbffbf557 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -36,7 +36,7 @@ /* Bitmask and mutex to keep track of bridge numbers */ static unsigned int vme_bus_numbers; -DEFINE_MUTEX(vme_bus_num_mtx); +static DEFINE_MUTEX(vme_bus_num_mtx); static void __exit vme_exit(void); static int __init vme_init(void); @@ -1408,7 +1408,7 @@ EXPORT_SYMBOL(vme_unregister_driver); /* - Bus Registration ------------------------------------------------------ */ -int vme_calc_slot(struct device *dev) +static int vme_calc_slot(struct device *dev) { struct vme_bridge *bridge; int num; |