Skip to content

Commit ad146e3

Browse files
committed
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.
2 parents f7f84fd + a75dc63 commit ad146e3

File tree

4 files changed

+157
-228
lines changed

4 files changed

+157
-228
lines changed

drivers/vme/bridges/vme_ca91cx42.c

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
511511
ca91cx42_bridge = image->parent;
512512

513513
/* Find pci_dev container of dev */
514-
if (ca91cx42_bridge->parent == NULL) {
514+
if (!ca91cx42_bridge->parent) {
515515
dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n");
516516
return -EINVAL;
517517
}
@@ -529,14 +529,12 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
529529
image->kern_base = NULL;
530530
kfree(image->bus_resource.name);
531531
release_resource(&image->bus_resource);
532-
memset(&image->bus_resource, 0, sizeof(struct resource));
532+
memset(&image->bus_resource, 0, sizeof(image->bus_resource));
533533
}
534534

535-
if (image->bus_resource.name == NULL) {
535+
if (!image->bus_resource.name) {
536536
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) {
540538
retval = -ENOMEM;
541539
goto err_name;
542540
}
@@ -562,7 +560,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
562560

563561
image->kern_base = ioremap_nocache(
564562
image->bus_resource.start, size);
565-
if (image->kern_base == NULL) {
563+
if (!image->kern_base) {
566564
dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n");
567565
retval = -ENOMEM;
568566
goto err_remap;
@@ -574,7 +572,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image,
574572
release_resource(&image->bus_resource);
575573
err_resource:
576574
kfree(image->bus_resource.name);
577-
memset(&image->bus_resource, 0, sizeof(struct resource));
575+
memset(&image->bus_resource, 0, sizeof(image->bus_resource));
578576
err_name:
579577
return retval;
580578
}
@@ -588,7 +586,7 @@ static void ca91cx42_free_resource(struct vme_master_resource *image)
588586
image->kern_base = NULL;
589587
release_resource(&image->bus_resource);
590588
kfree(image->bus_resource.name);
591-
memset(&image->bus_resource, 0, sizeof(struct resource));
589+
memset(&image->bus_resource, 0, sizeof(image->bus_resource));
592590
}
593591

594592

@@ -1036,10 +1034,8 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
10361034
dev = list->parent->parent->parent;
10371035

10381036
/* XXX descriptor must be aligned on 64-bit boundaries */
1039-
entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL);
1040-
if (entry == NULL) {
1041-
dev_err(dev, "Failed to allocate memory for dma resource "
1042-
"structure\n");
1037+
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
1038+
if (!entry) {
10431039
retval = -ENOMEM;
10441040
goto err_mem;
10451041
}
@@ -1052,7 +1048,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list *list,
10521048
goto err_align;
10531049
}
10541050

1055-
memset(&entry->descriptor, 0, sizeof(struct ca91cx42_dma_descriptor));
1051+
memset(&entry->descriptor, 0, sizeof(entry->descriptor));
10561052

10571053
if (dest->type == VME_DMA_VME) {
10581054
entry->descriptor.dctl |= CA91CX42_DCTL_L2V;
@@ -1323,7 +1319,7 @@ static int ca91cx42_lm_set(struct vme_lm_resource *lm,
13231319

13241320
/* If we already have a callback attached, we can't move it! */
13251321
for (i = 0; i < lm->monitors; i++) {
1326-
if (bridge->lm_callback[i] != NULL) {
1322+
if (bridge->lm_callback[i]) {
13271323
mutex_unlock(&lm->mtx);
13281324
dev_err(dev, "Location monitor callback attached, "
13291325
"can't reset\n");
@@ -1432,7 +1428,7 @@ static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor,
14321428
}
14331429

14341430
/* Check that a callback isn't already attached */
1435-
if (bridge->lm_callback[monitor] != NULL) {
1431+
if (bridge->lm_callback[monitor]) {
14361432
mutex_unlock(&lm->mtx);
14371433
dev_err(dev, "Existing callback attached\n");
14381434
return -EBUSY;
@@ -1567,7 +1563,7 @@ static int ca91cx42_crcsr_init(struct vme_bridge *ca91cx42_bridge,
15671563
/* Allocate mem for CR/CSR image */
15681564
bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
15691565
&bridge->crcsr_bus);
1570-
if (bridge->crcsr_kernel == NULL) {
1566+
if (!bridge->crcsr_kernel) {
15711567
dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR "
15721568
"image\n");
15731569
return -ENOMEM;
@@ -1618,21 +1614,15 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
16181614
/* We want to support more than one of each bridge so we need to
16191615
* dynamically allocate the bridge structure
16201616
*/
1621-
ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
1622-
1623-
if (ca91cx42_bridge == NULL) {
1624-
dev_err(&pdev->dev, "Failed to allocate memory for device "
1625-
"structure\n");
1617+
ca91cx42_bridge = kzalloc(sizeof(*ca91cx42_bridge), GFP_KERNEL);
1618+
if (!ca91cx42_bridge) {
16261619
retval = -ENOMEM;
16271620
goto err_struct;
16281621
}
16291622
vme_init_bridge(ca91cx42_bridge);
16301623

1631-
ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL);
1632-
1633-
if (ca91cx42_device == NULL) {
1634-
dev_err(&pdev->dev, "Failed to allocate memory for device "
1635-
"structure\n");
1624+
ca91cx42_device = kzalloc(sizeof(*ca91cx42_device), GFP_KERNEL);
1625+
if (!ca91cx42_device) {
16361626
retval = -ENOMEM;
16371627
goto err_driver;
16381628
}
@@ -1688,11 +1678,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
16881678

16891679
/* Add master windows to list */
16901680
for (i = 0; i < CA91C142_MAX_MASTER; i++) {
1691-
master_image = kmalloc(sizeof(struct vme_master_resource),
1692-
GFP_KERNEL);
1693-
if (master_image == NULL) {
1694-
dev_err(&pdev->dev, "Failed to allocate memory for "
1695-
"master resource structure\n");
1681+
master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
1682+
if (!master_image) {
16961683
retval = -ENOMEM;
16971684
goto err_master;
16981685
}
@@ -1706,19 +1693,16 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17061693
VME_SUPER | VME_USER | VME_PROG | VME_DATA;
17071694
master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64;
17081695
memset(&master_image->bus_resource, 0,
1709-
sizeof(struct resource));
1696+
sizeof(master_image->bus_resource));
17101697
master_image->kern_base = NULL;
17111698
list_add_tail(&master_image->list,
17121699
&ca91cx42_bridge->master_resources);
17131700
}
17141701

17151702
/* Add slave windows to list */
17161703
for (i = 0; i < CA91C142_MAX_SLAVE; i++) {
1717-
slave_image = kmalloc(sizeof(struct vme_slave_resource),
1718-
GFP_KERNEL);
1719-
if (slave_image == NULL) {
1720-
dev_err(&pdev->dev, "Failed to allocate memory for "
1721-
"slave resource structure\n");
1704+
slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
1705+
if (!slave_image) {
17221706
retval = -ENOMEM;
17231707
goto err_slave;
17241708
}
@@ -1741,11 +1725,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17411725

17421726
/* Add dma engines to list */
17431727
for (i = 0; i < CA91C142_MAX_DMA; i++) {
1744-
dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource),
1745-
GFP_KERNEL);
1746-
if (dma_ctrlr == NULL) {
1747-
dev_err(&pdev->dev, "Failed to allocate memory for "
1748-
"dma resource structure\n");
1728+
dma_ctrlr = kmalloc(sizeof(*dma_ctrlr), GFP_KERNEL);
1729+
if (!dma_ctrlr) {
17491730
retval = -ENOMEM;
17501731
goto err_dma;
17511732
}
@@ -1762,10 +1743,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17621743
}
17631744

17641745
/* Add location monitor to list */
1765-
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
1766-
if (lm == NULL) {
1767-
dev_err(&pdev->dev, "Failed to allocate memory for "
1768-
"location monitor resource structure\n");
1746+
lm = kmalloc(sizeof(*lm), GFP_KERNEL);
1747+
if (!lm) {
17691748
retval = -ENOMEM;
17701749
goto err_lm;
17711750
}

drivers/vme/bridges/vme_fake.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static void fake_lm_check(struct fake_driver *bridge, unsigned long long addr,
409409
/* Each location monitor covers 8 bytes */
410410
if (((lm_base + (8 * i)) <= addr) &&
411411
((lm_base + (8 * i) + 8) > addr)) {
412-
if (bridge->lm_callback[i] != NULL)
412+
if (bridge->lm_callback[i])
413413
bridge->lm_callback[i](
414414
bridge->lm_data[i]);
415415
}
@@ -866,7 +866,7 @@ static int fake_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base,
866866

867867
/* If we already have a callback attached, we can't move it! */
868868
for (i = 0; i < lm->monitors; i++) {
869-
if (bridge->lm_callback[i] != NULL) {
869+
if (bridge->lm_callback[i]) {
870870
mutex_unlock(&lm->mtx);
871871
pr_err("Location monitor callback attached, can't reset\n");
872872
return -EBUSY;
@@ -940,7 +940,7 @@ static int fake_lm_attach(struct vme_lm_resource *lm, int monitor,
940940
}
941941

942942
/* Check that a callback isn't already attached */
943-
if (bridge->lm_callback[monitor] != NULL) {
943+
if (bridge->lm_callback[monitor]) {
944944
mutex_unlock(&lm->mtx);
945945
pr_err("Existing callback attached\n");
946946
return -EBUSY;
@@ -978,7 +978,7 @@ static int fake_lm_detach(struct vme_lm_resource *lm, int monitor)
978978
/* If all location monitors disabled, disable global Location Monitor */
979979
tmp = 0;
980980
for (i = 0; i < lm->monitors; i++) {
981-
if (bridge->lm_callback[i] != NULL)
981+
if (bridge->lm_callback[i])
982982
tmp = 1;
983983
}
984984

@@ -1003,7 +1003,7 @@ static void *fake_alloc_consistent(struct device *parent, size_t size,
10031003
{
10041004
void *alloc = kmalloc(size, GFP_KERNEL);
10051005

1006-
if (alloc != NULL)
1006+
if (alloc)
10071007
*dma = fake_ptr_to_pci(alloc);
10081008

10091009
return alloc;
@@ -1039,7 +1039,7 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge)
10391039
/* Allocate mem for CR/CSR image */
10401040
bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL);
10411041
bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
1042-
if (bridge->crcsr_kernel == NULL)
1042+
if (!bridge->crcsr_kernel)
10431043
return -ENOMEM;
10441044

10451045
vstat = fake_slot_get(fake_bridge);
@@ -1075,14 +1075,14 @@ static int __init fake_init(void)
10751075
/* If we want to support more than one bridge at some point, we need to
10761076
* dynamically allocate this so we get one per device.
10771077
*/
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) {
10801080
retval = -ENOMEM;
10811081
goto err_struct;
10821082
}
10831083

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) {
10861086
retval = -ENOMEM;
10871087
goto err_driver;
10881088
}
@@ -1104,9 +1104,8 @@ static int __init fake_init(void)
11041104
/* Add master windows to list */
11051105
INIT_LIST_HEAD(&fake_bridge->master_resources);
11061106
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) {
11101109
retval = -ENOMEM;
11111110
goto err_master;
11121111
}
@@ -1131,9 +1130,8 @@ static int __init fake_init(void)
11311130
/* Add slave windows to list */
11321131
INIT_LIST_HEAD(&fake_bridge->slave_resources);
11331132
for (i = 0; i < FAKE_MAX_SLAVE; i++) {
1134-
slave_image = kmalloc(sizeof(struct vme_slave_resource),
1135-
GFP_KERNEL);
1136-
if (slave_image == NULL) {
1133+
slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
1134+
if (!slave_image) {
11371135
retval = -ENOMEM;
11381136
goto err_slave;
11391137
}
@@ -1154,9 +1152,8 @@ static int __init fake_init(void)
11541152

11551153
/* Add location monitor to list */
11561154
INIT_LIST_HEAD(&fake_bridge->lm_resources);
1157-
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
1158-
if (lm == NULL) {
1159-
pr_err("Failed to allocate memory for location monitor resource structure\n");
1155+
lm = kmalloc(sizeof(*lm), GFP_KERNEL);
1156+
if (!lm) {
11601157
retval = -ENOMEM;
11611158
goto err_lm;
11621159
}

0 commit comments

Comments
 (0)