Signed-off-by: Joe Perches <joe@xxxxxxxxxxx> --- drivers/staging/vme/vme.c | 175 +++++++++++++++++++++++---------------------- 1 files changed, 88 insertions(+), 87 deletions(-) diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index 477a1ad..bcee1c8 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -13,6 +13,8 @@ * option) any later version. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/version.h> #include <linux/module.h> #include <linux/moduleparam.h> @@ -74,7 +76,7 @@ static struct vme_bridge *find_bridge(struct vme_resource *resource) list)->parent; break; default: - printk(KERN_ERR "Unknown resource type\n"); + pr_err("Unknown resource type\n"); return NULL; break; } @@ -94,19 +96,19 @@ void * vme_alloc_consistent(struct vme_resource *resource, size_t size, struct pci_dev *pdev; if(resource == NULL) { - printk("No resource\n"); + pr_info("No resource\n"); return NULL; } bridge = find_bridge(resource); if(bridge == NULL) { - printk("Can't find bridge\n"); + pr_info("Can't find bridge\n"); return NULL; } /* Find pci_dev container of dev */ if (bridge->parent == NULL) { - printk("Dev entry NULL\n"); + pr_info("Dev entry NULL\n"); return NULL; } pdev = container_of(bridge->parent, struct pci_dev, dev); @@ -128,13 +130,13 @@ void vme_free_consistent(struct vme_resource *resource, size_t size, struct pci_dev *pdev; if(resource == NULL) { - printk("No resource\n"); + pr_info("No resource\n"); return; } bridge = find_bridge(resource); if(bridge == NULL) { - printk("Can't find bridge\n"); + pr_info("Can't find bridge\n"); return; } @@ -171,7 +173,7 @@ size_t vme_get_size(struct vme_resource *resource) return 0; break; default: - printk(KERN_ERR "Unknown resource type\n"); + pr_err("Unknown resource type\n"); return 0; break; } @@ -217,7 +219,7 @@ static int vme_check_window(vme_address_t aspace, unsigned long long vme_base, /* User Defined */ break; default: - printk("Invalid address space\n"); + pr_info("Invalid address space\n"); retval = -EINVAL; break; } @@ -240,7 +242,7 @@ struct vme_resource * vme_slave_request(struct device *dev, bridge = dev_to_bridge(dev); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); goto err_bus; } @@ -250,7 +252,7 @@ struct vme_resource * vme_slave_request(struct device *dev, struct vme_slave_resource, list); if (slave_image == NULL) { - printk("Registered NULL Slave resource\n"); + pr_info("Registered NULL Slave resource\n"); continue; } @@ -274,7 +276,7 @@ struct vme_resource * vme_slave_request(struct device *dev, resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); if (resource == NULL) { - printk(KERN_WARNING "Unable to allocate resource structure\n"); + pr_warning("Unable to allocate resource structure\n"); goto err_alloc; } resource->type = VME_SLAVE; @@ -302,20 +304,20 @@ int vme_slave_set (struct vme_resource *resource, int enabled, int retval; if (resource->type != VME_SLAVE) { - printk("Not a slave resource\n"); + pr_info("Not a slave resource\n"); return -EINVAL; } image = list_entry(resource->entry, struct vme_slave_resource, list); if (bridge->slave_set == NULL) { - printk("Function not supported\n"); + pr_info("Function not supported\n"); return -ENOSYS; } if(!(((image->address_attr & aspace) == aspace) && ((image->cycle_attr & cycle) == cycle))) { - printk("Invalid attributes\n"); + pr_info("Invalid attributes\n"); return -EINVAL; } @@ -336,14 +338,14 @@ int vme_slave_get (struct vme_resource *resource, int *enabled, struct vme_slave_resource *image; if (resource->type != VME_SLAVE) { - printk("Not a slave resource\n"); + pr_info("Not a slave resource\n"); return -EINVAL; } image = list_entry(resource->entry, struct vme_slave_resource, list); if (bridge->slave_get == NULL) { - printk("vme_slave_get not supported\n"); + pr_info("vme_slave_get not supported\n"); return -EINVAL; } @@ -357,21 +359,21 @@ void vme_slave_free(struct vme_resource *resource) struct vme_slave_resource *slave_image; if (resource->type != VME_SLAVE) { - printk("Not a slave resource\n"); + pr_info("Not a slave resource\n"); return; } slave_image = list_entry(resource->entry, struct vme_slave_resource, list); if (slave_image == NULL) { - printk("Can't find slave resource\n"); + pr_info("Can't find slave resource\n"); return; } /* Unlock image */ mutex_lock(&(slave_image->mtx)); if (slave_image->locked == 0) - printk(KERN_ERR "Image is already free\n"); + pr_err("Image is already free\n"); slave_image->locked = 0; mutex_unlock(&(slave_image->mtx)); @@ -396,7 +398,7 @@ struct vme_resource * vme_master_request(struct device *dev, bridge = dev_to_bridge(dev); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); goto err_bus; } @@ -406,7 +408,7 @@ struct vme_resource * vme_master_request(struct device *dev, struct vme_master_resource, list); if (master_image == NULL) { - printk(KERN_WARNING "Registered NULL master resource\n"); + pr_warning("Registered NULL master resource\n"); continue; } @@ -427,13 +429,13 @@ struct vme_resource * vme_master_request(struct device *dev, /* Check to see if we found a resource */ if (allocated_image == NULL) { - printk(KERN_ERR "Can't find a suitable resource\n"); + pr_err("Can't find a suitable resource\n"); goto err_image; } resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); if (resource == NULL) { - printk(KERN_ERR "Unable to allocate resource structure\n"); + pr_err("Unable to allocate resource structure\n"); goto err_alloc; } resource->type = VME_MASTER; @@ -462,21 +464,21 @@ int vme_master_set (struct vme_resource *resource, int enabled, int retval; if (resource->type != VME_MASTER) { - printk("Not a master resource\n"); + pr_info("Not a master resource\n"); return -EINVAL; } image = list_entry(resource->entry, struct vme_master_resource, list); if (bridge->master_set == NULL) { - printk("vme_master_set not supported\n"); + pr_info("vme_master_set not supported\n"); return -EINVAL; } if(!(((image->address_attr & aspace) == aspace) && ((image->cycle_attr & cycle) == cycle) && ((image->width_attr & dwidth) == dwidth))) { - printk("Invalid attributes\n"); + pr_info("Invalid attributes\n"); return -EINVAL; } @@ -497,14 +499,14 @@ int vme_master_get (struct vme_resource *resource, int *enabled, struct vme_master_resource *image; if (resource->type != VME_MASTER) { - printk("Not a master resource\n"); + pr_info("Not a master resource\n"); return -EINVAL; } image = list_entry(resource->entry, struct vme_master_resource, list); if (bridge->master_get == NULL) { - printk("vme_master_set not supported\n"); + pr_info("vme_master_set not supported\n"); return -EINVAL; } @@ -524,12 +526,12 @@ ssize_t vme_master_read (struct vme_resource *resource, void *buf, size_t count, size_t length; if (bridge->master_read == NULL) { - printk("Reading from resource not supported\n"); + pr_info("Reading from resource not supported\n"); return -EINVAL; } if (resource->type != VME_MASTER) { - printk("Not a master resource\n"); + pr_info("Not a master resource\n"); return -EINVAL; } @@ -538,7 +540,7 @@ ssize_t vme_master_read (struct vme_resource *resource, void *buf, size_t count, length = vme_get_size(resource); if (offset > length) { - printk("Invalid Offset\n"); + pr_info("Invalid Offset\n"); return -EFAULT; } @@ -561,12 +563,12 @@ ssize_t vme_master_write (struct vme_resource *resource, void *buf, size_t length; if (bridge->master_write == NULL) { - printk("Writing to resource not supported\n"); + pr_info("Writing to resource not supported\n"); return -EINVAL; } if (resource->type != VME_MASTER) { - printk("Not a master resource\n"); + pr_info("Not a master resource\n"); return -EINVAL; } @@ -575,7 +577,7 @@ ssize_t vme_master_write (struct vme_resource *resource, void *buf, length = vme_get_size(resource); if (offset > length) { - printk("Invalid Offset\n"); + pr_info("Invalid Offset\n"); return -EFAULT; } @@ -596,12 +598,12 @@ unsigned int vme_master_rmw (struct vme_resource *resource, unsigned int mask, struct vme_master_resource *image; if (bridge->master_rmw == NULL) { - printk("Writing to resource not supported\n"); + pr_info("Writing to resource not supported\n"); return -EINVAL; } if (resource->type != VME_MASTER) { - printk("Not a master resource\n"); + pr_info("Not a master resource\n"); return -EINVAL; } @@ -616,21 +618,21 @@ void vme_master_free(struct vme_resource *resource) struct vme_master_resource *master_image; if (resource->type != VME_MASTER) { - printk("Not a master resource\n"); + pr_info("Not a master resource\n"); return; } master_image = list_entry(resource->entry, struct vme_master_resource, list); if (master_image == NULL) { - printk("Can't find master resource\n"); + pr_info("Can't find master resource\n"); return; } /* Unlock image */ spin_lock(&(master_image->lock)); if (master_image->locked == 0) - printk(KERN_ERR "Image is already free\n"); + pr_err("Image is already free\n"); master_image->locked = 0; spin_unlock(&(master_image->lock)); @@ -653,11 +655,11 @@ struct vme_resource *vme_request_dma(struct device *dev) struct vme_resource *resource = NULL; /* XXX Not checking resource attributes */ - printk(KERN_ERR "No VME resource Attribute tests done\n"); + pr_err("No VME resource Attribute tests done\n"); bridge = dev_to_bridge(dev); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); goto err_bus; } @@ -667,7 +669,7 @@ struct vme_resource *vme_request_dma(struct device *dev) struct vme_dma_resource, list); if (dma_ctrlr == NULL) { - printk("Registered NULL DMA resource\n"); + pr_info("Registered NULL DMA resource\n"); continue; } @@ -688,7 +690,7 @@ struct vme_resource *vme_request_dma(struct device *dev) resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); if (resource == NULL) { - printk(KERN_WARNING "Unable to allocate resource structure\n"); + pr_warning("Unable to allocate resource structure\n"); goto err_alloc; } resource->type = VME_DMA; @@ -716,7 +718,7 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource) struct vme_dma_list *dma_list; if (resource->type != VME_DMA) { - printk("Not a DMA resource\n"); + pr_info("Not a DMA resource\n"); return NULL; } @@ -725,7 +727,7 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource) dma_list = (struct vme_dma_list *)kmalloc( sizeof(struct vme_dma_list), GFP_KERNEL); if(dma_list == NULL) { - printk("Unable to allocate memory for new dma list\n"); + pr_info("Unable to allocate memory for new dma list\n"); return NULL; } INIT_LIST_HEAD(&(dma_list->entries)); @@ -748,14 +750,14 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, attributes = (struct vme_dma_attr *)kmalloc( sizeof(struct vme_dma_attr), GFP_KERNEL); if(attributes == NULL) { - printk("Unable to allocate memory for attributes structure\n"); + pr_info("Unable to allocate memory for attributes structure\n"); goto err_attr; } pattern_attr = (struct vme_dma_pattern *)kmalloc( sizeof(struct vme_dma_pattern), GFP_KERNEL); if(pattern_attr == NULL) { - printk("Unable to allocate memory for pattern attributes\n"); + pr_info("Unable to allocate memory for pattern attributes\n"); goto err_pat; } @@ -788,14 +790,14 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address) attributes = (struct vme_dma_attr *)kmalloc( sizeof(struct vme_dma_attr), GFP_KERNEL); if(attributes == NULL) { - printk("Unable to allocate memory for attributes structure\n"); + pr_info("Unable to allocate memory for attributes structure\n"); goto err_attr; } pci_attr = (struct vme_dma_pci *)kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL); if(pci_attr == NULL) { - printk("Unable to allocate memory for pci attributes\n"); + pr_info("Unable to allocate memory for pci attributes\n"); goto err_pci; } @@ -830,14 +832,14 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address, attributes = (struct vme_dma_attr *)kmalloc( sizeof(struct vme_dma_attr), GFP_KERNEL); if(attributes == NULL) { - printk("Unable to allocate memory for attributes structure\n"); + pr_info("Unable to allocate memory for attributes structure\n"); goto err_attr; } vme_attr = (struct vme_dma_vme *)kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL); if(vme_attr == NULL) { - printk("Unable to allocate memory for vme attributes\n"); + pr_info("Unable to allocate memory for vme attributes\n"); goto err_vme; } @@ -876,12 +878,12 @@ int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, int retval; if (bridge->dma_list_add == NULL) { - printk("Link List DMA generation not supported\n"); + pr_info("Link List DMA generation not supported\n"); return -EINVAL; } if (mutex_trylock(&(list->mtx))) { - printk("Link List already submitted\n"); + pr_info("Link List already submitted\n"); return -EINVAL; } @@ -899,7 +901,7 @@ int vme_dma_list_exec(struct vme_dma_list *list) int retval; if (bridge->dma_list_exec == NULL) { - printk("Link List DMA execution not supported\n"); + pr_info("Link List DMA execution not supported\n"); return -EINVAL; } @@ -919,12 +921,12 @@ int vme_dma_list_free(struct vme_dma_list *list) int retval; if (bridge->dma_list_empty == NULL) { - printk("Emptying of Link Lists not supported\n"); + pr_info("Emptying of Link Lists not supported\n"); return -EINVAL; } if (mutex_trylock(&(list->mtx))) { - printk("Link List in use\n"); + pr_info("Link List in use\n"); return -EINVAL; } @@ -934,7 +936,7 @@ int vme_dma_list_free(struct vme_dma_list *list) */ retval = bridge->dma_list_empty(list); if (retval) { - printk("Unable to empty link-list entries\n"); + pr_info("Unable to empty link-list entries\n"); mutex_unlock(&(list->mtx)); return retval; } @@ -950,19 +952,19 @@ int vme_dma_free(struct vme_resource *resource) struct vme_dma_resource *ctrlr; if (resource->type != VME_DMA) { - printk("Not a DMA resource\n"); + pr_info("Not a DMA resource\n"); return -EINVAL; } ctrlr = list_entry(resource->entry, struct vme_dma_resource, list); if (mutex_trylock(&(ctrlr->mtx))) { - printk("Resource busy, can't free\n"); + pr_info("Resource busy, can't free\n"); return -EBUSY; } if (!(list_empty(&(ctrlr->pending)) && list_empty(&(ctrlr->running)))) { - printk("Resource still processing transfers\n"); + pr_info("Resource still processing transfers\n"); mutex_unlock(&(ctrlr->mtx)); return -EBUSY; } @@ -983,17 +985,17 @@ int vme_request_irq(struct device *dev, int level, int statid, bridge = dev_to_bridge(dev); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); return -EINVAL; } if((level < 1) || (level > 7)) { - printk(KERN_WARNING "Invalid interrupt level\n"); + pr_warning("Invalid interrupt level\n"); return -EINVAL; } if (bridge->request_irq == NULL) { - printk("Registering interrupts not supported\n"); + pr_info("Registering interrupts not supported\n"); return -EINVAL; } @@ -1007,17 +1009,17 @@ void vme_free_irq(struct device *dev, int level, int statid) bridge = dev_to_bridge(dev); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); return; } if((level < 1) || (level > 7)) { - printk(KERN_WARNING "Invalid interrupt level\n"); + pr_warning("Invalid interrupt level\n"); return; } if (bridge->free_irq == NULL) { - printk("Freeing interrupts not supported\n"); + pr_info("Freeing interrupts not supported\n"); return; } @@ -1031,17 +1033,17 @@ int vme_generate_irq(struct device *dev, int level, int statid) bridge = dev_to_bridge(dev); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); return -EINVAL; } if((level < 1) || (level > 7)) { - printk(KERN_WARNING "Invalid interrupt level\n"); + pr_warning("Invalid interrupt level\n"); return -EINVAL; } if (bridge->generate_irq == NULL) { - printk("Interrupt generation not supported\n"); + pr_info("Interrupt generation not supported\n"); return -EINVAL; } @@ -1062,7 +1064,7 @@ struct vme_resource *vme_lm_request(struct device *dev) bridge = dev_to_bridge(dev); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); goto err_bus; } @@ -1072,8 +1074,7 @@ struct vme_resource *vme_lm_request(struct device *dev) struct vme_lm_resource, list); if (lm == NULL) { - printk(KERN_ERR "Registered NULL Location Monitor " - "resource\n"); + pr_err("Registered NULL Location Monitor resource\n"); continue; } @@ -1094,7 +1095,7 @@ struct vme_resource *vme_lm_request(struct device *dev) resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); if (resource == NULL) { - printk(KERN_ERR "Unable to allocate resource structure\n"); + pr_err("Unable to allocate resource structure\n"); goto err_alloc; } resource->type = VME_LM; @@ -1118,7 +1119,7 @@ int vme_lm_count(struct vme_resource *resource) struct vme_lm_resource *lm; if (resource->type != VME_LM) { - printk(KERN_ERR "Not a Location Monitor resource\n"); + pr_err("Not a Location Monitor resource\n"); return -EINVAL; } @@ -1135,14 +1136,14 @@ int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base, struct vme_lm_resource *lm; if (resource->type != VME_LM) { - printk(KERN_ERR "Not a Location Monitor resource\n"); + pr_err("Not a Location Monitor resource\n"); return -EINVAL; } lm = list_entry(resource->entry, struct vme_lm_resource, list); if (bridge->lm_set == NULL) { - printk(KERN_ERR "vme_lm_set not supported\n"); + pr_err("vme_lm_set not supported\n"); return -EINVAL; } @@ -1159,14 +1160,14 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base, struct vme_lm_resource *lm; if (resource->type != VME_LM) { - printk(KERN_ERR "Not a Location Monitor resource\n"); + pr_err("Not a Location Monitor resource\n"); return -EINVAL; } lm = list_entry(resource->entry, struct vme_lm_resource, list); if (bridge->lm_get == NULL) { - printk(KERN_ERR "vme_lm_get not supported\n"); + pr_err("vme_lm_get not supported\n"); return -EINVAL; } @@ -1181,14 +1182,14 @@ int vme_lm_attach(struct vme_resource *resource, int monitor, struct vme_lm_resource *lm; if (resource->type != VME_LM) { - printk(KERN_ERR "Not a Location Monitor resource\n"); + pr_err("Not a Location Monitor resource\n"); return -EINVAL; } lm = list_entry(resource->entry, struct vme_lm_resource, list); if (bridge->lm_attach == NULL) { - printk(KERN_ERR "vme_lm_attach not supported\n"); + pr_err("vme_lm_attach not supported\n"); return -EINVAL; } @@ -1202,14 +1203,14 @@ int vme_lm_detach(struct vme_resource *resource, int monitor) struct vme_lm_resource *lm; if (resource->type != VME_LM) { - printk(KERN_ERR "Not a Location Monitor resource\n"); + pr_err("Not a Location Monitor resource\n"); return -EINVAL; } lm = list_entry(resource->entry, struct vme_lm_resource, list); if (bridge->lm_detach == NULL) { - printk(KERN_ERR "vme_lm_detach not supported\n"); + pr_err("vme_lm_detach not supported\n"); return -EINVAL; } @@ -1222,14 +1223,14 @@ void vme_lm_free(struct vme_resource *resource) struct vme_lm_resource *lm; if (resource->type != VME_LM) { - printk(KERN_ERR "Not a Location Monitor resource\n"); + pr_err("Not a Location Monitor resource\n"); return; } lm = list_entry(resource->entry, struct vme_lm_resource, list); if (mutex_trylock(&(lm->mtx))) { - printk(KERN_ERR "Resource busy, can't free\n"); + pr_err("Resource busy, can't free\n"); return; } @@ -1247,12 +1248,12 @@ int vme_slot_get(struct device *bus) bridge = dev_to_bridge(bus); if (bridge == NULL) { - printk(KERN_ERR "Can't find VME bus\n"); + pr_err("Can't find VME bus\n"); return -EINVAL; } if (bridge->slot_get == NULL) { - printk("vme_slot_get not supported\n"); + pr_info("vme_slot_get not supported\n"); return -EINVAL; } @@ -1393,7 +1394,7 @@ err_dev: static struct vme_driver *dev_to_vme_driver(struct device *dev) { if(dev->driver == NULL) - printk("Bugger dev->driver is NULL\n"); + pr_info("Bugger dev->driver is NULL\n"); return container_of(dev->driver, struct vme_driver, driver); } -- 1.6.5.rc3.dirty _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel