summaryrefslogtreecommitdiffstats
path: root/drivers/vme
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2017-08-25 04:56:41 -0400
committerMartyn Welch <martyn.welch@collabora.co.uk>2017-10-13 16:32:03 -0400
commit3d9b1e53343651e514644f2a6d4ce00b362f4033 (patch)
treedaf758cdcada0107d15be11aa4eda8e17f9df4bf /drivers/vme
parent85fd4939e53873839df8e78da917c79c5074b183 (diff)
vme: ca91cx42: Improve 12 size determinations
Replace the specification of data structures by variable references as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
Diffstat (limited to 'drivers/vme')
-rw-r--r--drivers/vme/bridges/vme_ca91cx42.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c
index d25f997e8aeb..61990c7f4543 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -529,7 +529,7 @@ 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 == NULL) {
@@ -572,7 +572,7 @@ err_remap:
572 release_resource(&image->bus_resource); 572 release_resource(&image->bus_resource);
573err_resource: 573err_resource:
574 kfree(image->bus_resource.name); 574 kfree(image->bus_resource.name);
575 memset(&image->bus_resource, 0, sizeof(struct resource)); 575 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
576err_name: 576err_name:
577 return retval; 577 return retval;
578} 578}
@@ -586,7 +586,7 @@ static void ca91cx42_free_resource(struct vme_master_resource *image)
586 image->kern_base = NULL; 586 image->kern_base = NULL;
587 release_resource(&image->bus_resource); 587 release_resource(&image->bus_resource);
588 kfree(image->bus_resource.name); 588 kfree(image->bus_resource.name);
589 memset(&image->bus_resource, 0, sizeof(struct resource)); 589 memset(&image->bus_resource, 0, sizeof(image->bus_resource));
590} 590}
591 591
592 592
@@ -1034,7 +1034,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
1034 dev = list->parent->parent->parent; 1034 dev = list->parent->parent->parent;
1035 1035
1036 /* XXX descriptor must be aligned on 64-bit boundaries */ 1036 /* XXX descriptor must be aligned on 64-bit boundaries */
1037 entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL); 1037 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
1038 if (entry == NULL) { 1038 if (entry == NULL) {
1039 retval = -ENOMEM; 1039 retval = -ENOMEM;
1040 goto err_mem; 1040 goto err_mem;
@@ -1048,7 +1048,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
1048 goto err_align; 1048 goto err_align;
1049 } 1049 }
1050 1050
1051 memset(&entry->descriptor, 0, sizeof(struct ca91cx42_dma_descriptor)); 1051 memset(&entry->descriptor, 0, sizeof(entry->descriptor));
1052 1052
1053 if (dest->type == VME_DMA_VME) { 1053 if (dest->type == VME_DMA_VME) {
1054 entry->descriptor.dctl |= CA91CX42_DCTL_L2V; 1054 entry->descriptor.dctl |= CA91CX42_DCTL_L2V;
@@ -1614,16 +1614,14 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1614 /* 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
1615 * dynamically allocate the bridge structure 1615 * dynamically allocate the bridge structure
1616 */ 1616 */
1617 ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); 1617 ca91cx42_bridge = kzalloc(sizeof(*ca91cx42_bridge), GFP_KERNEL);
1618
1619 if (ca91cx42_bridge == NULL) { 1618 if (ca91cx42_bridge == NULL) {
1620 retval = -ENOMEM; 1619 retval = -ENOMEM;
1621 goto err_struct; 1620 goto err_struct;
1622 } 1621 }
1623 vme_init_bridge(ca91cx42_bridge); 1622 vme_init_bridge(ca91cx42_bridge);
1624 1623
1625 ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL); 1624 ca91cx42_device = kzalloc(sizeof(*ca91cx42_device), GFP_KERNEL);
1626
1627 if (ca91cx42_device == NULL) { 1625 if (ca91cx42_device == NULL) {
1628 retval = -ENOMEM; 1626 retval = -ENOMEM;
1629 goto err_driver; 1627 goto err_driver;
@@ -1680,8 +1678,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1680 1678
1681 /* Add master windows to list */ 1679 /* Add master windows to list */
1682 for (i = 0; i < CA91C142_MAX_MASTER; i++) { 1680 for (i = 0; i < CA91C142_MAX_MASTER; i++) {
1683 master_image = kmalloc(sizeof(struct vme_master_resource), 1681 master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
1684 GFP_KERNEL);
1685 if (master_image == NULL) { 1682 if (master_image == NULL) {
1686 retval = -ENOMEM; 1683 retval = -ENOMEM;
1687 goto err_master; 1684 goto err_master;
@@ -1696,7 +1693,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1696 VME_SUPER | VME_USER | VME_PROG | VME_DATA; 1693 VME_SUPER | VME_USER | VME_PROG | VME_DATA;
1697 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;
1698 memset(&master_image->bus_resource, 0, 1695 memset(&master_image->bus_resource, 0,
1699 sizeof(struct resource)); 1696 sizeof(master_image->bus_resource));
1700 master_image->kern_base = NULL; 1697 master_image->kern_base = NULL;
1701 list_add_tail(&master_image->list, 1698 list_add_tail(&master_image->list,
1702 &ca91cx42_bridge->master_resources); 1699 &ca91cx42_bridge->master_resources);
@@ -1704,8 +1701,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1704 1701
1705 /* Add slave windows to list */ 1702 /* Add slave windows to list */
1706 for (i = 0; i < CA91C142_MAX_SLAVE; i++) { 1703 for (i = 0; i < CA91C142_MAX_SLAVE; i++) {
1707 slave_image = kmalloc(sizeof(struct vme_slave_resource), 1704 slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
1708 GFP_KERNEL);
1709 if (slave_image == NULL) { 1705 if (slave_image == NULL) {
1710 retval = -ENOMEM; 1706 retval = -ENOMEM;
1711 goto err_slave; 1707 goto err_slave;
@@ -1729,8 +1725,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1729 1725
1730 /* Add dma engines to list */ 1726 /* Add dma engines to list */
1731 for (i = 0; i < CA91C142_MAX_DMA; i++) { 1727 for (i = 0; i < CA91C142_MAX_DMA; i++) {
1732 dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), 1728 dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL);
1733 GFP_KERNEL);
1734 if (dma_ctrlr == NULL) { 1729 if (dma_ctrlr == NULL) {
1735 retval = -ENOMEM; 1730 retval = -ENOMEM;
1736 goto err_dma; 1731 goto err_dma;
@@ -1748,7 +1743,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1748 } 1743 }
1749 1744
1750 /* Add location monitor to list */ 1745 /* Add location monitor to list */
1751 lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); 1746 lm = kmalloc(sizeof(*lm), GFP_KERNEL);
1752 if (lm == NULL) { 1747 if (lm == NULL) {
1753 retval = -ENOMEM; 1748 retval = -ENOMEM;
1754 goto err_lm; 1749 goto err_lm;