Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

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