diff options
Diffstat (limited to 'drivers/vme/bridges')
-rw-r--r-- | drivers/vme/bridges/vme_ca91cx42.c | 73 | ||||
-rw-r--r-- | drivers/vme/bridges/vme_fake.c | 35 | ||||
-rw-r--r-- | drivers/vme/bridges/vme_tsi148.c | 83 |
3 files changed, 74 insertions, 117 deletions
diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c index 7cc51223db1c..5dd284008630 100644 --- a/drivers/vme/bridges/vme_ca91cx42.c +++ b/drivers/vme/bridges/vme_ca91cx42.c @@ -511,7 +511,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, ca91cx42_bridge = image->parent; /* Find pci_dev container of dev */ - if (ca91cx42_bridge->parent == NULL) { + if (!ca91cx42_bridge->parent) { dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n"); return -EINVAL; } @@ -529,14 +529,12 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, image->kern_base = NULL; kfree(image->bus_resource.name); release_resource(&image->bus_resource); - memset(&image->bus_resource, 0, sizeof(struct resource)); + memset(&image->bus_resource, 0, sizeof(image->bus_resource)); } - if (image->bus_resource.name == NULL) { + if (!image->bus_resource.name) { image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC); - if (image->bus_resource.name == NULL) { - dev_err(ca91cx42_bridge->parent, "Unable to allocate " - "memory for resource name\n"); + if (!image->bus_resource.name) { retval = -ENOMEM; goto err_name; } @@ -562,7 +560,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) { + if (!image->kern_base) { dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n"); retval = -ENOMEM; goto err_remap; @@ -574,7 +572,7 @@ err_remap: release_resource(&image->bus_resource); err_resource: kfree(image->bus_resource.name); - memset(&image->bus_resource, 0, sizeof(struct resource)); + memset(&image->bus_resource, 0, sizeof(image->bus_resource)); err_name: return retval; } @@ -588,7 +586,7 @@ static void ca91cx42_free_resource(struct vme_master_resource *image) image->kern_base = NULL; release_resource(&image->bus_resource); kfree(image->bus_resource.name); - memset(&image->bus_resource, 0, sizeof(struct resource)); + memset(&image->bus_resource, 0, sizeof(image->bus_resource)); } @@ -1036,10 +1034,8 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list, dev = list->parent->parent->parent; /* XXX descriptor must be aligned on 64-bit boundaries */ - entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL); - if (entry == NULL) { - dev_err(dev, "Failed to allocate memory for dma resource " - "structure\n"); + entry = kmalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) { retval = -ENOMEM; goto err_mem; } @@ -1052,7 +1048,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list, goto err_align; } - memset(&entry->descriptor, 0, sizeof(struct ca91cx42_dma_descriptor)); + memset(&entry->descriptor, 0, sizeof(entry->descriptor)); if (dest->type == VME_DMA_VME) { entry->descriptor.dctl |= CA91CX42_DCTL_L2V; @@ -1323,7 +1319,7 @@ static int ca91cx42_lm_set(struct vme_lm_resource *lm, /* If we already have a callback attached, we can't move it! */ for (i = 0; i < lm->monitors; i++) { - if (bridge->lm_callback[i] != NULL) { + if (bridge->lm_callback[i]) { mutex_unlock(&lm->mtx); dev_err(dev, "Location monitor callback attached, " "can't reset\n"); @@ -1432,7 +1428,7 @@ static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor, } /* Check that a callback isn't already attached */ - if (bridge->lm_callback[monitor] != NULL) { + if (bridge->lm_callback[monitor]) { mutex_unlock(&lm->mtx); dev_err(dev, "Existing callback attached\n"); return -EBUSY; @@ -1567,7 +1563,7 @@ static int ca91cx42_crcsr_init(struct vme_bridge *ca91cx42_bridge, /* Allocate mem for CR/CSR image */ bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, &bridge->crcsr_bus); - if (bridge->crcsr_kernel == NULL) { + if (!bridge->crcsr_kernel) { dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR " "image\n"); return -ENOMEM; @@ -1618,21 +1614,15 @@ 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 = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); - - if (ca91cx42_bridge == NULL) { - dev_err(&pdev->dev, "Failed to allocate memory for device " - "structure\n"); + ca91cx42_bridge = kzalloc(sizeof(*ca91cx42_bridge), GFP_KERNEL); + if (!ca91cx42_bridge) { retval = -ENOMEM; goto err_struct; } vme_init_bridge(ca91cx42_bridge); - ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); - - if (ca91cx42_device == NULL) { - dev_err(&pdev->dev, "Failed to allocate memory for device " - "structure\n"); + ca91cx42_device = kzalloc(sizeof(*ca91cx42_device), GFP_KERNEL); + if (!ca91cx42_device) { retval = -ENOMEM; goto err_driver; } @@ -1688,11 +1678,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add master windows to list */ for (i = 0; i < CA91C142_MAX_MASTER; i++) { - 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"); + master_image = kmalloc(sizeof(*master_image), GFP_KERNEL); + if (!master_image) { retval = -ENOMEM; goto err_master; } @@ -1706,7 +1693,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) VME_SUPER | VME_USER | VME_PROG | VME_DATA; master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64; memset(&master_image->bus_resource, 0, - sizeof(struct resource)); + sizeof(master_image->bus_resource)); master_image->kern_base = NULL; list_add_tail(&master_image->list, &ca91cx42_bridge->master_resources); @@ -1714,11 +1701,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add slave windows to list */ for (i = 0; i < CA91C142_MAX_SLAVE; i++) { - 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"); + slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL); + if (!slave_image) { retval = -ENOMEM; goto err_slave; } @@ -1741,11 +1725,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add dma engines to list */ for (i = 0; i < CA91C142_MAX_DMA; i++) { - 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"); + dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL); + if (!dma_ctrlr) { retval = -ENOMEM; goto err_dma; } @@ -1762,10 +1743,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) } /* Add location monitor to list */ - lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); - if (lm == NULL) { - dev_err(&pdev->dev, "Failed to allocate memory for " - "location monitor resource structure\n"); + lm = kmalloc(sizeof(*lm), GFP_KERNEL); + if (!lm) { retval = -ENOMEM; goto err_lm; } diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c index 30b3acc93833..7d83691047f4 100644 --- a/drivers/vme/bridges/vme_fake.c +++ b/drivers/vme/bridges/vme_fake.c @@ -409,7 +409,7 @@ static void fake_lm_check(struct fake_driver *bridge, unsigned long long addr, /* Each location monitor covers 8 bytes */ if (((lm_base + (8 * i)) <= addr) && ((lm_base + (8 * i) + 8) > addr)) { - if (bridge->lm_callback[i] != NULL) + if (bridge->lm_callback[i]) bridge->lm_callback[i]( bridge->lm_data[i]); } @@ -866,7 +866,7 @@ static int fake_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, /* If we already have a callback attached, we can't move it! */ for (i = 0; i < lm->monitors; i++) { - if (bridge->lm_callback[i] != NULL) { + if (bridge->lm_callback[i]) { mutex_unlock(&lm->mtx); pr_err("Location monitor callback attached, can't reset\n"); return -EBUSY; @@ -940,7 +940,7 @@ static int fake_lm_attach(struct vme_lm_resource *lm, int monitor, } /* Check that a callback isn't already attached */ - if (bridge->lm_callback[monitor] != NULL) { + if (bridge->lm_callback[monitor]) { mutex_unlock(&lm->mtx); pr_err("Existing callback attached\n"); return -EBUSY; @@ -978,7 +978,7 @@ static int fake_lm_detach(struct vme_lm_resource *lm, int monitor) /* If all location monitors disabled, disable global Location Monitor */ tmp = 0; for (i = 0; i < lm->monitors; i++) { - if (bridge->lm_callback[i] != NULL) + if (bridge->lm_callback[i]) tmp = 1; } @@ -1003,7 +1003,7 @@ static void *fake_alloc_consistent(struct device *parent, size_t size, { void *alloc = kmalloc(size, GFP_KERNEL); - if (alloc != NULL) + if (alloc) *dma = fake_ptr_to_pci(alloc); return alloc; @@ -1039,7 +1039,7 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge) /* Allocate mem for CR/CSR image */ bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL); bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel); - if (bridge->crcsr_kernel == NULL) + if (!bridge->crcsr_kernel) return -ENOMEM; vstat = fake_slot_get(fake_bridge); @@ -1075,14 +1075,14 @@ static int __init fake_init(void) /* If we want to support more than one bridge at some point, we need to * dynamically allocate this so we get one per device. */ - fake_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); - if (fake_bridge == NULL) { + fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL); + if (!fake_bridge) { retval = -ENOMEM; goto err_struct; } - fake_device = kzalloc(sizeof(struct fake_driver), GFP_KERNEL); - if (fake_device == NULL) { + fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL); + if (!fake_device) { retval = -ENOMEM; goto err_driver; } @@ -1104,9 +1104,8 @@ static int __init fake_init(void) /* Add master windows to list */ INIT_LIST_HEAD(&fake_bridge->master_resources); for (i = 0; i < FAKE_MAX_MASTER; i++) { - master_image = kmalloc(sizeof(struct vme_master_resource), - GFP_KERNEL); - if (master_image == NULL) { + master_image = kmalloc(sizeof(*master_image), GFP_KERNEL); + if (!master_image) { retval = -ENOMEM; goto err_master; } @@ -1131,9 +1130,8 @@ static int __init fake_init(void) /* Add slave windows to list */ INIT_LIST_HEAD(&fake_bridge->slave_resources); for (i = 0; i < FAKE_MAX_SLAVE; i++) { - slave_image = kmalloc(sizeof(struct vme_slave_resource), - GFP_KERNEL); - if (slave_image == NULL) { + slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL); + if (!slave_image) { retval = -ENOMEM; goto err_slave; } @@ -1154,9 +1152,8 @@ static int __init fake_init(void) /* Add location monitor to list */ INIT_LIST_HEAD(&fake_bridge->lm_resources); - lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); - if (lm == NULL) { - pr_err("Failed to allocate memory for location monitor resource structure\n"); + lm = kmalloc(sizeof(*lm), GFP_KERNEL); + if (!lm) { retval = -ENOMEM; goto err_lm; } diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c index fc1b634b969a..647d231d4422 100644 --- a/drivers/vme/bridges/vme_tsi148.c +++ b/drivers/vme/bridges/vme_tsi148.c @@ -741,18 +741,16 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, image->kern_base = NULL; kfree(image->bus_resource.name); release_resource(&image->bus_resource); - memset(&image->bus_resource, 0, sizeof(struct resource)); + memset(&image->bus_resource, 0, sizeof(image->bus_resource)); } /* Exit here if size is zero */ if (size == 0) return 0; - if (image->bus_resource.name == NULL) { + if (!image->bus_resource.name) { image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC); - if (image->bus_resource.name == NULL) { - dev_err(tsi148_bridge->parent, "Unable to allocate " - "memory for resource name\n"); + if (!image->bus_resource.name) { retval = -ENOMEM; goto err_name; } @@ -778,7 +776,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) { + if (!image->kern_base) { dev_err(tsi148_bridge->parent, "Failed to remap resource\n"); retval = -ENOMEM; goto err_remap; @@ -790,7 +788,7 @@ err_remap: release_resource(&image->bus_resource); err_resource: kfree(image->bus_resource.name); - memset(&image->bus_resource, 0, sizeof(struct resource)); + memset(&image->bus_resource, 0, sizeof(image->bus_resource)); err_name: return retval; } @@ -804,7 +802,7 @@ static void tsi148_free_resource(struct vme_master_resource *image) image->kern_base = NULL; release_resource(&image->bus_resource); kfree(image->bus_resource.name); - memset(&image->bus_resource, 0, sizeof(struct resource)); + memset(&image->bus_resource, 0, sizeof(image->bus_resource)); } /* @@ -1641,10 +1639,8 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, tsi148_bridge = list->parent->parent; /* Descriptor must be aligned on 64-bit boundaries */ - entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL); - if (entry == NULL) { - dev_err(tsi148_bridge->parent, "Failed to allocate memory for " - "dma resource structure\n"); + entry = kmalloc(sizeof(*entry), GFP_KERNEL); + if (!entry) { retval = -ENOMEM; goto err_mem; } @@ -1661,7 +1657,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, /* Given we are going to fill out the structure, we probably don't * need to zero it, but better safe than sorry for now. */ - memset(&entry->descriptor, 0, sizeof(struct tsi148_dma_descriptor)); + memset(&entry->descriptor, 0, sizeof(entry->descriptor)); /* Fill out source part */ switch (src->type) { @@ -1756,8 +1752,9 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, list_add_tail(&entry->list, &list->entries); entry->dma_handle = dma_map_single(tsi148_bridge->parent, - &entry->descriptor, - sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); + &entry->descriptor, + sizeof(entry->descriptor), + DMA_TO_DEVICE); if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) { dev_err(tsi148_bridge->parent, "DMA mapping error\n"); retval = -EINVAL; @@ -1946,7 +1943,7 @@ static int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, /* If we already have a callback attached, we can't move it! */ for (i = 0; i < lm->monitors; i++) { - if (bridge->lm_callback[i] != NULL) { + if (bridge->lm_callback[i]) { mutex_unlock(&lm->mtx); dev_err(tsi148_bridge->parent, "Location monitor " "callback attached, can't reset\n"); @@ -2071,7 +2068,7 @@ static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, } /* Check that a callback isn't already attached */ - if (bridge->lm_callback[monitor] != NULL) { + if (bridge->lm_callback[monitor]) { mutex_unlock(&lm->mtx); dev_err(tsi148_bridge->parent, "Existing callback attached\n"); return -EBUSY; @@ -2208,7 +2205,7 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge, /* Allocate mem for CR/CSR image */ bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, &bridge->crcsr_bus); - if (bridge->crcsr_kernel == NULL) { + if (!bridge->crcsr_kernel) { dev_err(tsi148_bridge->parent, "Failed to allocate memory for " "CR/CSR image\n"); return -ENOMEM; @@ -2294,19 +2291,15 @@ 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 = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); - if (tsi148_bridge == NULL) { - dev_err(&pdev->dev, "Failed to allocate memory for device " - "structure\n"); + tsi148_bridge = kzalloc(sizeof(*tsi148_bridge), GFP_KERNEL); + if (!tsi148_bridge) { retval = -ENOMEM; goto err_struct; } vme_init_bridge(tsi148_bridge); - 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"); + tsi148_device = kzalloc(sizeof(*tsi148_device), GFP_KERNEL); + if (!tsi148_device) { retval = -ENOMEM; goto err_driver; } @@ -2371,10 +2364,9 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) master_num--; 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 " - "flush resource structure\n"); + kmalloc(sizeof(*tsi148_device->flush_image), + GFP_KERNEL); + if (!tsi148_device->flush_image) { retval = -ENOMEM; goto err_master; } @@ -2383,17 +2375,14 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) tsi148_device->flush_image->locked = 1; tsi148_device->flush_image->number = master_num; memset(&tsi148_device->flush_image->bus_resource, 0, - sizeof(struct resource)); + sizeof(tsi148_device->flush_image->bus_resource)); tsi148_device->flush_image->kern_base = NULL; } /* Add master windows to list */ for (i = 0; i < master_num; i++) { - 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"); + master_image = kmalloc(sizeof(*master_image), GFP_KERNEL); + if (!master_image) { retval = -ENOMEM; goto err_master; } @@ -2410,7 +2399,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) VME_PROG | VME_DATA; master_image->width_attr = VME_D16 | VME_D32; memset(&master_image->bus_resource, 0, - sizeof(struct resource)); + sizeof(master_image->bus_resource)); master_image->kern_base = NULL; list_add_tail(&master_image->list, &tsi148_bridge->master_resources); @@ -2418,11 +2407,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add slave windows to list */ for (i = 0; i < TSI148_MAX_SLAVE; i++) { - 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"); + slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL); + if (!slave_image) { retval = -ENOMEM; goto err_slave; } @@ -2442,11 +2428,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add dma engines to list */ for (i = 0; i < TSI148_MAX_DMA; i++) { - 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"); + dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL); + if (!dma_ctrlr) { retval = -ENOMEM; goto err_dma; } @@ -2465,10 +2448,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) } /* Add location monitor to list */ - lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); - if (lm == NULL) { - dev_err(&pdev->dev, "Failed to allocate memory for " - "location monitor resource structure\n"); + lm = kmalloc(sizeof(*lm), GFP_KERNEL); + if (!lm) { retval = -ENOMEM; goto err_lm; } |