summaryrefslogtreecommitdiffstats
path: root/drivers/vme
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-20 09:24:34 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-10-20 09:24:34 -0400
commitad146e37d2a2f1cbf16bf4c7bbb9362f009a1480 (patch)
tree5a0a5bfdc353a47207580f3bc9020159ed3773fc /drivers/vme
parentf7f84fded6c461d58ca73c85f0cb23a036717110 (diff)
parenta75dc630086a6b83d780a7b27d03c4c0abdf0807 (diff)
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.
Diffstat (limited to 'drivers/vme')
-rw-r--r--drivers/vme/bridges/vme_ca91cx42.c73
-rw-r--r--drivers/vme/bridges/vme_fake.c35
-rw-r--r--drivers/vme/bridges/vme_tsi148.c83
-rw-r--r--drivers/vme/vme.c194
4 files changed, 157 insertions, 228 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,
511 ca91cx42_bridge = image->parent; 511 ca91cx42_bridge = image->parent;
512 512
513 /* Find pci_dev container of dev */ 513 /* Find pci_dev container of dev */
514 if (ca91cx42_bridge->parent == NULL) { 514 if (!ca91cx42_bridge->parent) {
515 dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n"); 515 dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n");
516 return -EINVAL; 516 return -EINVAL;
517 } 517 }
@@ -529,14 +529,12 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
529 image->kern_base = NULL; 529 image->kern_base = NULL;
530 kfree(image->bus_resource.name); 530 kfree(image->bus_resource.name);
531 release_resource(&image->bus_resource); 531 release_resource(&image->bus_resource);
532 memset(&image->bus_resource, 0, sizeof(struct resource)); 532 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
533 } 533 }
534 534
535 if (image->bus_resource.name == NULL) { 535 if (!image->bus_resource.name) {
536 image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC); 536 image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
537 if (image->bus_resource.name == NULL) { 537 if (!image->bus_resource.name) {
538 dev_err(ca91cx42_bridge->parent, "Unable to allocate "
539 "memory for resource name\n");
540 retval = -ENOMEM; 538 retval = -ENOMEM;
541 goto err_name; 539 goto err_name;
542 } 540 }
@@ -562,7 +560,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
562 560
563 image->kern_base = ioremap_nocache( 561 image->kern_base = ioremap_nocache(
564 image->bus_resource.start, size); 562 image->bus_resource.start, size);
565 if (image->kern_base == NULL) { 563 if (!image->kern_base) {
566 dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n"); 564 dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n");
567 retval = -ENOMEM; 565 retval = -ENOMEM;
568 goto err_remap; 566 goto err_remap;
@@ -574,7 +572,7 @@ err_remap:
574 release_resource(&image->bus_resource); 572 release_resource(&image->bus_resource);
575err_resource: 573err_resource:
576 kfree(image->bus_resource.name); 574 kfree(image->bus_resource.name);
577 memset(&image->bus_resource, 0, sizeof(struct resource)); 575 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
578err_name: 576err_name:
579 return retval; 577 return retval;
580} 578}
@@ -588,7 +586,7 @@ static void ca91cx42_free_resource(struct vme_master_resource *image)
588 image->kern_base = NULL; 586 image->kern_base = NULL;
589 release_resource(&image->bus_resource); 587 release_resource(&image->bus_resource);
590 kfree(image->bus_resource.name); 588 kfree(image->bus_resource.name);
591 memset(&image->bus_resource, 0, sizeof(struct resource)); 589 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
592} 590}
593 591
594 592
@@ -1036,10 +1034,8 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
1036 dev = list->parent->parent->parent; 1034 dev = list->parent->parent->parent;
1037 1035
1038 /* XXX descriptor must be aligned on 64-bit boundaries */ 1036 /* XXX descriptor must be aligned on 64-bit boundaries */
1039 entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL); 1037 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
1040 if (entry == NULL) { 1038 if (!entry) {
1041 dev_err(dev, "Failed to allocate memory for dma resource "
1042 "structure\n");
1043 retval = -ENOMEM; 1039 retval = -ENOMEM;
1044 goto err_mem; 1040 goto err_mem;
1045 } 1041 }
@@ -1052,7 +1048,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
1052 goto err_align; 1048 goto err_align;
1053 } 1049 }
1054 1050
1055 memset(&entry->descriptor, 0, sizeof(struct ca91cx42_dma_descriptor)); 1051 memset(&entry->descriptor, 0, sizeof(entry->descriptor));
1056 1052
1057 if (dest->type == VME_DMA_VME) { 1053 if (dest->type == VME_DMA_VME) {
1058 entry->descriptor.dctl |= CA91CX42_DCTL_L2V; 1054 entry->descriptor.dctl |= CA91CX42_DCTL_L2V;
@@ -1323,7 +1319,7 @@ static int ca91cx42_lm_set(struct vme_lm_resource *lm,
1323 1319
1324 /* If we already have a callback attached, we can't move it! */ 1320 /* If we already have a callback attached, we can't move it! */
1325 for (i = 0; i < lm->monitors; i++) { 1321 for (i = 0; i < lm->monitors; i++) {
1326 if (bridge->lm_callback[i] != NULL) { 1322 if (bridge->lm_callback[i]) {
1327 mutex_unlock(&lm->mtx); 1323 mutex_unlock(&lm->mtx);
1328 dev_err(dev, "Location monitor callback attached, " 1324 dev_err(dev, "Location monitor callback attached, "
1329 "can't reset\n"); 1325 "can't reset\n");
@@ -1432,7 +1428,7 @@ static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor,
1432 } 1428 }
1433 1429
1434 /* Check that a callback isn't already attached */ 1430 /* Check that a callback isn't already attached */
1435 if (bridge->lm_callback[monitor] != NULL) { 1431 if (bridge->lm_callback[monitor]) {
1436 mutex_unlock(&lm->mtx); 1432 mutex_unlock(&lm->mtx);
1437 dev_err(dev, "Existing callback attached\n"); 1433 dev_err(dev, "Existing callback attached\n");
1438 return -EBUSY; 1434 return -EBUSY;
@@ -1567,7 +1563,7 @@ static int ca91cx42_crcsr_init(struct vme_bridge *ca91cx42_bridge,
1567 /* Allocate mem for CR/CSR image */ 1563 /* Allocate mem for CR/CSR image */
1568 bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, 1564 bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
1569 &bridge->crcsr_bus); 1565 &bridge->crcsr_bus);
1570 if (bridge->crcsr_kernel == NULL) { 1566 if (!bridge->crcsr_kernel) {
1571 dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR " 1567 dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR "
1572 "image\n"); 1568 "image\n");
1573 return -ENOMEM; 1569 return -ENOMEM;
@@ -1618,21 +1614,15 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1618 /* We want to support more than one of each bridge so we need to 1614 /* We want to support more than one of each bridge so we need to
1619 * dynamically allocate the bridge structure 1615 * dynamically allocate the bridge structure
1620 */ 1616 */
1621 ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); 1617 ca91cx42_bridge = kzalloc(sizeof(*ca91cx42_bridge), GFP_KERNEL);
1622 1618 if (!ca91cx42_bridge) {
1623 if (ca91cx42_bridge == NULL) {
1624 dev_err(&pdev->dev, "Failed to allocate memory for device "
1625 "structure\n");
1626 retval = -ENOMEM; 1619 retval = -ENOMEM;
1627 goto err_struct; 1620 goto err_struct;
1628 } 1621 }
1629 vme_init_bridge(ca91cx42_bridge); 1622 vme_init_bridge(ca91cx42_bridge);
1630 1623
1631 ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); 1624 ca91cx42_device = kzalloc(sizeof(*ca91cx42_device), GFP_KERNEL);
1632 1625 if (!ca91cx42_device) {
1633 if (ca91cx42_device == NULL) {
1634 dev_err(&pdev->dev, "Failed to allocate memory for device "
1635 "structure\n");
1636 retval = -ENOMEM; 1626 retval = -ENOMEM;
1637 goto err_driver; 1627 goto err_driver;
1638 } 1628 }
@@ -1688,11 +1678,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1688 1678
1689 /* Add master windows to list */ 1679 /* Add master windows to list */
1690 for (i = 0; i < CA91C142_MAX_MASTER; i++) { 1680 for (i = 0; i < CA91C142_MAX_MASTER; i++) {
1691 master_image = kmalloc(sizeof(struct vme_master_resource), 1681 master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
1692 GFP_KERNEL); 1682 if (!master_image) {
1693 if (master_image == NULL) {
1694 dev_err(&pdev->dev, "Failed to allocate memory for "
1695 "master resource structure\n");
1696 retval = -ENOMEM; 1683 retval = -ENOMEM;
1697 goto err_master; 1684 goto err_master;
1698 } 1685 }
@@ -1706,7 +1693,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1706 VME_SUPER | VME_USER | VME_PROG | VME_DATA; 1693 VME_SUPER | VME_USER | VME_PROG | VME_DATA;
1707 master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64; 1694 master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64;
1708 memset(&master_image->bus_resource, 0, 1695 memset(&master_image->bus_resource, 0,
1709 sizeof(struct resource)); 1696 sizeof(master_image->bus_resource));
1710 master_image->kern_base = NULL; 1697 master_image->kern_base = NULL;
1711 list_add_tail(&master_image->list, 1698 list_add_tail(&master_image->list,
1712 &ca91cx42_bridge->master_resources); 1699 &ca91cx42_bridge->master_resources);
@@ -1714,11 +1701,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1714 1701
1715 /* Add slave windows to list */ 1702 /* Add slave windows to list */
1716 for (i = 0; i < CA91C142_MAX_SLAVE; i++) { 1703 for (i = 0; i < CA91C142_MAX_SLAVE; i++) {
1717 slave_image = kmalloc(sizeof(struct vme_slave_resource), 1704 slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
1718 GFP_KERNEL); 1705 if (!slave_image) {
1719 if (slave_image == NULL) {
1720 dev_err(&pdev->dev, "Failed to allocate memory for "
1721 "slave resource structure\n");
1722 retval = -ENOMEM; 1706 retval = -ENOMEM;
1723 goto err_slave; 1707 goto err_slave;
1724 } 1708 }
@@ -1741,11 +1725,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1741 1725
1742 /* Add dma engines to list */ 1726 /* Add dma engines to list */
1743 for (i = 0; i < CA91C142_MAX_DMA; i++) { 1727 for (i = 0; i < CA91C142_MAX_DMA; i++) {
1744 dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), 1728 dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL);
1745 GFP_KERNEL); 1729 if (!dma_ctrlr) {
1746 if (dma_ctrlr == NULL) {
1747 dev_err(&pdev->dev, "Failed to allocate memory for "
1748 "dma resource structure\n");
1749 retval = -ENOMEM; 1730 retval = -ENOMEM;
1750 goto err_dma; 1731 goto err_dma;
1751 } 1732 }
@@ -1762,10 +1743,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1762 } 1743 }
1763 1744
1764 /* Add location monitor to list */ 1745 /* Add location monitor to list */
1765 lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); 1746 lm = kmalloc(sizeof(*lm), GFP_KERNEL);
1766 if (lm == NULL) { 1747 if (!lm) {
1767 dev_err(&pdev->dev, "Failed to allocate memory for "
1768 "location monitor resource structure\n");
1769 retval = -ENOMEM; 1748 retval = -ENOMEM;
1770 goto err_lm; 1749 goto err_lm;
1771 } 1750 }
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,
409 /* Each location monitor covers 8 bytes */ 409 /* Each location monitor covers 8 bytes */
410 if (((lm_base + (8 * i)) <= addr) && 410 if (((lm_base + (8 * i)) <= addr) &&
411 ((lm_base + (8 * i) + 8) > addr)) { 411 ((lm_base + (8 * i) + 8) > addr)) {
412 if (bridge->lm_callback[i] != NULL) 412 if (bridge->lm_callback[i])
413 bridge->lm_callback[i]( 413 bridge->lm_callback[i](
414 bridge->lm_data[i]); 414 bridge->lm_data[i]);
415 } 415 }
@@ -866,7 +866,7 @@ static int fake_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base,
866 866
867 /* If we already have a callback attached, we can't move it! */ 867 /* If we already have a callback attached, we can't move it! */
868 for (i = 0; i < lm->monitors; i++) { 868 for (i = 0; i < lm->monitors; i++) {
869 if (bridge->lm_callback[i] != NULL) { 869 if (bridge->lm_callback[i]) {
870 mutex_unlock(&lm->mtx); 870 mutex_unlock(&lm->mtx);
871 pr_err("Location monitor callback attached, can't reset\n"); 871 pr_err("Location monitor callback attached, can't reset\n");
872 return -EBUSY; 872 return -EBUSY;
@@ -940,7 +940,7 @@ static int fake_lm_attach(struct vme_lm_resource *lm, int monitor,
940 } 940 }
941 941
942 /* Check that a callback isn't already attached */ 942 /* Check that a callback isn't already attached */
943 if (bridge->lm_callback[monitor] != NULL) { 943 if (bridge->lm_callback[monitor]) {
944 mutex_unlock(&lm->mtx); 944 mutex_unlock(&lm->mtx);
945 pr_err("Existing callback attached\n"); 945 pr_err("Existing callback attached\n");
946 return -EBUSY; 946 return -EBUSY;
@@ -978,7 +978,7 @@ static int fake_lm_detach(struct vme_lm_resource *lm, int monitor)
978 /* If all location monitors disabled, disable global Location Monitor */ 978 /* If all location monitors disabled, disable global Location Monitor */
979 tmp = 0; 979 tmp = 0;
980 for (i = 0; i < lm->monitors; i++) { 980 for (i = 0; i < lm->monitors; i++) {
981 if (bridge->lm_callback[i] != NULL) 981 if (bridge->lm_callback[i])
982 tmp = 1; 982 tmp = 1;
983 } 983 }
984 984
@@ -1003,7 +1003,7 @@ static void *fake_alloc_consistent(struct device *parent, size_t size,
1003{ 1003{
1004 void *alloc = kmalloc(size, GFP_KERNEL); 1004 void *alloc = kmalloc(size, GFP_KERNEL);
1005 1005
1006 if (alloc != NULL) 1006 if (alloc)
1007 *dma = fake_ptr_to_pci(alloc); 1007 *dma = fake_ptr_to_pci(alloc);
1008 1008
1009 return alloc; 1009 return alloc;
@@ -1039,7 +1039,7 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge)
1039 /* Allocate mem for CR/CSR image */ 1039 /* Allocate mem for CR/CSR image */
1040 bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL); 1040 bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL);
1041 bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel); 1041 bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
1042 if (bridge->crcsr_kernel == NULL) 1042 if (!bridge->crcsr_kernel)
1043 return -ENOMEM; 1043 return -ENOMEM;
1044 1044
1045 vstat = fake_slot_get(fake_bridge); 1045 vstat = fake_slot_get(fake_bridge);
@@ -1075,14 +1075,14 @@ static int __init fake_init(void)
1075 /* If we want to support more than one bridge at some point, we need to 1075 /* If we want to support more than one bridge at some point, we need to
1076 * dynamically allocate this so we get one per device. 1076 * dynamically allocate this so we get one per device.
1077 */ 1077 */
1078 fake_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); 1078 fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL);
1079 if (fake_bridge == NULL) { 1079 if (!fake_bridge) {
1080 retval = -ENOMEM; 1080 retval = -ENOMEM;
1081 goto err_struct; 1081 goto err_struct;
1082 } 1082 }
1083 1083
1084 fake_device = kzalloc(sizeof(struct fake_driver), GFP_KERNEL); 1084 fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL);
1085 if (fake_device == NULL) { 1085 if (!fake_device) {
1086 retval = -ENOMEM; 1086 retval = -ENOMEM;
1087 goto err_driver; 1087 goto err_driver;
1088 } 1088 }
@@ -1104,9 +1104,8 @@ static int __init fake_init(void)
1104 /* Add master windows to list */ 1104 /* Add master windows to list */
1105 INIT_LIST_HEAD(&fake_bridge->master_resources); 1105 INIT_LIST_HEAD(&fake_bridge->master_resources);
1106 for (i = 0; i < FAKE_MAX_MASTER; i++) { 1106 for (i = 0; i < FAKE_MAX_MASTER; i++) {
1107 master_image = kmalloc(sizeof(struct vme_master_resource), 1107 master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
1108 GFP_KERNEL); 1108 if (!master_image) {
1109 if (master_image == NULL) {
1110 retval = -ENOMEM; 1109 retval = -ENOMEM;
1111 goto err_master; 1110 goto err_master;
1112 } 1111 }
@@ -1131,9 +1130,8 @@ static int __init fake_init(void)
1131 /* Add slave windows to list */ 1130 /* Add slave windows to list */
1132 INIT_LIST_HEAD(&fake_bridge->slave_resources); 1131 INIT_LIST_HEAD(&fake_bridge->slave_resources);
1133 for (i = 0; i < FAKE_MAX_SLAVE; i++) { 1132 for (i = 0; i < FAKE_MAX_SLAVE; i++) {
1134 slave_image = kmalloc(sizeof(struct vme_slave_resource), 1133 slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
1135 GFP_KERNEL); 1134 if (!slave_image) {
1136 if (slave_image == NULL) {
1137 retval = -ENOMEM; 1135 retval = -ENOMEM;
1138 goto err_slave; 1136 goto err_slave;
1139 } 1137 }
@@ -1154,9 +1152,8 @@ static int __init fake_init(void)
1154 1152
1155 /* Add location monitor to list */ 1153 /* Add location monitor to list */
1156 INIT_LIST_HEAD(&fake_bridge->lm_resources); 1154 INIT_LIST_HEAD(&fake_bridge->lm_resources);
1157 lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); 1155 lm = kmalloc(sizeof(*lm), GFP_KERNEL);
1158 if (lm == NULL) { 1156 if (!lm) {
1159 pr_err("Failed to allocate memory for location monitor resource structure\n");
1160 retval = -ENOMEM; 1157 retval = -ENOMEM;
1161 goto err_lm; 1158 goto err_lm;
1162 } 1159 }
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,
741 image->kern_base = NULL; 741 image->kern_base = NULL;
742 kfree(image->bus_resource.name); 742 kfree(image->bus_resource.name);
743 release_resource(&image->bus_resource); 743 release_resource(&image->bus_resource);
744 memset(&image->bus_resource, 0, sizeof(struct resource)); 744 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
745 } 745 }
746 746
747 /* Exit here if size is zero */ 747 /* Exit here if size is zero */
748 if (size == 0) 748 if (size == 0)
749 return 0; 749 return 0;
750 750
751 if (image->bus_resource.name == NULL) { 751 if (!image->bus_resource.name) {
752 image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC); 752 image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
753 if (image->bus_resource.name == NULL) { 753 if (!image->bus_resource.name) {
754 dev_err(tsi148_bridge->parent, "Unable to allocate "
755 "memory for resource name\n");
756 retval = -ENOMEM; 754 retval = -ENOMEM;
757 goto err_name; 755 goto err_name;
758 } 756 }
@@ -778,7 +776,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
778 776
779 image->kern_base = ioremap_nocache( 777 image->kern_base = ioremap_nocache(
780 image->bus_resource.start, size); 778 image->bus_resource.start, size);
781 if (image->kern_base == NULL) { 779 if (!image->kern_base) {
782 dev_err(tsi148_bridge->parent, "Failed to remap resource\n"); 780 dev_err(tsi148_bridge->parent, "Failed to remap resource\n");
783 retval = -ENOMEM; 781 retval = -ENOMEM;
784 goto err_remap; 782 goto err_remap;
@@ -790,7 +788,7 @@ err_remap:
790 release_resource(&image->bus_resource); 788 release_resource(&image->bus_resource);
791err_resource: 789err_resource:
792 kfree(image->bus_resource.name); 790 kfree(image->bus_resource.name);
793 memset(&image->bus_resource, 0, sizeof(struct resource)); 791 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
794err_name: 792err_name:
795 return retval; 793 return retval;
796} 794}
@@ -804,7 +802,7 @@ static void tsi148_free_resource(struct vme_master_resource *image)
804 image->kern_base = NULL; 802 image->kern_base = NULL;
805 release_resource(&image->bus_resource); 803 release_resource(&image->bus_resource);
806 kfree(image->bus_resource.name); 804 kfree(image->bus_resource.name);
807 memset(&image->bus_resource, 0, sizeof(struct resource)); 805 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
808} 806}
809 807
810/* 808/*
@@ -1641,10 +1639,8 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
1641 tsi148_bridge = list->parent->parent; 1639 tsi148_bridge = list->parent->parent;
1642 1640
1643 /* Descriptor must be aligned on 64-bit boundaries */ 1641 /* Descriptor must be aligned on 64-bit boundaries */
1644 entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL); 1642 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
1645 if (entry == NULL) { 1643 if (!entry) {
1646 dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
1647 "dma resource structure\n");
1648 retval = -ENOMEM; 1644 retval = -ENOMEM;
1649 goto err_mem; 1645 goto err_mem;
1650 } 1646 }
@@ -1661,7 +1657,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
1661 /* Given we are going to fill out the structure, we probably don't 1657 /* Given we are going to fill out the structure, we probably don't
1662 * need to zero it, but better safe than sorry for now. 1658 * need to zero it, but better safe than sorry for now.
1663 */ 1659 */
1664 memset(&entry->descriptor, 0, sizeof(struct tsi148_dma_descriptor)); 1660 memset(&entry->descriptor, 0, sizeof(entry->descriptor));
1665 1661
1666 /* Fill out source part */ 1662 /* Fill out source part */
1667 switch (src->type) { 1663 switch (src->type) {
@@ -1756,8 +1752,9 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
1756 list_add_tail(&entry->list, &list->entries); 1752 list_add_tail(&entry->list, &list->entries);
1757 1753
1758 entry->dma_handle = dma_map_single(tsi148_bridge->parent, 1754 entry->dma_handle = dma_map_single(tsi148_bridge->parent,
1759 &entry->descriptor, 1755 &entry->descriptor,
1760 sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); 1756 sizeof(entry->descriptor),
1757 DMA_TO_DEVICE);
1761 if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) { 1758 if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) {
1762 dev_err(tsi148_bridge->parent, "DMA mapping error\n"); 1759 dev_err(tsi148_bridge->parent, "DMA mapping error\n");
1763 retval = -EINVAL; 1760 retval = -EINVAL;
@@ -1946,7 +1943,7 @@ static int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base,
1946 1943
1947 /* If we already have a callback attached, we can't move it! */ 1944 /* If we already have a callback attached, we can't move it! */
1948 for (i = 0; i < lm->monitors; i++) { 1945 for (i = 0; i < lm->monitors; i++) {
1949 if (bridge->lm_callback[i] != NULL) { 1946 if (bridge->lm_callback[i]) {
1950 mutex_unlock(&lm->mtx); 1947 mutex_unlock(&lm->mtx);
1951 dev_err(tsi148_bridge->parent, "Location monitor " 1948 dev_err(tsi148_bridge->parent, "Location monitor "
1952 "callback attached, can't reset\n"); 1949 "callback attached, can't reset\n");
@@ -2071,7 +2068,7 @@ static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor,
2071 } 2068 }
2072 2069
2073 /* Check that a callback isn't already attached */ 2070 /* Check that a callback isn't already attached */
2074 if (bridge->lm_callback[monitor] != NULL) { 2071 if (bridge->lm_callback[monitor]) {
2075 mutex_unlock(&lm->mtx); 2072 mutex_unlock(&lm->mtx);
2076 dev_err(tsi148_bridge->parent, "Existing callback attached\n"); 2073 dev_err(tsi148_bridge->parent, "Existing callback attached\n");
2077 return -EBUSY; 2074 return -EBUSY;
@@ -2208,7 +2205,7 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge,
2208 /* Allocate mem for CR/CSR image */ 2205 /* Allocate mem for CR/CSR image */
2209 bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, 2206 bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
2210 &bridge->crcsr_bus); 2207 &bridge->crcsr_bus);
2211 if (bridge->crcsr_kernel == NULL) { 2208 if (!bridge->crcsr_kernel) {
2212 dev_err(tsi148_bridge->parent, "Failed to allocate memory for " 2209 dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
2213 "CR/CSR image\n"); 2210 "CR/CSR image\n");
2214 return -ENOMEM; 2211 return -ENOMEM;
@@ -2294,19 +2291,15 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2294 /* If we want to support more than one of each bridge, we need to 2291 /* If we want to support more than one of each bridge, we need to
2295 * dynamically generate this so we get one per device 2292 * dynamically generate this so we get one per device
2296 */ 2293 */
2297 tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); 2294 tsi148_bridge = kzalloc(sizeof(*tsi148_bridge), GFP_KERNEL);
2298 if (tsi148_bridge == NULL) { 2295 if (!tsi148_bridge) {
2299 dev_err(&pdev->dev, "Failed to allocate memory for device "
2300 "structure\n");
2301 retval = -ENOMEM; 2296 retval = -ENOMEM;
2302 goto err_struct; 2297 goto err_struct;
2303 } 2298 }
2304 vme_init_bridge(tsi148_bridge); 2299 vme_init_bridge(tsi148_bridge);
2305 2300
2306 tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL); 2301 tsi148_device = kzalloc(sizeof(*tsi148_device), GFP_KERNEL);
2307 if (tsi148_device == NULL) { 2302 if (!tsi148_device) {
2308 dev_err(&pdev->dev, "Failed to allocate memory for device "
2309 "structure\n");
2310 retval = -ENOMEM; 2303 retval = -ENOMEM;
2311 goto err_driver; 2304 goto err_driver;
2312 } 2305 }
@@ -2371,10 +2364,9 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2371 master_num--; 2364 master_num--;
2372 2365
2373 tsi148_device->flush_image = 2366 tsi148_device->flush_image =
2374 kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL); 2367 kmalloc(sizeof(*tsi148_device->flush_image),
2375 if (tsi148_device->flush_image == NULL) { 2368 GFP_KERNEL);
2376 dev_err(&pdev->dev, "Failed to allocate memory for " 2369 if (!tsi148_device->flush_image) {
2377 "flush resource structure\n");
2378 retval = -ENOMEM; 2370 retval = -ENOMEM;
2379 goto err_master; 2371 goto err_master;
2380 } 2372 }
@@ -2383,17 +2375,14 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2383 tsi148_device->flush_image->locked = 1; 2375 tsi148_device->flush_image->locked = 1;
2384 tsi148_device->flush_image->number = master_num; 2376 tsi148_device->flush_image->number = master_num;
2385 memset(&tsi148_device->flush_image->bus_resource, 0, 2377 memset(&tsi148_device->flush_image->bus_resource, 0,
2386 sizeof(struct resource)); 2378 sizeof(tsi148_device->flush_image->bus_resource));
2387 tsi148_device->flush_image->kern_base = NULL; 2379 tsi148_device->flush_image->kern_base = NULL;
2388 } 2380 }
2389 2381
2390 /* Add master windows to list */ 2382 /* Add master windows to list */
2391 for (i = 0; i < master_num; i++) { 2383 for (i = 0; i < master_num; i++) {
2392 master_image = kmalloc(sizeof(struct vme_master_resource), 2384 master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
2393 GFP_KERNEL); 2385 if (!master_image) {
2394 if (master_image == NULL) {
2395 dev_err(&pdev->dev, "Failed to allocate memory for "
2396 "master resource structure\n");
2397 retval = -ENOMEM; 2386 retval = -ENOMEM;
2398 goto err_master; 2387 goto err_master;
2399 } 2388 }
@@ -2410,7 +2399,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2410 VME_PROG | VME_DATA; 2399 VME_PROG | VME_DATA;
2411 master_image->width_attr = VME_D16 | VME_D32; 2400 master_image->width_attr = VME_D16 | VME_D32;
2412 memset(&master_image->bus_resource, 0, 2401 memset(&master_image->bus_resource, 0,
2413 sizeof(struct resource)); 2402 sizeof(master_image->bus_resource));
2414 master_image->kern_base = NULL; 2403 master_image->kern_base = NULL;
2415 list_add_tail(&master_image->list, 2404 list_add_tail(&master_image->list,
2416 &tsi148_bridge->master_resources); 2405 &tsi148_bridge->master_resources);
@@ -2418,11 +2407,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2418 2407
2419 /* Add slave windows to list */ 2408 /* Add slave windows to list */
2420 for (i = 0; i < TSI148_MAX_SLAVE; i++) { 2409 for (i = 0; i < TSI148_MAX_SLAVE; i++) {
2421 slave_image = kmalloc(sizeof(struct vme_slave_resource), 2410 slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
2422 GFP_KERNEL); 2411 if (!slave_image) {
2423 if (slave_image == NULL) {
2424 dev_err(&pdev->dev, "Failed to allocate memory for "
2425 "slave resource structure\n");
2426 retval = -ENOMEM; 2412 retval = -ENOMEM;
2427 goto err_slave; 2413 goto err_slave;
2428 } 2414 }
@@ -2442,11 +2428,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2442 2428
2443 /* Add dma engines to list */ 2429 /* Add dma engines to list */
2444 for (i = 0; i < TSI148_MAX_DMA; i++) { 2430 for (i = 0; i < TSI148_MAX_DMA; i++) {
2445 dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), 2431 dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL);
2446 GFP_KERNEL); 2432 if (!dma_ctrlr) {
2447 if (dma_ctrlr == NULL) {
2448 dev_err(&pdev->dev, "Failed to allocate memory for "
2449 "dma resource structure\n");
2450 retval = -ENOMEM; 2433 retval = -ENOMEM;
2451 goto err_dma; 2434 goto err_dma;
2452 } 2435 }
@@ -2465,10 +2448,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2465 } 2448 }
2466 2449
2467 /* Add location monitor to list */ 2450 /* Add location monitor to list */
2468 lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); 2451 lm = kmalloc(sizeof(*lm), GFP_KERNEL);
2469 if (lm == NULL) { 2452 if (!lm) {
2470 dev_err(&pdev->dev, "Failed to allocate memory for "
2471 "location monitor resource structure\n");
2472 retval = -ENOMEM; 2453 retval = -ENOMEM;
2473 goto err_lm; 2454 goto err_lm;
2474 } 2455 }
diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 5b4c898d7509..d0ce50d56019 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -92,23 +92,23 @@ void *vme_alloc_consistent(struct vme_resource *resource, size_t size,
92{ 92{
93 struct vme_bridge *bridge; 93 struct vme_bridge *bridge;
94 94
95 if (resource == NULL) { 95 if (!resource) {
96 printk(KERN_ERR "No resource\n"); 96 printk(KERN_ERR "No resource\n");
97 return NULL; 97 return NULL;
98 } 98 }
99 99
100 bridge = find_bridge(resource); 100 bridge = find_bridge(resource);
101 if (bridge == NULL) { 101 if (!bridge) {
102 printk(KERN_ERR "Can't find bridge\n"); 102 printk(KERN_ERR "Can't find bridge\n");
103 return NULL; 103 return NULL;
104 } 104 }
105 105
106 if (bridge->parent == NULL) { 106 if (!bridge->parent) {
107 printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name); 107 printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
108 return NULL; 108 return NULL;
109 } 109 }
110 110
111 if (bridge->alloc_consistent == NULL) { 111 if (!bridge->alloc_consistent) {
112 printk(KERN_ERR "alloc_consistent not supported by bridge %s\n", 112 printk(KERN_ERR "alloc_consistent not supported by bridge %s\n",
113 bridge->name); 113 bridge->name);
114 return NULL; 114 return NULL;
@@ -132,23 +132,23 @@ void vme_free_consistent(struct vme_resource *resource, size_t size,
132{ 132{
133 struct vme_bridge *bridge; 133 struct vme_bridge *bridge;
134 134
135 if (resource == NULL) { 135 if (!resource) {
136 printk(KERN_ERR "No resource\n"); 136 printk(KERN_ERR "No resource\n");
137 return; 137 return;
138 } 138 }
139 139
140 bridge = find_bridge(resource); 140 bridge = find_bridge(resource);
141 if (bridge == NULL) { 141 if (!bridge) {
142 printk(KERN_ERR "Can't find bridge\n"); 142 printk(KERN_ERR "Can't find bridge\n");
143 return; 143 return;
144 } 144 }
145 145
146 if (bridge->parent == NULL) { 146 if (!bridge->parent) {
147 printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name); 147 printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
148 return; 148 return;
149 } 149 }
150 150
151 if (bridge->free_consistent == NULL) { 151 if (!bridge->free_consistent) {
152 printk(KERN_ERR "free_consistent not supported by bridge %s\n", 152 printk(KERN_ERR "free_consistent not supported by bridge %s\n",
153 bridge->name); 153 bridge->name);
154 return; 154 return;
@@ -301,7 +301,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
301 struct vme_resource *resource = NULL; 301 struct vme_resource *resource = NULL;
302 302
303 bridge = vdev->bridge; 303 bridge = vdev->bridge;
304 if (bridge == NULL) { 304 if (!bridge) {
305 printk(KERN_ERR "Can't find VME bus\n"); 305 printk(KERN_ERR "Can't find VME bus\n");
306 goto err_bus; 306 goto err_bus;
307 } 307 }
@@ -311,7 +311,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
311 slave_image = list_entry(slave_pos, 311 slave_image = list_entry(slave_pos,
312 struct vme_slave_resource, list); 312 struct vme_slave_resource, list);
313 313
314 if (slave_image == NULL) { 314 if (!slave_image) {
315 printk(KERN_ERR "Registered NULL Slave resource\n"); 315 printk(KERN_ERR "Registered NULL Slave resource\n");
316 continue; 316 continue;
317 } 317 }
@@ -331,14 +331,13 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
331 } 331 }
332 332
333 /* No free image */ 333 /* No free image */
334 if (allocated_image == NULL) 334 if (!allocated_image)
335 goto err_image; 335 goto err_image;
336 336
337 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 337 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
338 if (resource == NULL) { 338 if (!resource)
339 printk(KERN_WARNING "Unable to allocate resource structure\n");
340 goto err_alloc; 339 goto err_alloc;
341 } 340
342 resource->type = VME_SLAVE; 341 resource->type = VME_SLAVE;
343 resource->entry = &allocated_image->list; 342 resource->entry = &allocated_image->list;
344 343
@@ -387,7 +386,7 @@ int vme_slave_set(struct vme_resource *resource, int enabled,
387 386
388 image = list_entry(resource->entry, struct vme_slave_resource, list); 387 image = list_entry(resource->entry, struct vme_slave_resource, list);
389 388
390 if (bridge->slave_set == NULL) { 389 if (!bridge->slave_set) {
391 printk(KERN_ERR "Function not supported\n"); 390 printk(KERN_ERR "Function not supported\n");
392 return -ENOSYS; 391 return -ENOSYS;
393 } 392 }
@@ -436,7 +435,7 @@ int vme_slave_get(struct vme_resource *resource, int *enabled,
436 435
437 image = list_entry(resource->entry, struct vme_slave_resource, list); 436 image = list_entry(resource->entry, struct vme_slave_resource, list);
438 437
439 if (bridge->slave_get == NULL) { 438 if (!bridge->slave_get) {
440 printk(KERN_ERR "vme_slave_get not supported\n"); 439 printk(KERN_ERR "vme_slave_get not supported\n");
441 return -EINVAL; 440 return -EINVAL;
442 } 441 }
@@ -463,7 +462,7 @@ void vme_slave_free(struct vme_resource *resource)
463 462
464 slave_image = list_entry(resource->entry, struct vme_slave_resource, 463 slave_image = list_entry(resource->entry, struct vme_slave_resource,
465 list); 464 list);
466 if (slave_image == NULL) { 465 if (!slave_image) {
467 printk(KERN_ERR "Can't find slave resource\n"); 466 printk(KERN_ERR "Can't find slave resource\n");
468 return; 467 return;
469 } 468 }
@@ -503,7 +502,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
503 struct vme_resource *resource = NULL; 502 struct vme_resource *resource = NULL;
504 503
505 bridge = vdev->bridge; 504 bridge = vdev->bridge;
506 if (bridge == NULL) { 505 if (!bridge) {
507 printk(KERN_ERR "Can't find VME bus\n"); 506 printk(KERN_ERR "Can't find VME bus\n");
508 goto err_bus; 507 goto err_bus;
509 } 508 }
@@ -513,7 +512,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
513 master_image = list_entry(master_pos, 512 master_image = list_entry(master_pos,
514 struct vme_master_resource, list); 513 struct vme_master_resource, list);
515 514
516 if (master_image == NULL) { 515 if (!master_image) {
517 printk(KERN_WARNING "Registered NULL master resource\n"); 516 printk(KERN_WARNING "Registered NULL master resource\n");
518 continue; 517 continue;
519 } 518 }
@@ -534,16 +533,15 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
534 } 533 }
535 534
536 /* Check to see if we found a resource */ 535 /* Check to see if we found a resource */
537 if (allocated_image == NULL) { 536 if (!allocated_image) {
538 printk(KERN_ERR "Can't find a suitable resource\n"); 537 printk(KERN_ERR "Can't find a suitable resource\n");
539 goto err_image; 538 goto err_image;
540 } 539 }
541 540
542 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 541 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
543 if (resource == NULL) { 542 if (!resource)
544 printk(KERN_ERR "Unable to allocate resource structure\n");
545 goto err_alloc; 543 goto err_alloc;
546 } 544
547 resource->type = VME_MASTER; 545 resource->type = VME_MASTER;
548 resource->entry = &allocated_image->list; 546 resource->entry = &allocated_image->list;
549 547
@@ -592,7 +590,7 @@ int vme_master_set(struct vme_resource *resource, int enabled,
592 590
593 image = list_entry(resource->entry, struct vme_master_resource, list); 591 image = list_entry(resource->entry, struct vme_master_resource, list);
594 592
595 if (bridge->master_set == NULL) { 593 if (!bridge->master_set) {
596 printk(KERN_WARNING "vme_master_set not supported\n"); 594 printk(KERN_WARNING "vme_master_set not supported\n");
597 return -EINVAL; 595 return -EINVAL;
598 } 596 }
@@ -642,7 +640,7 @@ int vme_master_get(struct vme_resource *resource, int *enabled,
642 640
643 image = list_entry(resource->entry, struct vme_master_resource, list); 641 image = list_entry(resource->entry, struct vme_master_resource, list);
644 642
645 if (bridge->master_get == NULL) { 643 if (!bridge->master_get) {
646 printk(KERN_WARNING "%s not supported\n", __func__); 644 printk(KERN_WARNING "%s not supported\n", __func__);
647 return -EINVAL; 645 return -EINVAL;
648 } 646 }
@@ -674,7 +672,7 @@ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,
674 struct vme_master_resource *image; 672 struct vme_master_resource *image;
675 size_t length; 673 size_t length;
676 674
677 if (bridge->master_read == NULL) { 675 if (!bridge->master_read) {
678 printk(KERN_WARNING "Reading from resource not supported\n"); 676 printk(KERN_WARNING "Reading from resource not supported\n");
679 return -EINVAL; 677 return -EINVAL;
680 } 678 }
@@ -723,7 +721,7 @@ ssize_t vme_master_write(struct vme_resource *resource, void *buf,
723 struct vme_master_resource *image; 721 struct vme_master_resource *image;
724 size_t length; 722 size_t length;
725 723
726 if (bridge->master_write == NULL) { 724 if (!bridge->master_write) {
727 printk(KERN_WARNING "Writing to resource not supported\n"); 725 printk(KERN_WARNING "Writing to resource not supported\n");
728 return -EINVAL; 726 return -EINVAL;
729 } 727 }
@@ -774,7 +772,7 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,
774 struct vme_bridge *bridge = find_bridge(resource); 772 struct vme_bridge *bridge = find_bridge(resource);
775 struct vme_master_resource *image; 773 struct vme_master_resource *image;
776 774
777 if (bridge->master_rmw == NULL) { 775 if (!bridge->master_rmw) {
778 printk(KERN_WARNING "Writing to resource not supported\n"); 776 printk(KERN_WARNING "Writing to resource not supported\n");
779 return -EINVAL; 777 return -EINVAL;
780 } 778 }
@@ -844,7 +842,7 @@ void vme_master_free(struct vme_resource *resource)
844 842
845 master_image = list_entry(resource->entry, struct vme_master_resource, 843 master_image = list_entry(resource->entry, struct vme_master_resource,
846 list); 844 list);
847 if (master_image == NULL) { 845 if (!master_image) {
848 printk(KERN_ERR "Can't find master resource\n"); 846 printk(KERN_ERR "Can't find master resource\n");
849 return; 847 return;
850 } 848 }
@@ -884,7 +882,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
884 printk(KERN_ERR "No VME resource Attribute tests done\n"); 882 printk(KERN_ERR "No VME resource Attribute tests done\n");
885 883
886 bridge = vdev->bridge; 884 bridge = vdev->bridge;
887 if (bridge == NULL) { 885 if (!bridge) {
888 printk(KERN_ERR "Can't find VME bus\n"); 886 printk(KERN_ERR "Can't find VME bus\n");
889 goto err_bus; 887 goto err_bus;
890 } 888 }
@@ -893,8 +891,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
893 list_for_each(dma_pos, &bridge->dma_resources) { 891 list_for_each(dma_pos, &bridge->dma_resources) {
894 dma_ctrlr = list_entry(dma_pos, 892 dma_ctrlr = list_entry(dma_pos,
895 struct vme_dma_resource, list); 893 struct vme_dma_resource, list);
896 894 if (!dma_ctrlr) {
897 if (dma_ctrlr == NULL) {
898 printk(KERN_ERR "Registered NULL DMA resource\n"); 895 printk(KERN_ERR "Registered NULL DMA resource\n");
899 continue; 896 continue;
900 } 897 }
@@ -913,14 +910,13 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
913 } 910 }
914 911
915 /* Check to see if we found a resource */ 912 /* Check to see if we found a resource */
916 if (allocated_ctrlr == NULL) 913 if (!allocated_ctrlr)
917 goto err_ctrlr; 914 goto err_ctrlr;
918 915
919 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 916 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
920 if (resource == NULL) { 917 if (!resource)
921 printk(KERN_WARNING "Unable to allocate resource structure\n");
922 goto err_alloc; 918 goto err_alloc;
923 } 919
924 resource->type = VME_DMA; 920 resource->type = VME_DMA;
925 resource->entry = &allocated_ctrlr->list; 921 resource->entry = &allocated_ctrlr->list;
926 922
@@ -949,7 +945,6 @@ EXPORT_SYMBOL(vme_dma_request);
949 */ 945 */
950struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource) 946struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
951{ 947{
952 struct vme_dma_resource *ctrlr;
953 struct vme_dma_list *dma_list; 948 struct vme_dma_list *dma_list;
954 949
955 if (resource->type != VME_DMA) { 950 if (resource->type != VME_DMA) {
@@ -957,15 +952,14 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
957 return NULL; 952 return NULL;
958 } 953 }
959 954
960 ctrlr = list_entry(resource->entry, struct vme_dma_resource, list); 955 dma_list = kmalloc(sizeof(*dma_list), GFP_KERNEL);
961 956 if (!dma_list)
962 dma_list = kmalloc(sizeof(struct vme_dma_list), GFP_KERNEL);
963 if (dma_list == NULL) {
964 printk(KERN_ERR "Unable to allocate memory for new DMA list\n");
965 return NULL; 957 return NULL;
966 } 958
967 INIT_LIST_HEAD(&dma_list->entries); 959 INIT_LIST_HEAD(&dma_list->entries);
968 dma_list->parent = ctrlr; 960 dma_list->parent = list_entry(resource->entry,
961 struct vme_dma_resource,
962 list);
969 mutex_init(&dma_list->mtx); 963 mutex_init(&dma_list->mtx);
970 964
971 return dma_list; 965 return dma_list;
@@ -988,17 +982,13 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, u32 type)
988 struct vme_dma_attr *attributes; 982 struct vme_dma_attr *attributes;
989 struct vme_dma_pattern *pattern_attr; 983 struct vme_dma_pattern *pattern_attr;
990 984
991 attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL); 985 attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
992 if (attributes == NULL) { 986 if (!attributes)
993 printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
994 goto err_attr; 987 goto err_attr;
995 }
996 988
997 pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL); 989 pattern_attr = kmalloc(sizeof(*pattern_attr), GFP_KERNEL);
998 if (pattern_attr == NULL) { 990 if (!pattern_attr)
999 printk(KERN_ERR "Unable to allocate memory for pattern attributes\n");
1000 goto err_pat; 991 goto err_pat;
1001 }
1002 992
1003 attributes->type = VME_DMA_PATTERN; 993 attributes->type = VME_DMA_PATTERN;
1004 attributes->private = (void *)pattern_attr; 994 attributes->private = (void *)pattern_attr;
@@ -1032,19 +1022,13 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address)
1032 1022
1033 /* XXX Run some sanity checks here */ 1023 /* XXX Run some sanity checks here */
1034 1024
1035 attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL); 1025 attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
1036 if (attributes == NULL) { 1026 if (!attributes)
1037 printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
1038 goto err_attr; 1027 goto err_attr;
1039 }
1040 1028
1041 pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL); 1029 pci_attr = kmalloc(sizeof(*pci_attr), GFP_KERNEL);
1042 if (pci_attr == NULL) { 1030 if (!pci_attr)
1043 printk(KERN_ERR "Unable to allocate memory for PCI attributes\n");
1044 goto err_pci; 1031 goto err_pci;
1045 }
1046
1047
1048 1032
1049 attributes->type = VME_DMA_PCI; 1033 attributes->type = VME_DMA_PCI;
1050 attributes->private = (void *)pci_attr; 1034 attributes->private = (void *)pci_attr;
@@ -1079,18 +1063,13 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address,
1079 struct vme_dma_attr *attributes; 1063 struct vme_dma_attr *attributes;
1080 struct vme_dma_vme *vme_attr; 1064 struct vme_dma_vme *vme_attr;
1081 1065
1082 attributes = kmalloc( 1066 attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
1083 sizeof(struct vme_dma_attr), GFP_KERNEL); 1067 if (!attributes)
1084 if (attributes == NULL) {
1085 printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
1086 goto err_attr; 1068 goto err_attr;
1087 }
1088 1069
1089 vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL); 1070 vme_attr = kmalloc(sizeof(*vme_attr), GFP_KERNEL);
1090 if (vme_attr == NULL) { 1071 if (!vme_attr)
1091 printk(KERN_ERR "Unable to allocate memory for VME attributes\n");
1092 goto err_vme; 1072 goto err_vme;
1093 }
1094 1073
1095 attributes->type = VME_DMA_VME; 1074 attributes->type = VME_DMA_VME;
1096 attributes->private = (void *)vme_attr; 1075 attributes->private = (void *)vme_attr;
@@ -1146,7 +1125,7 @@ int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,
1146 struct vme_bridge *bridge = list->parent->parent; 1125 struct vme_bridge *bridge = list->parent->parent;
1147 int retval; 1126 int retval;
1148 1127
1149 if (bridge->dma_list_add == NULL) { 1128 if (!bridge->dma_list_add) {
1150 printk(KERN_WARNING "Link List DMA generation not supported\n"); 1129 printk(KERN_WARNING "Link List DMA generation not supported\n");
1151 return -EINVAL; 1130 return -EINVAL;
1152 } 1131 }
@@ -1179,7 +1158,7 @@ int vme_dma_list_exec(struct vme_dma_list *list)
1179 struct vme_bridge *bridge = list->parent->parent; 1158 struct vme_bridge *bridge = list->parent->parent;
1180 int retval; 1159 int retval;
1181 1160
1182 if (bridge->dma_list_exec == NULL) { 1161 if (!bridge->dma_list_exec) {
1183 printk(KERN_ERR "Link List DMA execution not supported\n"); 1162 printk(KERN_ERR "Link List DMA execution not supported\n");
1184 return -EINVAL; 1163 return -EINVAL;
1185 } 1164 }
@@ -1208,7 +1187,7 @@ int vme_dma_list_free(struct vme_dma_list *list)
1208 struct vme_bridge *bridge = list->parent->parent; 1187 struct vme_bridge *bridge = list->parent->parent;
1209 int retval; 1188 int retval;
1210 1189
1211 if (bridge->dma_list_empty == NULL) { 1190 if (!bridge->dma_list_empty) {
1212 printk(KERN_WARNING "Emptying of Link Lists not supported\n"); 1191 printk(KERN_WARNING "Emptying of Link Lists not supported\n");
1213 return -EINVAL; 1192 return -EINVAL;
1214 } 1193 }
@@ -1340,8 +1319,7 @@ void vme_irq_handler(struct vme_bridge *bridge, int level, int statid)
1340 1319
1341 call = bridge->irq[level - 1].callback[statid].func; 1320 call = bridge->irq[level - 1].callback[statid].func;
1342 priv_data = bridge->irq[level - 1].callback[statid].priv_data; 1321 priv_data = bridge->irq[level - 1].callback[statid].priv_data;
1343 1322 if (call)
1344 if (call != NULL)
1345 call(level, statid, priv_data); 1323 call(level, statid, priv_data);
1346 else 1324 else
1347 printk(KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n", 1325 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,
1372 struct vme_bridge *bridge; 1350 struct vme_bridge *bridge;
1373 1351
1374 bridge = vdev->bridge; 1352 bridge = vdev->bridge;
1375 if (bridge == NULL) { 1353 if (!bridge) {
1376 printk(KERN_ERR "Can't find VME bus\n"); 1354 printk(KERN_ERR "Can't find VME bus\n");
1377 return -EINVAL; 1355 return -EINVAL;
1378 } 1356 }
@@ -1382,7 +1360,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,
1382 return -EINVAL; 1360 return -EINVAL;
1383 } 1361 }
1384 1362
1385 if (bridge->irq_set == NULL) { 1363 if (!bridge->irq_set) {
1386 printk(KERN_ERR "Configuring interrupts not supported\n"); 1364 printk(KERN_ERR "Configuring interrupts not supported\n");
1387 return -EINVAL; 1365 return -EINVAL;
1388 } 1366 }
@@ -1421,7 +1399,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
1421 struct vme_bridge *bridge; 1399 struct vme_bridge *bridge;
1422 1400
1423 bridge = vdev->bridge; 1401 bridge = vdev->bridge;
1424 if (bridge == NULL) { 1402 if (!bridge) {
1425 printk(KERN_ERR "Can't find VME bus\n"); 1403 printk(KERN_ERR "Can't find VME bus\n");
1426 return; 1404 return;
1427 } 1405 }
@@ -1431,7 +1409,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
1431 return; 1409 return;
1432 } 1410 }
1433 1411
1434 if (bridge->irq_set == NULL) { 1412 if (!bridge->irq_set) {
1435 printk(KERN_ERR "Configuring interrupts not supported\n"); 1413 printk(KERN_ERR "Configuring interrupts not supported\n");
1436 return; 1414 return;
1437 } 1415 }
@@ -1468,7 +1446,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
1468 struct vme_bridge *bridge; 1446 struct vme_bridge *bridge;
1469 1447
1470 bridge = vdev->bridge; 1448 bridge = vdev->bridge;
1471 if (bridge == NULL) { 1449 if (!bridge) {
1472 printk(KERN_ERR "Can't find VME bus\n"); 1450 printk(KERN_ERR "Can't find VME bus\n");
1473 return -EINVAL; 1451 return -EINVAL;
1474 } 1452 }
@@ -1478,7 +1456,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
1478 return -EINVAL; 1456 return -EINVAL;
1479 } 1457 }
1480 1458
1481 if (bridge->irq_generate == NULL) { 1459 if (!bridge->irq_generate) {
1482 printk(KERN_WARNING "Interrupt generation not supported\n"); 1460 printk(KERN_WARNING "Interrupt generation not supported\n");
1483 return -EINVAL; 1461 return -EINVAL;
1484 } 1462 }
@@ -1506,7 +1484,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
1506 struct vme_resource *resource = NULL; 1484 struct vme_resource *resource = NULL;
1507 1485
1508 bridge = vdev->bridge; 1486 bridge = vdev->bridge;
1509 if (bridge == NULL) { 1487 if (!bridge) {
1510 printk(KERN_ERR "Can't find VME bus\n"); 1488 printk(KERN_ERR "Can't find VME bus\n");
1511 goto err_bus; 1489 goto err_bus;
1512 } 1490 }
@@ -1515,8 +1493,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
1515 list_for_each(lm_pos, &bridge->lm_resources) { 1493 list_for_each(lm_pos, &bridge->lm_resources) {
1516 lm = list_entry(lm_pos, 1494 lm = list_entry(lm_pos,
1517 struct vme_lm_resource, list); 1495 struct vme_lm_resource, list);
1518 1496 if (!lm) {
1519 if (lm == NULL) {
1520 printk(KERN_ERR "Registered NULL Location Monitor resource\n"); 1497 printk(KERN_ERR "Registered NULL Location Monitor resource\n");
1521 continue; 1498 continue;
1522 } 1499 }
@@ -1533,14 +1510,13 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
1533 } 1510 }
1534 1511
1535 /* Check to see if we found a resource */ 1512 /* Check to see if we found a resource */
1536 if (allocated_lm == NULL) 1513 if (!allocated_lm)
1537 goto err_lm; 1514 goto err_lm;
1538 1515
1539 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 1516 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
1540 if (resource == NULL) { 1517 if (!resource)
1541 printk(KERN_ERR "Unable to allocate resource structure\n");
1542 goto err_alloc; 1518 goto err_alloc;
1543 } 1519
1544 resource->type = VME_LM; 1520 resource->type = VME_LM;
1545 resource->entry = &allocated_lm->list; 1521 resource->entry = &allocated_lm->list;
1546 1522
@@ -1610,7 +1586,7 @@ int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base,
1610 1586
1611 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1587 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1612 1588
1613 if (bridge->lm_set == NULL) { 1589 if (!bridge->lm_set) {
1614 printk(KERN_ERR "vme_lm_set not supported\n"); 1590 printk(KERN_ERR "vme_lm_set not supported\n");
1615 return -EINVAL; 1591 return -EINVAL;
1616 } 1592 }
@@ -1646,7 +1622,7 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,
1646 1622
1647 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1623 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1648 1624
1649 if (bridge->lm_get == NULL) { 1625 if (!bridge->lm_get) {
1650 printk(KERN_ERR "vme_lm_get not supported\n"); 1626 printk(KERN_ERR "vme_lm_get not supported\n");
1651 return -EINVAL; 1627 return -EINVAL;
1652 } 1628 }
@@ -1683,7 +1659,7 @@ int vme_lm_attach(struct vme_resource *resource, int monitor,
1683 1659
1684 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1660 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1685 1661
1686 if (bridge->lm_attach == NULL) { 1662 if (!bridge->lm_attach) {
1687 printk(KERN_ERR "vme_lm_attach not supported\n"); 1663 printk(KERN_ERR "vme_lm_attach not supported\n");
1688 return -EINVAL; 1664 return -EINVAL;
1689 } 1665 }
@@ -1716,7 +1692,7 @@ int vme_lm_detach(struct vme_resource *resource, int monitor)
1716 1692
1717 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1693 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1718 1694
1719 if (bridge->lm_detach == NULL) { 1695 if (!bridge->lm_detach) {
1720 printk(KERN_ERR "vme_lm_detach not supported\n"); 1696 printk(KERN_ERR "vme_lm_detach not supported\n");
1721 return -EINVAL; 1697 return -EINVAL;
1722 } 1698 }
@@ -1778,12 +1754,12 @@ int vme_slot_num(struct vme_dev *vdev)
1778 struct vme_bridge *bridge; 1754 struct vme_bridge *bridge;
1779 1755
1780 bridge = vdev->bridge; 1756 bridge = vdev->bridge;
1781 if (bridge == NULL) { 1757 if (!bridge) {
1782 printk(KERN_ERR "Can't find VME bus\n"); 1758 printk(KERN_ERR "Can't find VME bus\n");
1783 return -EINVAL; 1759 return -EINVAL;
1784 } 1760 }
1785 1761
1786 if (bridge->slot_get == NULL) { 1762 if (!bridge->slot_get) {
1787 printk(KERN_WARNING "vme_slot_num not supported\n"); 1763 printk(KERN_WARNING "vme_slot_num not supported\n");
1788 return -EINVAL; 1764 return -EINVAL;
1789 } 1765 }
@@ -1806,7 +1782,7 @@ int vme_bus_num(struct vme_dev *vdev)
1806 struct vme_bridge *bridge; 1782 struct vme_bridge *bridge;
1807 1783
1808 bridge = vdev->bridge; 1784 bridge = vdev->bridge;
1809 if (bridge == NULL) { 1785 if (!bridge) {
1810 pr_err("Can't find VME bus\n"); 1786 pr_err("Can't find VME bus\n");
1811 return -EINVAL; 1787 return -EINVAL;
1812 } 1788 }
@@ -1886,7 +1862,7 @@ static int __vme_register_driver_bus(struct vme_driver *drv,
1886 struct vme_dev *tmp; 1862 struct vme_dev *tmp;
1887 1863
1888 for (i = 0; i < ndevs; i++) { 1864 for (i = 0; i < ndevs; i++) {
1889 vdev = kzalloc(sizeof(struct vme_dev), GFP_KERNEL); 1865 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
1890 if (!vdev) { 1866 if (!vdev) {
1891 err = -ENOMEM; 1867 err = -ENOMEM;
1892 goto err_devalloc; 1868 goto err_devalloc;
@@ -2018,30 +1994,26 @@ static int vme_bus_match(struct device *dev, struct device_driver *drv)
2018 1994
2019static int vme_bus_probe(struct device *dev) 1995static int vme_bus_probe(struct device *dev)
2020{ 1996{
2021 int retval = -ENODEV;
2022 struct vme_driver *driver; 1997 struct vme_driver *driver;
2023 struct vme_dev *vdev = dev_to_vme_dev(dev); 1998 struct vme_dev *vdev = dev_to_vme_dev(dev);
2024 1999
2025 driver = dev->platform_data; 2000 driver = dev->platform_data;
2001 if (driver->probe)
2002 return driver->probe(vdev);
2026 2003
2027 if (driver->probe != NULL) 2004 return -ENODEV;
2028 retval = driver->probe(vdev);
2029
2030 return retval;
2031} 2005}
2032 2006
2033static int vme_bus_remove(struct device *dev) 2007static int vme_bus_remove(struct device *dev)
2034{ 2008{
2035 int retval = -ENODEV;
2036 struct vme_driver *driver; 2009 struct vme_driver *driver;
2037 struct vme_dev *vdev = dev_to_vme_dev(dev); 2010 struct vme_dev *vdev = dev_to_vme_dev(dev);
2038 2011
2039 driver = dev->platform_data; 2012 driver = dev->platform_data;
2013 if (driver->remove)
2014 return driver->remove(vdev);
2040 2015
2041 if (driver->remove != NULL) 2016 return -ENODEV;
2042 retval = driver->remove(vdev);
2043
2044 return retval;
2045} 2017}
2046 2018
2047struct bus_type vme_bus_type = { 2019struct bus_type vme_bus_type = {