Commit 6d011dd8 authored by Markus Elfring's avatar Markus Elfring Committed by Martyn Welch

vme: tsi148: Improve 17 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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
[martyn@welchs.me.uk: Correct long line]
Signed-off-by: default avatarMartyn Welch <martyn@welchs.me.uk>
parent 97660957
...@@ -741,7 +741,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, ...@@ -741,7 +741,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
image->kern_base = NULL; image->kern_base = NULL;
kfree(image->bus_resource.name); kfree(image->bus_resource.name);
release_resource(&image->bus_resource); release_resource(&image->bus_resource);
memset(&image->bus_resource, 0, sizeof(struct resource)); memset(&image->bus_resource, 0, sizeof(image->bus_resource));
} }
/* Exit here if size is zero */ /* Exit here if size is zero */
...@@ -788,7 +788,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, ...@@ -788,7 +788,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
release_resource(&image->bus_resource); release_resource(&image->bus_resource);
err_resource: err_resource:
kfree(image->bus_resource.name); kfree(image->bus_resource.name);
memset(&image->bus_resource, 0, sizeof(struct resource)); memset(&image->bus_resource, 0, sizeof(image->bus_resource));
err_name: err_name:
return retval; return retval;
} }
...@@ -802,7 +802,7 @@ static void tsi148_free_resource(struct vme_master_resource *image) ...@@ -802,7 +802,7 @@ static void tsi148_free_resource(struct vme_master_resource *image)
image->kern_base = NULL; image->kern_base = NULL;
release_resource(&image->bus_resource); release_resource(&image->bus_resource);
kfree(image->bus_resource.name); kfree(image->bus_resource.name);
memset(&image->bus_resource, 0, sizeof(struct resource)); memset(&image->bus_resource, 0, sizeof(image->bus_resource));
} }
/* /*
...@@ -1639,7 +1639,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, ...@@ -1639,7 +1639,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
tsi148_bridge = list->parent->parent; tsi148_bridge = list->parent->parent;
/* Descriptor must be aligned on 64-bit boundaries */ /* Descriptor must be aligned on 64-bit boundaries */
entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL); entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry == NULL) { if (entry == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_mem; goto err_mem;
...@@ -1657,7 +1657,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, ...@@ -1657,7 +1657,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
/* Given we are going to fill out the structure, we probably don't /* Given we are going to fill out the structure, we probably don't
* need to zero it, but better safe than sorry for now. * need to zero it, but better safe than sorry for now.
*/ */
memset(&entry->descriptor, 0, sizeof(struct tsi148_dma_descriptor)); memset(&entry->descriptor, 0, sizeof(entry->descriptor));
/* Fill out source part */ /* Fill out source part */
switch (src->type) { switch (src->type) {
...@@ -1752,8 +1752,9 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, ...@@ -1752,8 +1752,9 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
list_add_tail(&entry->list, &list->entries); list_add_tail(&entry->list, &list->entries);
entry->dma_handle = dma_map_single(tsi148_bridge->parent, entry->dma_handle = dma_map_single(tsi148_bridge->parent,
&entry->descriptor, &entry->descriptor,
sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); sizeof(entry->descriptor),
DMA_TO_DEVICE);
if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) { if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) {
dev_err(tsi148_bridge->parent, "DMA mapping error\n"); dev_err(tsi148_bridge->parent, "DMA mapping error\n");
retval = -EINVAL; retval = -EINVAL;
...@@ -2290,14 +2291,14 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2290,14 +2291,14 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* If we want to support more than one of each bridge, we need to /* If we want to support more than one of each bridge, we need to
* dynamically generate this so we get one per device * dynamically generate this so we get one per device
*/ */
tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); tsi148_bridge = kzalloc(sizeof(*tsi148_bridge), GFP_KERNEL);
if (tsi148_bridge == NULL) { if (tsi148_bridge == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_struct; goto err_struct;
} }
vme_init_bridge(tsi148_bridge); vme_init_bridge(tsi148_bridge);
tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL); tsi148_device = kzalloc(sizeof(*tsi148_device), GFP_KERNEL);
if (tsi148_device == NULL) { if (tsi148_device == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_driver; goto err_driver;
...@@ -2363,7 +2364,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2363,7 +2364,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
master_num--; master_num--;
tsi148_device->flush_image = tsi148_device->flush_image =
kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL); kmalloc(sizeof(*tsi148_device->flush_image),
GFP_KERNEL);
if (tsi148_device->flush_image == NULL) { if (tsi148_device->flush_image == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_master; goto err_master;
...@@ -2373,14 +2375,13 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2373,14 +2375,13 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
tsi148_device->flush_image->locked = 1; tsi148_device->flush_image->locked = 1;
tsi148_device->flush_image->number = master_num; tsi148_device->flush_image->number = master_num;
memset(&tsi148_device->flush_image->bus_resource, 0, memset(&tsi148_device->flush_image->bus_resource, 0,
sizeof(struct resource)); sizeof(tsi148_device->flush_image->bus_resource));
tsi148_device->flush_image->kern_base = NULL; tsi148_device->flush_image->kern_base = NULL;
} }
/* Add master windows to list */ /* Add master windows to list */
for (i = 0; i < master_num; i++) { for (i = 0; i < master_num; i++) {
master_image = kmalloc(sizeof(struct vme_master_resource), master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
GFP_KERNEL);
if (master_image == NULL) { if (master_image == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_master; goto err_master;
...@@ -2398,7 +2399,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2398,7 +2399,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
VME_PROG | VME_DATA; VME_PROG | VME_DATA;
master_image->width_attr = VME_D16 | VME_D32; master_image->width_attr = VME_D16 | VME_D32;
memset(&master_image->bus_resource, 0, memset(&master_image->bus_resource, 0,
sizeof(struct resource)); sizeof(master_image->bus_resource));
master_image->kern_base = NULL; master_image->kern_base = NULL;
list_add_tail(&master_image->list, list_add_tail(&master_image->list,
&tsi148_bridge->master_resources); &tsi148_bridge->master_resources);
...@@ -2406,8 +2407,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2406,8 +2407,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* Add slave windows to list */ /* Add slave windows to list */
for (i = 0; i < TSI148_MAX_SLAVE; i++) { for (i = 0; i < TSI148_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(struct vme_slave_resource), slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
GFP_KERNEL);
if (slave_image == NULL) { if (slave_image == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_slave; goto err_slave;
...@@ -2428,8 +2428,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2428,8 +2428,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
/* Add dma engines to list */ /* Add dma engines to list */
for (i = 0; i < TSI148_MAX_DMA; i++) { for (i = 0; i < TSI148_MAX_DMA; i++) {
dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL);
GFP_KERNEL);
if (dma_ctrlr == NULL) { if (dma_ctrlr == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_dma; goto err_dma;
...@@ -2449,7 +2448,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -2449,7 +2448,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
} }
/* Add location monitor to list */ /* Add location monitor to list */
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); lm = kmalloc(sizeof(*lm), GFP_KERNEL);
if (lm == NULL) { if (lm == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_lm; goto err_lm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment