summaryrefslogtreecommitdiffstats
path: root/drivers/vme
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-16 12:10:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-16 12:10:59 -0500
commit2bf16b7a73caf3435f782e4170cfe563675e10f9 (patch)
tree7f4c5b28a02f08c4d6fd69dd43db5872b07c20c4 /drivers/vme
parentb9743042b3d31fed271ae19aee79dd86817904f0 (diff)
parentf13d1a8a801dae552ef495c84a223280586a9f67 (diff)
Merge tag 'char-misc-4.15-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc updates from Greg KH: "Here is the big set of char/misc and other driver subsystem patches for 4.15-rc1. There are small changes all over here, hyperv driver updates, pcmcia driver updates, w1 driver updats, vme driver updates, nvmem driver updates, and lots of other little one-off driver updates as well. The shortlog has the full details. All of these have been in linux-next for quite a while with no reported issues" * tag 'char-misc-4.15-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (90 commits) VME: Return -EBUSY when DMA list in use w1: keep balance of mutex locks and refcnts MAINTAINERS: Update VME subsystem tree. nvmem: sunxi-sid: add support for A64/H5's SID controller nvmem: imx-ocotp: Update module description nvmem: imx-ocotp: Enable i.MX7D OTP write support nvmem: imx-ocotp: Add i.MX7D timing write clock setup support nvmem: imx-ocotp: Move i.MX6 write clock setup to dedicated function nvmem: imx-ocotp: Add support for banked OTP addressing nvmem: imx-ocotp: Pass parameters via a struct nvmem: imx-ocotp: Restrict OTP write to IMX6 processors nvmem: uniphier: add UniPhier eFuse driver dt-bindings: nvmem: add description for UniPhier eFuse nvmem: set nvmem->owner to nvmem->dev->driver->owner if unset nvmem: qfprom: fix different address space warnings of sparse nvmem: mtk-efuse: fix different address space warnings of sparse nvmem: mtk-efuse: use stack for nvmem_config instead of malloc'ing it nvmem: imx-iim: use stack for nvmem_config instead of malloc'ing it thunderbolt: tb: fix use after free in tb_activate_pcie_devices MAINTAINERS: Add git tree for Thunderbolt development ...
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.c214
4 files changed, 166 insertions, 239 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 6a3ead42aba8..81246221a13b 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;
@@ -208,29 +208,27 @@ int vme_check_window(u32 aspace, unsigned long long vme_base,
208{ 208{
209 int retval = 0; 209 int retval = 0;
210 210
211 if (vme_base + size < size)
212 return -EINVAL;
213
211 switch (aspace) { 214 switch (aspace) {
212 case VME_A16: 215 case VME_A16:
213 if (((vme_base + size) > VME_A16_MAX) || 216 if (vme_base + size > VME_A16_MAX)
214 (vme_base > VME_A16_MAX))
215 retval = -EFAULT; 217 retval = -EFAULT;
216 break; 218 break;
217 case VME_A24: 219 case VME_A24:
218 if (((vme_base + size) > VME_A24_MAX) || 220 if (vme_base + size > VME_A24_MAX)
219 (vme_base > VME_A24_MAX))
220 retval = -EFAULT; 221 retval = -EFAULT;
221 break; 222 break;
222 case VME_A32: 223 case VME_A32:
223 if (((vme_base + size) > VME_A32_MAX) || 224 if (vme_base + size > VME_A32_MAX)
224 (vme_base > VME_A32_MAX))
225 retval = -EFAULT; 225 retval = -EFAULT;
226 break; 226 break;
227 case VME_A64: 227 case VME_A64:
228 if ((size != 0) && (vme_base > U64_MAX + 1 - size)) 228 /* The VME_A64_MAX limit is actually U64_MAX + 1 */
229 retval = -EFAULT;
230 break; 229 break;
231 case VME_CRCSR: 230 case VME_CRCSR:
232 if (((vme_base + size) > VME_CRCSR_MAX) || 231 if (vme_base + size > VME_CRCSR_MAX)
233 (vme_base > VME_CRCSR_MAX))
234 retval = -EFAULT; 232 retval = -EFAULT;
235 break; 233 break;
236 case VME_USER1: 234 case VME_USER1:
@@ -303,7 +301,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
303 struct vme_resource *resource = NULL; 301 struct vme_resource *resource = NULL;
304 302
305 bridge = vdev->bridge; 303 bridge = vdev->bridge;
306 if (bridge == NULL) { 304 if (!bridge) {
307 printk(KERN_ERR "Can't find VME bus\n"); 305 printk(KERN_ERR "Can't find VME bus\n");
308 goto err_bus; 306 goto err_bus;
309 } 307 }
@@ -313,7 +311,7 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
313 slave_image = list_entry(slave_pos, 311 slave_image = list_entry(slave_pos,
314 struct vme_slave_resource, list); 312 struct vme_slave_resource, list);
315 313
316 if (slave_image == NULL) { 314 if (!slave_image) {
317 printk(KERN_ERR "Registered NULL Slave resource\n"); 315 printk(KERN_ERR "Registered NULL Slave resource\n");
318 continue; 316 continue;
319 } 317 }
@@ -333,14 +331,13 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
333 } 331 }
334 332
335 /* No free image */ 333 /* No free image */
336 if (allocated_image == NULL) 334 if (!allocated_image)
337 goto err_image; 335 goto err_image;
338 336
339 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 337 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
340 if (resource == NULL) { 338 if (!resource)
341 printk(KERN_WARNING "Unable to allocate resource structure\n");
342 goto err_alloc; 339 goto err_alloc;
343 } 340
344 resource->type = VME_SLAVE; 341 resource->type = VME_SLAVE;
345 resource->entry = &allocated_image->list; 342 resource->entry = &allocated_image->list;
346 343
@@ -389,7 +386,7 @@ int vme_slave_set(struct vme_resource *resource, int enabled,
389 386
390 image = list_entry(resource->entry, struct vme_slave_resource, list); 387 image = list_entry(resource->entry, struct vme_slave_resource, list);
391 388
392 if (bridge->slave_set == NULL) { 389 if (!bridge->slave_set) {
393 printk(KERN_ERR "Function not supported\n"); 390 printk(KERN_ERR "Function not supported\n");
394 return -ENOSYS; 391 return -ENOSYS;
395 } 392 }
@@ -438,7 +435,7 @@ int vme_slave_get(struct vme_resource *resource, int *enabled,
438 435
439 image = list_entry(resource->entry, struct vme_slave_resource, list); 436 image = list_entry(resource->entry, struct vme_slave_resource, list);
440 437
441 if (bridge->slave_get == NULL) { 438 if (!bridge->slave_get) {
442 printk(KERN_ERR "vme_slave_get not supported\n"); 439 printk(KERN_ERR "vme_slave_get not supported\n");
443 return -EINVAL; 440 return -EINVAL;
444 } 441 }
@@ -465,7 +462,7 @@ void vme_slave_free(struct vme_resource *resource)
465 462
466 slave_image = list_entry(resource->entry, struct vme_slave_resource, 463 slave_image = list_entry(resource->entry, struct vme_slave_resource,
467 list); 464 list);
468 if (slave_image == NULL) { 465 if (!slave_image) {
469 printk(KERN_ERR "Can't find slave resource\n"); 466 printk(KERN_ERR "Can't find slave resource\n");
470 return; 467 return;
471 } 468 }
@@ -505,7 +502,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
505 struct vme_resource *resource = NULL; 502 struct vme_resource *resource = NULL;
506 503
507 bridge = vdev->bridge; 504 bridge = vdev->bridge;
508 if (bridge == NULL) { 505 if (!bridge) {
509 printk(KERN_ERR "Can't find VME bus\n"); 506 printk(KERN_ERR "Can't find VME bus\n");
510 goto err_bus; 507 goto err_bus;
511 } 508 }
@@ -515,7 +512,7 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
515 master_image = list_entry(master_pos, 512 master_image = list_entry(master_pos,
516 struct vme_master_resource, list); 513 struct vme_master_resource, list);
517 514
518 if (master_image == NULL) { 515 if (!master_image) {
519 printk(KERN_WARNING "Registered NULL master resource\n"); 516 printk(KERN_WARNING "Registered NULL master resource\n");
520 continue; 517 continue;
521 } 518 }
@@ -536,16 +533,15 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
536 } 533 }
537 534
538 /* Check to see if we found a resource */ 535 /* Check to see if we found a resource */
539 if (allocated_image == NULL) { 536 if (!allocated_image) {
540 printk(KERN_ERR "Can't find a suitable resource\n"); 537 printk(KERN_ERR "Can't find a suitable resource\n");
541 goto err_image; 538 goto err_image;
542 } 539 }
543 540
544 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 541 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
545 if (resource == NULL) { 542 if (!resource)
546 printk(KERN_ERR "Unable to allocate resource structure\n");
547 goto err_alloc; 543 goto err_alloc;
548 } 544
549 resource->type = VME_MASTER; 545 resource->type = VME_MASTER;
550 resource->entry = &allocated_image->list; 546 resource->entry = &allocated_image->list;
551 547
@@ -594,7 +590,7 @@ int vme_master_set(struct vme_resource *resource, int enabled,
594 590
595 image = list_entry(resource->entry, struct vme_master_resource, list); 591 image = list_entry(resource->entry, struct vme_master_resource, list);
596 592
597 if (bridge->master_set == NULL) { 593 if (!bridge->master_set) {
598 printk(KERN_WARNING "vme_master_set not supported\n"); 594 printk(KERN_WARNING "vme_master_set not supported\n");
599 return -EINVAL; 595 return -EINVAL;
600 } 596 }
@@ -644,7 +640,7 @@ int vme_master_get(struct vme_resource *resource, int *enabled,
644 640
645 image = list_entry(resource->entry, struct vme_master_resource, list); 641 image = list_entry(resource->entry, struct vme_master_resource, list);
646 642
647 if (bridge->master_get == NULL) { 643 if (!bridge->master_get) {
648 printk(KERN_WARNING "%s not supported\n", __func__); 644 printk(KERN_WARNING "%s not supported\n", __func__);
649 return -EINVAL; 645 return -EINVAL;
650 } 646 }
@@ -676,7 +672,7 @@ ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,
676 struct vme_master_resource *image; 672 struct vme_master_resource *image;
677 size_t length; 673 size_t length;
678 674
679 if (bridge->master_read == NULL) { 675 if (!bridge->master_read) {
680 printk(KERN_WARNING "Reading from resource not supported\n"); 676 printk(KERN_WARNING "Reading from resource not supported\n");
681 return -EINVAL; 677 return -EINVAL;
682 } 678 }
@@ -725,7 +721,7 @@ ssize_t vme_master_write(struct vme_resource *resource, void *buf,
725 struct vme_master_resource *image; 721 struct vme_master_resource *image;
726 size_t length; 722 size_t length;
727 723
728 if (bridge->master_write == NULL) { 724 if (!bridge->master_write) {
729 printk(KERN_WARNING "Writing to resource not supported\n"); 725 printk(KERN_WARNING "Writing to resource not supported\n");
730 return -EINVAL; 726 return -EINVAL;
731 } 727 }
@@ -776,7 +772,7 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,
776 struct vme_bridge *bridge = find_bridge(resource); 772 struct vme_bridge *bridge = find_bridge(resource);
777 struct vme_master_resource *image; 773 struct vme_master_resource *image;
778 774
779 if (bridge->master_rmw == NULL) { 775 if (!bridge->master_rmw) {
780 printk(KERN_WARNING "Writing to resource not supported\n"); 776 printk(KERN_WARNING "Writing to resource not supported\n");
781 return -EINVAL; 777 return -EINVAL;
782 } 778 }
@@ -846,7 +842,7 @@ void vme_master_free(struct vme_resource *resource)
846 842
847 master_image = list_entry(resource->entry, struct vme_master_resource, 843 master_image = list_entry(resource->entry, struct vme_master_resource,
848 list); 844 list);
849 if (master_image == NULL) { 845 if (!master_image) {
850 printk(KERN_ERR "Can't find master resource\n"); 846 printk(KERN_ERR "Can't find master resource\n");
851 return; 847 return;
852 } 848 }
@@ -886,7 +882,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
886 printk(KERN_ERR "No VME resource Attribute tests done\n"); 882 printk(KERN_ERR "No VME resource Attribute tests done\n");
887 883
888 bridge = vdev->bridge; 884 bridge = vdev->bridge;
889 if (bridge == NULL) { 885 if (!bridge) {
890 printk(KERN_ERR "Can't find VME bus\n"); 886 printk(KERN_ERR "Can't find VME bus\n");
891 goto err_bus; 887 goto err_bus;
892 } 888 }
@@ -895,8 +891,7 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
895 list_for_each(dma_pos, &bridge->dma_resources) { 891 list_for_each(dma_pos, &bridge->dma_resources) {
896 dma_ctrlr = list_entry(dma_pos, 892 dma_ctrlr = list_entry(dma_pos,
897 struct vme_dma_resource, list); 893 struct vme_dma_resource, list);
898 894 if (!dma_ctrlr) {
899 if (dma_ctrlr == NULL) {
900 printk(KERN_ERR "Registered NULL DMA resource\n"); 895 printk(KERN_ERR "Registered NULL DMA resource\n");
901 continue; 896 continue;
902 } 897 }
@@ -915,14 +910,13 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
915 } 910 }
916 911
917 /* Check to see if we found a resource */ 912 /* Check to see if we found a resource */
918 if (allocated_ctrlr == NULL) 913 if (!allocated_ctrlr)
919 goto err_ctrlr; 914 goto err_ctrlr;
920 915
921 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 916 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
922 if (resource == NULL) { 917 if (!resource)
923 printk(KERN_WARNING "Unable to allocate resource structure\n");
924 goto err_alloc; 918 goto err_alloc;
925 } 919
926 resource->type = VME_DMA; 920 resource->type = VME_DMA;
927 resource->entry = &allocated_ctrlr->list; 921 resource->entry = &allocated_ctrlr->list;
928 922
@@ -951,7 +945,6 @@ EXPORT_SYMBOL(vme_dma_request);
951 */ 945 */
952struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource) 946struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
953{ 947{
954 struct vme_dma_resource *ctrlr;
955 struct vme_dma_list *dma_list; 948 struct vme_dma_list *dma_list;
956 949
957 if (resource->type != VME_DMA) { 950 if (resource->type != VME_DMA) {
@@ -959,15 +952,14 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
959 return NULL; 952 return NULL;
960 } 953 }
961 954
962 ctrlr = list_entry(resource->entry, struct vme_dma_resource, list); 955 dma_list = kmalloc(sizeof(*dma_list), GFP_KERNEL);
963 956 if (!dma_list)
964 dma_list = kmalloc(sizeof(struct vme_dma_list), GFP_KERNEL);
965 if (dma_list == NULL) {
966 printk(KERN_ERR "Unable to allocate memory for new DMA list\n");
967 return NULL; 957 return NULL;
968 } 958
969 INIT_LIST_HEAD(&dma_list->entries); 959 INIT_LIST_HEAD(&dma_list->entries);
970 dma_list->parent = ctrlr; 960 dma_list->parent = list_entry(resource->entry,
961 struct vme_dma_resource,
962 list);
971 mutex_init(&dma_list->mtx); 963 mutex_init(&dma_list->mtx);
972 964
973 return dma_list; 965 return dma_list;
@@ -990,17 +982,13 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, u32 type)
990 struct vme_dma_attr *attributes; 982 struct vme_dma_attr *attributes;
991 struct vme_dma_pattern *pattern_attr; 983 struct vme_dma_pattern *pattern_attr;
992 984
993 attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL); 985 attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
994 if (attributes == NULL) { 986 if (!attributes)
995 printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
996 goto err_attr; 987 goto err_attr;
997 }
998 988
999 pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL); 989 pattern_attr = kmalloc(sizeof(*pattern_attr), GFP_KERNEL);
1000 if (pattern_attr == NULL) { 990 if (!pattern_attr)
1001 printk(KERN_ERR "Unable to allocate memory for pattern attributes\n");
1002 goto err_pat; 991 goto err_pat;
1003 }
1004 992
1005 attributes->type = VME_DMA_PATTERN; 993 attributes->type = VME_DMA_PATTERN;
1006 attributes->private = (void *)pattern_attr; 994 attributes->private = (void *)pattern_attr;
@@ -1034,19 +1022,13 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address)
1034 1022
1035 /* XXX Run some sanity checks here */ 1023 /* XXX Run some sanity checks here */
1036 1024
1037 attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL); 1025 attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
1038 if (attributes == NULL) { 1026 if (!attributes)
1039 printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
1040 goto err_attr; 1027 goto err_attr;
1041 }
1042 1028
1043 pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL); 1029 pci_attr = kmalloc(sizeof(*pci_attr), GFP_KERNEL);
1044 if (pci_attr == NULL) { 1030 if (!pci_attr)
1045 printk(KERN_ERR "Unable to allocate memory for PCI attributes\n");
1046 goto err_pci; 1031 goto err_pci;
1047 }
1048
1049
1050 1032
1051 attributes->type = VME_DMA_PCI; 1033 attributes->type = VME_DMA_PCI;
1052 attributes->private = (void *)pci_attr; 1034 attributes->private = (void *)pci_attr;
@@ -1081,18 +1063,13 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address,
1081 struct vme_dma_attr *attributes; 1063 struct vme_dma_attr *attributes;
1082 struct vme_dma_vme *vme_attr; 1064 struct vme_dma_vme *vme_attr;
1083 1065
1084 attributes = kmalloc( 1066 attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
1085 sizeof(struct vme_dma_attr), GFP_KERNEL); 1067 if (!attributes)
1086 if (attributes == NULL) {
1087 printk(KERN_ERR "Unable to allocate memory for attributes structure\n");
1088 goto err_attr; 1068 goto err_attr;
1089 }
1090 1069
1091 vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL); 1070 vme_attr = kmalloc(sizeof(*vme_attr), GFP_KERNEL);
1092 if (vme_attr == NULL) { 1071 if (!vme_attr)
1093 printk(KERN_ERR "Unable to allocate memory for VME attributes\n");
1094 goto err_vme; 1072 goto err_vme;
1095 }
1096 1073
1097 attributes->type = VME_DMA_VME; 1074 attributes->type = VME_DMA_VME;
1098 attributes->private = (void *)vme_attr; 1075 attributes->private = (void *)vme_attr;
@@ -1148,7 +1125,7 @@ int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,
1148 struct vme_bridge *bridge = list->parent->parent; 1125 struct vme_bridge *bridge = list->parent->parent;
1149 int retval; 1126 int retval;
1150 1127
1151 if (bridge->dma_list_add == NULL) { 1128 if (!bridge->dma_list_add) {
1152 printk(KERN_WARNING "Link List DMA generation not supported\n"); 1129 printk(KERN_WARNING "Link List DMA generation not supported\n");
1153 return -EINVAL; 1130 return -EINVAL;
1154 } 1131 }
@@ -1181,7 +1158,7 @@ int vme_dma_list_exec(struct vme_dma_list *list)
1181 struct vme_bridge *bridge = list->parent->parent; 1158 struct vme_bridge *bridge = list->parent->parent;
1182 int retval; 1159 int retval;
1183 1160
1184 if (bridge->dma_list_exec == NULL) { 1161 if (!bridge->dma_list_exec) {
1185 printk(KERN_ERR "Link List DMA execution not supported\n"); 1162 printk(KERN_ERR "Link List DMA execution not supported\n");
1186 return -EINVAL; 1163 return -EINVAL;
1187 } 1164 }
@@ -1210,14 +1187,14 @@ int vme_dma_list_free(struct vme_dma_list *list)
1210 struct vme_bridge *bridge = list->parent->parent; 1187 struct vme_bridge *bridge = list->parent->parent;
1211 int retval; 1188 int retval;
1212 1189
1213 if (bridge->dma_list_empty == NULL) { 1190 if (!bridge->dma_list_empty) {
1214 printk(KERN_WARNING "Emptying of Link Lists not supported\n"); 1191 printk(KERN_WARNING "Emptying of Link Lists not supported\n");
1215 return -EINVAL; 1192 return -EINVAL;
1216 } 1193 }
1217 1194
1218 if (!mutex_trylock(&list->mtx)) { 1195 if (!mutex_trylock(&list->mtx)) {
1219 printk(KERN_ERR "Link List in use\n"); 1196 printk(KERN_ERR "Link List in use\n");
1220 return -EINVAL; 1197 return -EBUSY;
1221 } 1198 }
1222 1199
1223 /* 1200 /*
@@ -1342,8 +1319,7 @@ void vme_irq_handler(struct vme_bridge *bridge, int level, int statid)
1342 1319
1343 call = bridge->irq[level - 1].callback[statid].func; 1320 call = bridge->irq[level - 1].callback[statid].func;
1344 priv_data = bridge->irq[level - 1].callback[statid].priv_data; 1321 priv_data = bridge->irq[level - 1].callback[statid].priv_data;
1345 1322 if (call)
1346 if (call != NULL)
1347 call(level, statid, priv_data); 1323 call(level, statid, priv_data);
1348 else 1324 else
1349 printk(KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n", 1325 printk(KERN_WARNING "Spurious VME interrupt, level:%x, vector:%x\n",
@@ -1374,7 +1350,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,
1374 struct vme_bridge *bridge; 1350 struct vme_bridge *bridge;
1375 1351
1376 bridge = vdev->bridge; 1352 bridge = vdev->bridge;
1377 if (bridge == NULL) { 1353 if (!bridge) {
1378 printk(KERN_ERR "Can't find VME bus\n"); 1354 printk(KERN_ERR "Can't find VME bus\n");
1379 return -EINVAL; 1355 return -EINVAL;
1380 } 1356 }
@@ -1384,7 +1360,7 @@ int vme_irq_request(struct vme_dev *vdev, int level, int statid,
1384 return -EINVAL; 1360 return -EINVAL;
1385 } 1361 }
1386 1362
1387 if (bridge->irq_set == NULL) { 1363 if (!bridge->irq_set) {
1388 printk(KERN_ERR "Configuring interrupts not supported\n"); 1364 printk(KERN_ERR "Configuring interrupts not supported\n");
1389 return -EINVAL; 1365 return -EINVAL;
1390 } 1366 }
@@ -1423,7 +1399,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
1423 struct vme_bridge *bridge; 1399 struct vme_bridge *bridge;
1424 1400
1425 bridge = vdev->bridge; 1401 bridge = vdev->bridge;
1426 if (bridge == NULL) { 1402 if (!bridge) {
1427 printk(KERN_ERR "Can't find VME bus\n"); 1403 printk(KERN_ERR "Can't find VME bus\n");
1428 return; 1404 return;
1429 } 1405 }
@@ -1433,7 +1409,7 @@ void vme_irq_free(struct vme_dev *vdev, int level, int statid)
1433 return; 1409 return;
1434 } 1410 }
1435 1411
1436 if (bridge->irq_set == NULL) { 1412 if (!bridge->irq_set) {
1437 printk(KERN_ERR "Configuring interrupts not supported\n"); 1413 printk(KERN_ERR "Configuring interrupts not supported\n");
1438 return; 1414 return;
1439 } 1415 }
@@ -1470,7 +1446,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
1470 struct vme_bridge *bridge; 1446 struct vme_bridge *bridge;
1471 1447
1472 bridge = vdev->bridge; 1448 bridge = vdev->bridge;
1473 if (bridge == NULL) { 1449 if (!bridge) {
1474 printk(KERN_ERR "Can't find VME bus\n"); 1450 printk(KERN_ERR "Can't find VME bus\n");
1475 return -EINVAL; 1451 return -EINVAL;
1476 } 1452 }
@@ -1480,7 +1456,7 @@ int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
1480 return -EINVAL; 1456 return -EINVAL;
1481 } 1457 }
1482 1458
1483 if (bridge->irq_generate == NULL) { 1459 if (!bridge->irq_generate) {
1484 printk(KERN_WARNING "Interrupt generation not supported\n"); 1460 printk(KERN_WARNING "Interrupt generation not supported\n");
1485 return -EINVAL; 1461 return -EINVAL;
1486 } 1462 }
@@ -1508,7 +1484,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
1508 struct vme_resource *resource = NULL; 1484 struct vme_resource *resource = NULL;
1509 1485
1510 bridge = vdev->bridge; 1486 bridge = vdev->bridge;
1511 if (bridge == NULL) { 1487 if (!bridge) {
1512 printk(KERN_ERR "Can't find VME bus\n"); 1488 printk(KERN_ERR "Can't find VME bus\n");
1513 goto err_bus; 1489 goto err_bus;
1514 } 1490 }
@@ -1517,8 +1493,7 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
1517 list_for_each(lm_pos, &bridge->lm_resources) { 1493 list_for_each(lm_pos, &bridge->lm_resources) {
1518 lm = list_entry(lm_pos, 1494 lm = list_entry(lm_pos,
1519 struct vme_lm_resource, list); 1495 struct vme_lm_resource, list);
1520 1496 if (!lm) {
1521 if (lm == NULL) {
1522 printk(KERN_ERR "Registered NULL Location Monitor resource\n"); 1497 printk(KERN_ERR "Registered NULL Location Monitor resource\n");
1523 continue; 1498 continue;
1524 } 1499 }
@@ -1535,14 +1510,13 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
1535 } 1510 }
1536 1511
1537 /* Check to see if we found a resource */ 1512 /* Check to see if we found a resource */
1538 if (allocated_lm == NULL) 1513 if (!allocated_lm)
1539 goto err_lm; 1514 goto err_lm;
1540 1515
1541 resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL); 1516 resource = kmalloc(sizeof(*resource), GFP_KERNEL);
1542 if (resource == NULL) { 1517 if (!resource)
1543 printk(KERN_ERR "Unable to allocate resource structure\n");
1544 goto err_alloc; 1518 goto err_alloc;
1545 } 1519
1546 resource->type = VME_LM; 1520 resource->type = VME_LM;
1547 resource->entry = &allocated_lm->list; 1521 resource->entry = &allocated_lm->list;
1548 1522
@@ -1612,7 +1586,7 @@ int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base,
1612 1586
1613 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1587 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1614 1588
1615 if (bridge->lm_set == NULL) { 1589 if (!bridge->lm_set) {
1616 printk(KERN_ERR "vme_lm_set not supported\n"); 1590 printk(KERN_ERR "vme_lm_set not supported\n");
1617 return -EINVAL; 1591 return -EINVAL;
1618 } 1592 }
@@ -1648,7 +1622,7 @@ int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,
1648 1622
1649 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1623 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1650 1624
1651 if (bridge->lm_get == NULL) { 1625 if (!bridge->lm_get) {
1652 printk(KERN_ERR "vme_lm_get not supported\n"); 1626 printk(KERN_ERR "vme_lm_get not supported\n");
1653 return -EINVAL; 1627 return -EINVAL;
1654 } 1628 }
@@ -1685,7 +1659,7 @@ int vme_lm_attach(struct vme_resource *resource, int monitor,
1685 1659
1686 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1660 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1687 1661
1688 if (bridge->lm_attach == NULL) { 1662 if (!bridge->lm_attach) {
1689 printk(KERN_ERR "vme_lm_attach not supported\n"); 1663 printk(KERN_ERR "vme_lm_attach not supported\n");
1690 return -EINVAL; 1664 return -EINVAL;
1691 } 1665 }
@@ -1718,7 +1692,7 @@ int vme_lm_detach(struct vme_resource *resource, int monitor)
1718 1692
1719 lm = list_entry(resource->entry, struct vme_lm_resource, list); 1693 lm = list_entry(resource->entry, struct vme_lm_resource, list);
1720 1694
1721 if (bridge->lm_detach == NULL) { 1695 if (!bridge->lm_detach) {
1722 printk(KERN_ERR "vme_lm_detach not supported\n"); 1696 printk(KERN_ERR "vme_lm_detach not supported\n");
1723 return -EINVAL; 1697 return -EINVAL;
1724 } 1698 }
@@ -1780,12 +1754,12 @@ int vme_slot_num(struct vme_dev *vdev)
1780 struct vme_bridge *bridge; 1754 struct vme_bridge *bridge;
1781 1755
1782 bridge = vdev->bridge; 1756 bridge = vdev->bridge;
1783 if (bridge == NULL) { 1757 if (!bridge) {
1784 printk(KERN_ERR "Can't find VME bus\n"); 1758 printk(KERN_ERR "Can't find VME bus\n");
1785 return -EINVAL; 1759 return -EINVAL;
1786 } 1760 }
1787 1761
1788 if (bridge->slot_get == NULL) { 1762 if (!bridge->slot_get) {
1789 printk(KERN_WARNING "vme_slot_num not supported\n"); 1763 printk(KERN_WARNING "vme_slot_num not supported\n");
1790 return -EINVAL; 1764 return -EINVAL;
1791 } 1765 }
@@ -1808,7 +1782,7 @@ int vme_bus_num(struct vme_dev *vdev)
1808 struct vme_bridge *bridge; 1782 struct vme_bridge *bridge;
1809 1783
1810 bridge = vdev->bridge; 1784 bridge = vdev->bridge;
1811 if (bridge == NULL) { 1785 if (!bridge) {
1812 pr_err("Can't find VME bus\n"); 1786 pr_err("Can't find VME bus\n");
1813 return -EINVAL; 1787 return -EINVAL;
1814 } 1788 }
@@ -1888,7 +1862,7 @@ static int __vme_register_driver_bus(struct vme_driver *drv,
1888 struct vme_dev *tmp; 1862 struct vme_dev *tmp;
1889 1863
1890 for (i = 0; i < ndevs; i++) { 1864 for (i = 0; i < ndevs; i++) {
1891 vdev = kzalloc(sizeof(struct vme_dev), GFP_KERNEL); 1865 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
1892 if (!vdev) { 1866 if (!vdev) {
1893 err = -ENOMEM; 1867 err = -ENOMEM;
1894 goto err_devalloc; 1868 goto err_devalloc;
@@ -2020,30 +1994,26 @@ static int vme_bus_match(struct device *dev, struct device_driver *drv)
2020 1994
2021static int vme_bus_probe(struct device *dev) 1995static int vme_bus_probe(struct device *dev)
2022{ 1996{
2023 int retval = -ENODEV;
2024 struct vme_driver *driver; 1997 struct vme_driver *driver;
2025 struct vme_dev *vdev = dev_to_vme_dev(dev); 1998 struct vme_dev *vdev = dev_to_vme_dev(dev);
2026 1999
2027 driver = dev->platform_data; 2000 driver = dev->platform_data;
2001 if (driver->probe)
2002 return driver->probe(vdev);
2028 2003
2029 if (driver->probe != NULL) 2004 return -ENODEV;
2030 retval = driver->probe(vdev);
2031
2032 return retval;
2033} 2005}
2034 2006
2035static int vme_bus_remove(struct device *dev) 2007static int vme_bus_remove(struct device *dev)
2036{ 2008{
2037 int retval = -ENODEV;
2038 struct vme_driver *driver; 2009 struct vme_driver *driver;
2039 struct vme_dev *vdev = dev_to_vme_dev(dev); 2010 struct vme_dev *vdev = dev_to_vme_dev(dev);
2040 2011
2041 driver = dev->platform_data; 2012 driver = dev->platform_data;
2013 if (driver->remove)
2014 return driver->remove(vdev);
2042 2015
2043 if (driver->remove != NULL) 2016 return -ENODEV;
2044 retval = driver->remove(vdev);
2045
2046 return retval;
2047} 2017}
2048 2018
2049struct bus_type vme_bus_type = { 2019struct bus_type vme_bus_type = {