2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-15 00:34:10 +08:00

VME Subsystem changes for master v4.14-rc4:

- Corrections across the VME subsystem to better align with the preferred
    kernel coding style.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJZ4SrIAAoJEE12cGh4ILCUrx0QAKnbzriglz5v8WqKcH7Z0IRT
 d6+3hRsot7TvEKbcsDU0dql3njI1LM1owPXsIEaFCmx1mP2D+1MFp7IuxEfNdiFo
 rO2gmvXvfv4nyaW/LYCu/7aiC/R+0f1RSj9K6e+jc0o31VGL6EG+mBN+XZ6G5PV0
 RCVz87BBtulU4zt/tbKpKmpJucbVAToUoAhnU3mIU/rDy/U9zuzfepzkGmtRzoid
 fCSrC87Me+Wq++1b3FOQpAKR3pd9eLqevMRwOe5c8JBD1qy4KyeQPVq44beGf3uy
 bWDTYGkn4NiVlJQEJQfnXbvFxo7zuuqUO9fBNsTbvaVzwiyoAq6u4vZZRqMQghL+
 GG5lskyUZCqlOOdjy8HyNGYiHelELgnU0YaJk3/vl5kjsfpApuAkHBH9X7ztFPQi
 t0QrqkX3/cYhI2AmBoddR6cEEBvZN23rjhe2zReln+Aq5Se7k5DZnogVWkM9QwDD
 agnhAB3LhOYoxeDKfDtbVieV6//UdOQtsmadgeOihfZ5AWxel+Jh0w4dv2xrjqpS
 8Xwt1AtUPG+h+OAmUpTgrWDs1osV1eHBQ7MtuVosB1ofn5vdinTXEalqPEHQCOU8
 Ab5R4qEm9srEsoMZ8GCr8d6irDU5w/Uk39KHOKycz9g1+o7jexSDHJ9xbePrOSR9
 +r7NuSYReExa8XBNUyO1
 =gprQ
 -----END PGP SIGNATURE-----

Merge tag 'vme-next-4.14-rc4' of https://gitlab.collabora.com/martyn/linux into char-misc-next

Martyn writes:

VME Subsystem changes for master v4.14-rc4:

 - Corrections across the VME subsystem to better align with the preferred
   kernel coding style.
This commit is contained in:
Greg Kroah-Hartman 2017-10-20 15:24:34 +02:00
commit ad146e37d2
4 changed files with 157 additions and 228 deletions

View File

@ -511,7 +511,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
ca91cx42_bridge = image->parent; ca91cx42_bridge = image->parent;
/* Find pci_dev container of dev */ /* Find pci_dev container of dev */
if (ca91cx42_bridge->parent == NULL) { if (!ca91cx42_bridge->parent) {
dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n"); dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n");
return -EINVAL; return -EINVAL;
} }
@ -529,14 +529,12 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
image->kern_base = NULL; image->kern_base = NULL;
kfree(image->bus_resource.name); kfree(image->bus_resource.name);
release_resource(&image->bus_resource); 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); image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
if (image->bus_resource.name == NULL) { if (!image->bus_resource.name) {
dev_err(ca91cx42_bridge->parent, "Unable to allocate "
"memory for resource name\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_name; goto err_name;
} }
@ -562,7 +560,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
image->kern_base = ioremap_nocache( image->kern_base = ioremap_nocache(
image->bus_resource.start, size); image->bus_resource.start, size);
if (image->kern_base == NULL) { if (!image->kern_base) {
dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n"); dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_remap; goto err_remap;
@ -574,7 +572,7 @@ err_remap:
release_resource(&image->bus_resource); release_resource(&image->bus_resource);
err_resource: err_resource:
kfree(image->bus_resource.name); kfree(image->bus_resource.name);
memset(&image->bus_resource, 0, sizeof(struct resource)); memset(&image->bus_resource, 0, sizeof(image->bus_resource));
err_name: err_name:
return retval; return retval;
} }
@ -588,7 +586,7 @@ static void ca91cx42_free_resource(struct vme_master_resource *image)
image->kern_base = NULL; image->kern_base = NULL;
release_resource(&image->bus_resource); release_resource(&image->bus_resource);
kfree(image->bus_resource.name); 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; dev = list->parent->parent->parent;
/* XXX descriptor must be aligned on 64-bit boundaries */ /* XXX descriptor must be aligned on 64-bit boundaries */
entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL); entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry == NULL) { if (!entry) {
dev_err(dev, "Failed to allocate memory for dma resource "
"structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_mem; goto err_mem;
} }
@ -1052,7 +1048,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
goto err_align; 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) { if (dest->type == VME_DMA_VME) {
entry->descriptor.dctl |= CA91CX42_DCTL_L2V; 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! */ /* If we already have a callback attached, we can't move it! */
for (i = 0; i < lm->monitors; i++) { for (i = 0; i < lm->monitors; i++) {
if (bridge->lm_callback[i] != NULL) { if (bridge->lm_callback[i]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
dev_err(dev, "Location monitor callback attached, " dev_err(dev, "Location monitor callback attached, "
"can't reset\n"); "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 */ /* Check that a callback isn't already attached */
if (bridge->lm_callback[monitor] != NULL) { if (bridge->lm_callback[monitor]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
dev_err(dev, "Existing callback attached\n"); dev_err(dev, "Existing callback attached\n");
return -EBUSY; return -EBUSY;
@ -1567,7 +1563,7 @@ static int ca91cx42_crcsr_init(struct vme_bridge *ca91cx42_bridge,
/* Allocate mem for CR/CSR image */ /* Allocate mem for CR/CSR image */
bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
&bridge->crcsr_bus); &bridge->crcsr_bus);
if (bridge->crcsr_kernel == NULL) { if (!bridge->crcsr_kernel) {
dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR " dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR "
"image\n"); "image\n");
return -ENOMEM; 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 /* We want to support more than one of each bridge so we need to
* dynamically allocate the bridge structure * dynamically allocate the bridge structure
*/ */
ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); ca91cx42_bridge = kzalloc(sizeof(*ca91cx42_bridge), GFP_KERNEL);
if (!ca91cx42_bridge) {
if (ca91cx42_bridge == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for device "
"structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_struct; goto err_struct;
} }
vme_init_bridge(ca91cx42_bridge); vme_init_bridge(ca91cx42_bridge);
ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); ca91cx42_device = kzalloc(sizeof(*ca91cx42_device), GFP_KERNEL);
if (!ca91cx42_device) {
if (ca91cx42_device == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for device "
"structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_driver; 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 */ /* Add master windows to list */
for (i = 0; i < CA91C142_MAX_MASTER; i++) { for (i = 0; i < CA91C142_MAX_MASTER; i++) {
master_image = kmalloc(sizeof(struct vme_master_resource), master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
GFP_KERNEL); if (!master_image) {
if (master_image == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"master resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_master; 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; VME_SUPER | VME_USER | VME_PROG | VME_DATA;
master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64; master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64;
memset(&master_image->bus_resource, 0, memset(&master_image->bus_resource, 0,
sizeof(struct resource)); sizeof(master_image->bus_resource));
master_image->kern_base = NULL; master_image->kern_base = NULL;
list_add_tail(&master_image->list, list_add_tail(&master_image->list,
&ca91cx42_bridge->master_resources); &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 */ /* Add slave windows to list */
for (i = 0; i < CA91C142_MAX_SLAVE; i++) { for (i = 0; i < CA91C142_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(struct vme_slave_resource), slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
GFP_KERNEL); if (!slave_image) {
if (slave_image == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"slave resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_slave; 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 */ /* Add dma engines to list */
for (i = 0; i < CA91C142_MAX_DMA; i++) { for (i = 0; i < CA91C142_MAX_DMA; i++) {
dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL);
GFP_KERNEL); if (!dma_ctrlr) {
if (dma_ctrlr == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"dma resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_dma; 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 */ /* Add location monitor to list */
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); lm = kmalloc(sizeof(*lm), GFP_KERNEL);
if (lm == NULL) { if (!lm) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"location monitor resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_lm; goto err_lm;
} }

View File

@ -409,7 +409,7 @@ static void fake_lm_check(struct fake_driver *bridge, unsigned long long addr,
/* Each location monitor covers 8 bytes */ /* Each location monitor covers 8 bytes */
if (((lm_base + (8 * i)) <= addr) && if (((lm_base + (8 * i)) <= addr) &&
((lm_base + (8 * i) + 8) > addr)) { ((lm_base + (8 * i) + 8) > addr)) {
if (bridge->lm_callback[i] != NULL) if (bridge->lm_callback[i])
bridge->lm_callback[i]( bridge->lm_callback[i](
bridge->lm_data[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! */ /* If we already have a callback attached, we can't move it! */
for (i = 0; i < lm->monitors; i++) { for (i = 0; i < lm->monitors; i++) {
if (bridge->lm_callback[i] != NULL) { if (bridge->lm_callback[i]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
pr_err("Location monitor callback attached, can't reset\n"); pr_err("Location monitor callback attached, can't reset\n");
return -EBUSY; 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 */ /* Check that a callback isn't already attached */
if (bridge->lm_callback[monitor] != NULL) { if (bridge->lm_callback[monitor]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
pr_err("Existing callback attached\n"); pr_err("Existing callback attached\n");
return -EBUSY; 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 */ /* If all location monitors disabled, disable global Location Monitor */
tmp = 0; tmp = 0;
for (i = 0; i < lm->monitors; i++) { for (i = 0; i < lm->monitors; i++) {
if (bridge->lm_callback[i] != NULL) if (bridge->lm_callback[i])
tmp = 1; tmp = 1;
} }
@ -1003,7 +1003,7 @@ static void *fake_alloc_consistent(struct device *parent, size_t size,
{ {
void *alloc = kmalloc(size, GFP_KERNEL); void *alloc = kmalloc(size, GFP_KERNEL);
if (alloc != NULL) if (alloc)
*dma = fake_ptr_to_pci(alloc); *dma = fake_ptr_to_pci(alloc);
return alloc; return alloc;
@ -1039,7 +1039,7 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge)
/* Allocate mem for CR/CSR image */ /* Allocate mem for CR/CSR image */
bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL); bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL);
bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel); bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
if (bridge->crcsr_kernel == NULL) if (!bridge->crcsr_kernel)
return -ENOMEM; return -ENOMEM;
vstat = fake_slot_get(fake_bridge); 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 /* If we want to support more than one bridge at some point, we need to
* dynamically allocate this so we get one per device. * dynamically allocate this so we get one per device.
*/ */
fake_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL);
if (fake_bridge == NULL) { if (!fake_bridge) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_struct; goto err_struct;
} }
fake_device = kzalloc(sizeof(struct fake_driver), GFP_KERNEL); fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL);
if (fake_device == NULL) { if (!fake_device) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_driver; goto err_driver;
} }
@ -1104,9 +1104,8 @@ static int __init fake_init(void)
/* Add master windows to list */ /* Add master windows to list */
INIT_LIST_HEAD(&fake_bridge->master_resources); INIT_LIST_HEAD(&fake_bridge->master_resources);
for (i = 0; i < FAKE_MAX_MASTER; i++) { for (i = 0; i < FAKE_MAX_MASTER; i++) {
master_image = kmalloc(sizeof(struct vme_master_resource), master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
GFP_KERNEL); if (!master_image) {
if (master_image == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_master; goto err_master;
} }
@ -1131,9 +1130,8 @@ static int __init fake_init(void)
/* Add slave windows to list */ /* Add slave windows to list */
INIT_LIST_HEAD(&fake_bridge->slave_resources); INIT_LIST_HEAD(&fake_bridge->slave_resources);
for (i = 0; i < FAKE_MAX_SLAVE; i++) { for (i = 0; i < FAKE_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(struct vme_slave_resource), slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
GFP_KERNEL); if (!slave_image) {
if (slave_image == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_slave; goto err_slave;
} }
@ -1154,9 +1152,8 @@ static int __init fake_init(void)
/* Add location monitor to list */ /* Add location monitor to list */
INIT_LIST_HEAD(&fake_bridge->lm_resources); INIT_LIST_HEAD(&fake_bridge->lm_resources);
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); lm = kmalloc(sizeof(*lm), GFP_KERNEL);
if (lm == NULL) { if (!lm) {
pr_err("Failed to allocate memory for location monitor resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_lm; goto err_lm;
} }

View File

@ -741,18 +741,16 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
image->kern_base = NULL; image->kern_base = NULL;
kfree(image->bus_resource.name); kfree(image->bus_resource.name);
release_resource(&image->bus_resource); 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 */ /* Exit here if size is zero */
if (size == 0) if (size == 0)
return 0; return 0;
if (image->bus_resource.name == NULL) { if (!image->bus_resource.name) {
image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC); image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
if (image->bus_resource.name == NULL) { if (!image->bus_resource.name) {
dev_err(tsi148_bridge->parent, "Unable to allocate "
"memory for resource name\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_name; goto err_name;
} }
@ -778,7 +776,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
image->kern_base = ioremap_nocache( image->kern_base = ioremap_nocache(
image->bus_resource.start, size); image->bus_resource.start, size);
if (image->kern_base == NULL) { if (!image->kern_base) {
dev_err(tsi148_bridge->parent, "Failed to remap resource\n"); dev_err(tsi148_bridge->parent, "Failed to remap resource\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_remap; goto err_remap;
@ -790,7 +788,7 @@ err_remap:
release_resource(&image->bus_resource); release_resource(&image->bus_resource);
err_resource: err_resource:
kfree(image->bus_resource.name); kfree(image->bus_resource.name);
memset(&image->bus_resource, 0, sizeof(struct resource)); memset(&image->bus_resource, 0, sizeof(image->bus_resource));
err_name: err_name:
return retval; return retval;
} }
@ -804,7 +802,7 @@ static void tsi148_free_resource(struct vme_master_resource *image)
image->kern_base = NULL; image->kern_base = NULL;
release_resource(&image->bus_resource); release_resource(&image->bus_resource);
kfree(image->bus_resource.name); 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; tsi148_bridge = list->parent->parent;
/* Descriptor must be aligned on 64-bit boundaries */ /* Descriptor must be aligned on 64-bit boundaries */
entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL); entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry == NULL) { if (!entry) {
dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
"dma resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_mem; 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 /* Given we are going to fill out the structure, we probably don't
* need to zero it, but better safe than sorry for now. * 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 */ /* Fill out source part */
switch (src->type) { 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); list_add_tail(&entry->list, &list->entries);
entry->dma_handle = dma_map_single(tsi148_bridge->parent, entry->dma_handle = dma_map_single(tsi148_bridge->parent,
&entry->descriptor, &entry->descriptor,
sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); sizeof(entry->descriptor),
DMA_TO_DEVICE);
if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) { if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) {
dev_err(tsi148_bridge->parent, "DMA mapping error\n"); dev_err(tsi148_bridge->parent, "DMA mapping error\n");
retval = -EINVAL; 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! */ /* If we already have a callback attached, we can't move it! */
for (i = 0; i < lm->monitors; i++) { for (i = 0; i < lm->monitors; i++) {
if (bridge->lm_callback[i] != NULL) { if (bridge->lm_callback[i]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
dev_err(tsi148_bridge->parent, "Location monitor " dev_err(tsi148_bridge->parent, "Location monitor "
"callback attached, can't reset\n"); "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 */ /* Check that a callback isn't already attached */
if (bridge->lm_callback[monitor] != NULL) { if (bridge->lm_callback[monitor]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
dev_err(tsi148_bridge->parent, "Existing callback attached\n"); dev_err(tsi148_bridge->parent, "Existing callback attached\n");
return -EBUSY; return -EBUSY;
@ -2208,7 +2205,7 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge,
/* Allocate mem for CR/CSR image */ /* Allocate mem for CR/CSR image */
bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
&bridge->crcsr_bus); &bridge->crcsr_bus);
if (bridge->crcsr_kernel == NULL) { if (!bridge->crcsr_kernel) {
dev_err(tsi148_bridge->parent, "Failed to allocate memory for " dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
"CR/CSR image\n"); "CR/CSR image\n");
return -ENOMEM; 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 /* If we want to support more than one of each bridge, we need to
* dynamically generate this so we get one per device * dynamically generate this so we get one per device
*/ */
tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); tsi148_bridge = kzalloc(sizeof(*tsi148_bridge), GFP_KERNEL);
if (tsi148_bridge == NULL) { if (!tsi148_bridge) {
dev_err(&pdev->dev, "Failed to allocate memory for device "
"structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_struct; goto err_struct;
} }
vme_init_bridge(tsi148_bridge); vme_init_bridge(tsi148_bridge);
tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL); tsi148_device = kzalloc(sizeof(*tsi148_device), GFP_KERNEL);
if (tsi148_device == NULL) { if (!tsi148_device) {
dev_err(&pdev->dev, "Failed to allocate memory for device "
"structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_driver; goto err_driver;
} }
@ -2371,10 +2364,9 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
master_num--; master_num--;
tsi148_device->flush_image = tsi148_device->flush_image =
kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL); kmalloc(sizeof(*tsi148_device->flush_image),
if (tsi148_device->flush_image == NULL) { GFP_KERNEL);
dev_err(&pdev->dev, "Failed to allocate memory for " if (!tsi148_device->flush_image) {
"flush resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_master; 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->locked = 1;
tsi148_device->flush_image->number = master_num; tsi148_device->flush_image->number = master_num;
memset(&tsi148_device->flush_image->bus_resource, 0, 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; tsi148_device->flush_image->kern_base = NULL;
} }
/* Add master windows to list */ /* Add master windows to list */
for (i = 0; i < master_num; i++) { for (i = 0; i < master_num; i++) {
master_image = kmalloc(sizeof(struct vme_master_resource), master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
GFP_KERNEL); if (!master_image) {
if (master_image == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"master resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_master; 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; VME_PROG | VME_DATA;
master_image->width_attr = VME_D16 | VME_D32; master_image->width_attr = VME_D16 | VME_D32;
memset(&master_image->bus_resource, 0, memset(&master_image->bus_resource, 0,
sizeof(struct resource)); sizeof(master_image->bus_resource));
master_image->kern_base = NULL; master_image->kern_base = NULL;
list_add_tail(&master_image->list, list_add_tail(&master_image->list,
&tsi148_bridge->master_resources); &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 */ /* Add slave windows to list */
for (i = 0; i < TSI148_MAX_SLAVE; i++) { for (i = 0; i < TSI148_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(struct vme_slave_resource), slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
GFP_KERNEL); if (!slave_image) {
if (slave_image == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"slave resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_slave; 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 */ /* Add dma engines to list */
for (i = 0; i < TSI148_MAX_DMA; i++) { for (i = 0; i < TSI148_MAX_DMA; i++) {
dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL);
GFP_KERNEL); if (!dma_ctrlr) {
if (dma_ctrlr == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"dma resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_dma; 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 */ /* Add location monitor to list */
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); lm = kmalloc(sizeof(*lm), GFP_KERNEL);
if (lm == NULL) { if (!lm) {
dev_err(&pdev->dev, "Failed to allocate memory for "
"location monitor resource structure\n");
retval = -ENOMEM; retval = -ENOMEM;
goto err_lm; goto err_lm;
} }

View File

@ -92,23 +92,23 @@ void *vme_alloc_consistent(struct vme_resource *resource, size_t size,
{ {
struct vme_bridge *bridge; struct vme_bridge *bridge;
if (resource == NULL) { if (!resource) {
printk(KERN_ERR "No resource\n"); printk(KERN_ERR "No resource\n");
return NULL; return NULL;
} }
bridge = find_bridge(resource); bridge = find_bridge(resource);
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find bridge\n"); printk(KERN_ERR "Can't find bridge\n");
return NULL; return NULL;
} }
if (bridge->parent == NULL) { if (!bridge->parent) {
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name); printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
return NULL; return NULL;
} }
if (bridge->alloc_consistent == NULL) { if (!bridge->alloc_consistent) {
printk(KERN_ERR "alloc_consistent not supported by bridge %s\n", printk(KERN_ERR "alloc_consistent not supported by bridge %s\n",
bridge->name); bridge->name);
return NULL; return NULL;
@ -132,23 +132,23 @@ void vme_free_consistent(struct vme_resource *resource, size_t size,
{ {
struct vme_bridge *bridge; struct vme_bridge *bridge;
if (resource == NULL) { if (!resource) {
printk(KERN_ERR "No resource\n"); printk(KERN_ERR "No resource\n");
return; return;
} }
bridge = find_bridge(resource); bridge = find_bridge(resource);
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find bridge\n"); printk(KERN_ERR "Can't find bridge\n");
return; return;
} }
if (bridge->parent == NULL) { if (!bridge->parent) {
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name); printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
return; return;
} }
if (bridge->free_consistent == NULL) { if (!bridge->free_consistent) {
printk(KERN_ERR "free_consistent not supported by bridge %s\n", printk(KERN_ERR "free_consistent not supported by bridge %s\n",
bridge->name); bridge->name);
return; return;
@ -301,7 +301,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
struct vme_resource *resource = NULL; struct vme_resource *resource = NULL;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
goto err_bus; goto err_bus;
} }
@ -311,7 +311,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
slave_image = list_entry(slave_pos, slave_image = list_entry(slave_pos,
struct vme_slave_resource, list); struct vme_slave_resource, list);
if (slave_image == NULL) { if (!slave_image) {
printk(KERN_ERR "Registered NULL Slave resource\n"); printk(KERN_ERR "Registered NULL Slave resource\n");
continue; continue;
} }
@ -331,14 +331,13 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
} }
/* No free image */ /* No free image */
if (allocated_image == NULL) if (!allocated_image)
goto err_image; goto err_image;
resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (resource == NULL) { if (!resource)
printk(KERN_WARNING "Unable to allocate resource structure\n");
goto err_alloc; goto err_alloc;
}
resource->type = VME_SLAVE; resource->type = VME_SLAVE;
resource->entry = &allocated_image->list; resource->entry = &allocated_image->list;
@ -387,7 +386,7 @@ int vme_slave_set(struct vme_resource *resource, int enabled,
image = list_entry(resource->entry, struct vme_slave_resource, list); image = list_entry(resource->entry, struct vme_slave_resource, list);
if (bridge->slave_set == NULL) { if (!bridge->slave_set) {
printk(KERN_ERR "Function not supported\n"); printk(KERN_ERR "Function not supported\n");
return -ENOSYS; return -ENOSYS;
} }
@ -436,7 +435,7 @@ int vme_slave_get(struct vme_resource *resource, int *enabled,
image = list_entry(resource->entry, struct vme_slave_resource, list); image = list_entry(resource->entry, struct vme_slave_resource, list);
if (bridge->slave_get == NULL) { if (!bridge->slave_get) {
printk(KERN_ERR "vme_slave_get not supported\n"); printk(KERN_ERR "vme_slave_get not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -463,7 +462,7 @@ void vme_slave_free(struct vme_resource *resource)
slave_image = list_entry(resource->entry, struct vme_slave_resource, slave_image = list_entry(resource->entry, struct vme_slave_resource,
list); list);
if (slave_image == NULL) { if (!slave_image) {
printk(KERN_ERR "Can't find slave resource\n"); printk(KERN_ERR "Can't find slave resource\n");
return; return;
} }
@ -503,7 +502,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
struct vme_resource *resource = NULL; struct vme_resource *resource = NULL;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
goto err_bus; goto err_bus;
} }
@ -513,7 +512,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
master_image = list_entry(master_pos, master_image = list_entry(master_pos,
struct vme_master_resource, list); struct vme_master_resource, list);
if (master_image == NULL) { if (!master_image) {
printk(KERN_WARNING "Registered NULL master resource\n"); printk(KERN_WARNING "Registered NULL master resource\n");
continue; continue;
} }
@ -534,16 +533,15 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
} }
/* Check to see if we found a resource */ /* Check to see if we found a resource */
if (allocated_image == NULL) { if (!allocated_image) {
printk(KERN_ERR "Can't find a suitable resource\n"); printk(KERN_ERR "Can't find a suitable resource\n");
goto err_image; goto err_image;
} }
resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (resource == NULL) { if (!resource)
printk(KERN_ERR "Unable to allocate resource structure\n");
goto err_alloc; goto err_alloc;
}
resource->type = VME_MASTER; resource->type = VME_MASTER;
resource->entry = &allocated_image->list; resource->entry = &allocated_image->list;
@ -592,7 +590,7 @@ int vme_master_set(struct vme_resource *resource, int enabled,
image = list_entry(resource->entry, struct vme_master_resource, list); image = list_entry(resource->entry, struct vme_master_resource, list);
if (bridge->master_set == NULL) { if (!bridge->master_set) {
printk(KERN_WARNING "vme_master_set not supported\n"); printk(KERN_WARNING "vme_master_set not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -642,7 +640,7 @@ int vme_master_get(struct vme_resource *resource, int *enabled,
image = list_entry(resource->entry, struct vme_master_resource, list); image = list_entry(resource->entry, struct vme_master_resource, list);
if (bridge->master_get == NULL) { if (!bridge->master_get) {
printk(KERN_WARNING "%s not supported\n", __func__); printk(KERN_WARNING "%s not supported\n", __func__);
return -EINVAL; return -EINVAL;
} }
@ -674,7 +672,7 @@ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,
struct vme_master_resource *image; struct vme_master_resource *image;
size_t length; size_t length;
if (bridge->master_read == NULL) { if (!bridge->master_read) {
printk(KERN_WARNING "Reading from resource not supported\n"); printk(KERN_WARNING "Reading from resource not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -723,7 +721,7 @@ ssize_t vme_master_write(struct vme_resource *resource, void *buf,
struct vme_master_resource *image; struct vme_master_resource *image;
size_t length; size_t length;
if (bridge->master_write == NULL) { if (!bridge->master_write) {
printk(KERN_WARNING "Writing to resource not supported\n"); printk(KERN_WARNING "Writing to resource not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -774,7 +772,7 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,
struct vme_bridge *bridge = find_bridge(resource); struct vme_bridge *bridge = find_bridge(resource);
struct vme_master_resource *image; struct vme_master_resource *image;
if (bridge->master_rmw == NULL) { if (!bridge->master_rmw) {
printk(KERN_WARNING "Writing to resource not supported\n"); printk(KERN_WARNING "Writing to resource not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -844,7 +842,7 @@ void vme_master_free(struct vme_resource *resource)
master_image = list_entry(resource->entry, struct vme_master_resource, master_image = list_entry(resource->entry, struct vme_master_resource,
list); list);
if (master_image == NULL) { if (!master_image) {
printk(KERN_ERR "Can't find master resource\n"); printk(KERN_ERR "Can't find master resource\n");
return; return;
} }
@ -884,7 +882,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
printk(KERN_ERR "No VME resource Attribute tests done\n"); printk(KERN_ERR "No VME resource Attribute tests done\n");
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
goto err_bus; goto err_bus;
} }
@ -893,8 +891,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
list_for_each(dma_pos, &bridge->dma_resources) { list_for_each(dma_pos, &bridge->dma_resources) {
dma_ctrlr = list_entry(dma_pos, dma_ctrlr = list_entry(dma_pos,
struct vme_dma_resource, list); struct vme_dma_resource, list);
if (!dma_ctrlr) {
if (dma_ctrlr == NULL) {
printk(KERN_ERR "Registered NULL DMA resource\n"); printk(KERN_ERR "Registered NULL DMA resource\n");
continue; continue;
} }
@ -913,14 +910,13 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
} }
/* Check to see if we found a resource */ /* Check to see if we found a resource */
if (allocated_ctrlr == NULL) if (!allocated_ctrlr)
goto err_ctrlr; goto err_ctrlr;
resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (resource == NULL) { if (!resource)
printk(KERN_WARNING "Unable to allocate resource structure\n");
goto err_alloc; goto err_alloc;
}
resource->type = VME_DMA; resource->type = VME_DMA;
resource->entry = &allocated_ctrlr->list; resource->entry = &allocated_ctrlr->list;
@ -949,7 +945,6 @@ EXPORT_SYMBOL(vme_dma_request);
*/ */
struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource) struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
{ {
struct vme_dma_resource *ctrlr;
struct vme_dma_list *dma_list; struct vme_dma_list *dma_list;
if (resource->type != VME_DMA) { if (resource->type != VME_DMA) {
@ -957,15 +952,14 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
return NULL; return NULL;
} }
ctrlr = list_entry(resource->entry, struct vme_dma_resource, list); dma_list = kmalloc(sizeof(*dma_list), GFP_KERNEL);
if (!dma_list)
dma_list = kmalloc(sizeof(struct vme_dma_list), GFP_KERNEL);
if (dma_list == NULL) {
printk(KERN_ERR "Unable to allocate memory for new DMA list\n");
return NULL; return NULL;
}
INIT_LIST_HEAD(&dma_list->entries); INIT_LIST_HEAD(&dma_list->entries);
dma_list->parent = ctrlr; dma_list->parent = list_entry(resource->entry,
struct vme_dma_resource,
list);
mutex_init(&dma_list->mtx); mutex_init(&dma_list->mtx);
return dma_list; return dma_list;
@ -988,17 +982,13 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, u32 type)
struct vme_dma_attr *attributes; struct vme_dma_attr *attributes;
struct vme_dma_pattern *pattern_attr; struct vme_dma_pattern *pattern_attr;
attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL); attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
if (attributes == NULL) { if (!attributes)
printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
goto err_attr; goto err_attr;
}
pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL); pattern_attr = kmalloc(sizeof(*pattern_attr), GFP_KERNEL);
if (pattern_attr == NULL) { if (!pattern_attr)
printk(KERN_ERR "Unable to allocate memory for pattern attributes\n");
goto err_pat; goto err_pat;
}
attributes->type = VME_DMA_PATTERN; attributes->type = VME_DMA_PATTERN;
attributes->private = (void *)pattern_attr; attributes->private = (void *)pattern_attr;
@ -1032,19 +1022,13 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address)
/* XXX Run some sanity checks here */ /* XXX Run some sanity checks here */
attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL); attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
if (attributes == NULL) { if (!attributes)
printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
goto err_attr; goto err_attr;
}
pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL); pci_attr = kmalloc(sizeof(*pci_attr), GFP_KERNEL);
if (pci_attr == NULL) { if (!pci_attr)
printk(KERN_ERR "Unable to allocate memory for PCI attributes\n");
goto err_pci; goto err_pci;
}
attributes->type = VME_DMA_PCI; attributes->type = VME_DMA_PCI;
attributes->private = (void *)pci_attr; attributes->private = (void *)pci_attr;
@ -1079,18 +1063,13 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address,
struct vme_dma_attr *attributes; struct vme_dma_attr *attributes;
struct vme_dma_vme *vme_attr; struct vme_dma_vme *vme_attr;
attributes = kmalloc( attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
sizeof(struct vme_dma_attr), GFP_KERNEL); if (!attributes)
if (attributes == NULL) {
printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
goto err_attr; goto err_attr;
}
vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL); vme_attr = kmalloc(sizeof(*vme_attr), GFP_KERNEL);
if (vme_attr == NULL) { if (!vme_attr)
printk(KERN_ERR "Unable to allocate memory for VME attributes\n");
goto err_vme; goto err_vme;
}
attributes->type = VME_DMA_VME; attributes->type = VME_DMA_VME;
attributes->private = (void *)vme_attr; attributes->private = (void *)vme_attr;
@ -1146,7 +1125,7 @@ int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,
struct vme_bridge *bridge = list->parent->parent; struct vme_bridge *bridge = list->parent->parent;
int retval; int retval;
if (bridge->dma_list_add == NULL) { if (!bridge->dma_list_add) {
printk(KERN_WARNING "Link List DMA generation not supported\n"); printk(KERN_WARNING "Link List DMA generation not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1179,7 +1158,7 @@ int vme_dma_list_exec(struct vme_dma_list *list)
struct vme_bridge *bridge = list->parent->parent; struct vme_bridge *bridge = list->parent->parent;
int retval; int retval;
if (bridge->dma_list_exec == NULL) { if (!bridge->dma_list_exec) {
printk(KERN_ERR "Link List DMA execution not supported\n"); printk(KERN_ERR "Link List DMA execution not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1208,7 +1187,7 @@ int vme_dma_list_free(struct vme_dma_list *list)
struct vme_bridge *bridge = list->parent->parent; struct vme_bridge *bridge = list->parent->parent;
int retval; int retval;
if (bridge->dma_list_empty == NULL) { if (!bridge->dma_list_empty) {
printk(KERN_WARNING "Emptying of Link Lists not supported\n"); printk(KERN_WARNING "Emptying of Link Lists not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1340,8 +1319,7 @@ void vme_irq_handler(struct vme_bridge *bridge, int level, int statid)
call = bridge->irq[level - 1].callback[statid].func; call = bridge->irq[level - 1].callback[statid].func;
priv_data = bridge->irq[level - 1].callback[statid].priv_data; priv_data = bridge->irq[level - 1].callback[statid].priv_data;
if (call)
if (call != NULL)
call(level, statid, priv_data); call(level, statid, priv_data);
else else
printk(KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n", printk(KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n",
@ -1372,7 +1350,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,
struct vme_bridge *bridge; struct vme_bridge *bridge;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
return -EINVAL; return -EINVAL;
} }
@ -1382,7 +1360,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,
return -EINVAL; return -EINVAL;
} }
if (bridge->irq_set == NULL) { if (!bridge->irq_set) {
printk(KERN_ERR "Configuring interrupts not supported\n"); printk(KERN_ERR "Configuring interrupts not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1421,7 +1399,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
struct vme_bridge *bridge; struct vme_bridge *bridge;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
return; return;
} }
@ -1431,7 +1409,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
return; return;
} }
if (bridge->irq_set == NULL) { if (!bridge->irq_set) {
printk(KERN_ERR "Configuring interrupts not supported\n"); printk(KERN_ERR "Configuring interrupts not supported\n");
return; return;
} }
@ -1468,7 +1446,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
struct vme_bridge *bridge; struct vme_bridge *bridge;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
return -EINVAL; return -EINVAL;
} }
@ -1478,7 +1456,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
return -EINVAL; return -EINVAL;
} }
if (bridge->irq_generate == NULL) { if (!bridge->irq_generate) {
printk(KERN_WARNING "Interrupt generation not supported\n"); printk(KERN_WARNING "Interrupt generation not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1506,7 +1484,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
struct vme_resource *resource = NULL; struct vme_resource *resource = NULL;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
goto err_bus; goto err_bus;
} }
@ -1515,8 +1493,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
list_for_each(lm_pos, &bridge->lm_resources) { list_for_each(lm_pos, &bridge->lm_resources) {
lm = list_entry(lm_pos, lm = list_entry(lm_pos,
struct vme_lm_resource, list); struct vme_lm_resource, list);
if (!lm) {
if (lm == NULL) {
printk(KERN_ERR "Registered NULL Location Monitor resource\n"); printk(KERN_ERR "Registered NULL Location Monitor resource\n");
continue; continue;
} }
@ -1533,14 +1510,13 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
} }
/* Check to see if we found a resource */ /* Check to see if we found a resource */
if (allocated_lm == NULL) if (!allocated_lm)
goto err_lm; goto err_lm;
resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (resource == NULL) { if (!resource)
printk(KERN_ERR "Unable to allocate resource structure\n");
goto err_alloc; goto err_alloc;
}
resource->type = VME_LM; resource->type = VME_LM;
resource->entry = &allocated_lm->list; resource->entry = &allocated_lm->list;
@ -1610,7 +1586,7 @@ int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base,
lm = list_entry(resource->entry, struct vme_lm_resource, list); lm = list_entry(resource->entry, struct vme_lm_resource, list);
if (bridge->lm_set == NULL) { if (!bridge->lm_set) {
printk(KERN_ERR "vme_lm_set not supported\n"); printk(KERN_ERR "vme_lm_set not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1646,7 +1622,7 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,
lm = list_entry(resource->entry, struct vme_lm_resource, list); lm = list_entry(resource->entry, struct vme_lm_resource, list);
if (bridge->lm_get == NULL) { if (!bridge->lm_get) {
printk(KERN_ERR "vme_lm_get not supported\n"); printk(KERN_ERR "vme_lm_get not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1683,7 +1659,7 @@ int vme_lm_attach(struct vme_resource *resource, int monitor,
lm = list_entry(resource->entry, struct vme_lm_resource, list); lm = list_entry(resource->entry, struct vme_lm_resource, list);
if (bridge->lm_attach == NULL) { if (!bridge->lm_attach) {
printk(KERN_ERR "vme_lm_attach not supported\n"); printk(KERN_ERR "vme_lm_attach not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1716,7 +1692,7 @@ int vme_lm_detach(struct vme_resource *resource, int monitor)
lm = list_entry(resource->entry, struct vme_lm_resource, list); lm = list_entry(resource->entry, struct vme_lm_resource, list);
if (bridge->lm_detach == NULL) { if (!bridge->lm_detach) {
printk(KERN_ERR "vme_lm_detach not supported\n"); printk(KERN_ERR "vme_lm_detach not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1778,12 +1754,12 @@ int vme_slot_num(struct vme_dev *vdev)
struct vme_bridge *bridge; struct vme_bridge *bridge;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n"); printk(KERN_ERR "Can't find VME bus\n");
return -EINVAL; return -EINVAL;
} }
if (bridge->slot_get == NULL) { if (!bridge->slot_get) {
printk(KERN_WARNING "vme_slot_num not supported\n"); printk(KERN_WARNING "vme_slot_num not supported\n");
return -EINVAL; return -EINVAL;
} }
@ -1806,7 +1782,7 @@ int vme_bus_num(struct vme_dev *vdev)
struct vme_bridge *bridge; struct vme_bridge *bridge;
bridge = vdev->bridge; bridge = vdev->bridge;
if (bridge == NULL) { if (!bridge) {
pr_err("Can't find VME bus\n"); pr_err("Can't find VME bus\n");
return -EINVAL; return -EINVAL;
} }
@ -1886,7 +1862,7 @@ static int __vme_register_driver_bus(struct vme_driver *drv,
struct vme_dev *tmp; struct vme_dev *tmp;
for (i = 0; i < ndevs; i++) { for (i = 0; i < ndevs; i++) {
vdev = kzalloc(sizeof(struct vme_dev), GFP_KERNEL); vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
if (!vdev) { if (!vdev) {
err = -ENOMEM; err = -ENOMEM;
goto err_devalloc; goto err_devalloc;
@ -2018,30 +1994,26 @@ static int vme_bus_match(struct device *dev, struct device_driver *drv)
static int vme_bus_probe(struct device *dev) static int vme_bus_probe(struct device *dev)
{ {
int retval = -ENODEV;
struct vme_driver *driver; struct vme_driver *driver;
struct vme_dev *vdev = dev_to_vme_dev(dev); struct vme_dev *vdev = dev_to_vme_dev(dev);
driver = dev->platform_data; driver = dev->platform_data;
if (driver->probe)
return driver->probe(vdev);
if (driver->probe != NULL) return -ENODEV;
retval = driver->probe(vdev);
return retval;
} }
static int vme_bus_remove(struct device *dev) static int vme_bus_remove(struct device *dev)
{ {
int retval = -ENODEV;
struct vme_driver *driver; struct vme_driver *driver;
struct vme_dev *vdev = dev_to_vme_dev(dev); struct vme_dev *vdev = dev_to_vme_dev(dev);
driver = dev->platform_data; driver = dev->platform_data;
if (driver->remove)
return driver->remove(vdev);
if (driver->remove != NULL) return -ENODEV;
retval = driver->remove(vdev);
return retval;
} }
struct bus_type vme_bus_type = { struct bus_type vme_bus_type = {