1
0
Fork 0

vme: fake: Adjust 11 checks for null pointers

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Martyn Welch <martyn@welchs.me.uk>
hifive-unleashed-5.1
Markus Elfring 2017-08-25 10:01:16 +02:00 committed by Martyn Welch
parent 246740656a
commit 2444d37fb0
1 changed files with 11 additions and 11 deletions

View File

@ -409,7 +409,7 @@ static void fake_lm_check(struct fake_driver *bridge, unsigned long long addr,
/* Each location monitor covers 8 bytes */ /* Each location monitor covers 8 bytes */
if (((lm_base + (8 * i)) <= addr) && if (((lm_base + (8 * i)) <= addr) &&
((lm_base + (8 * i) + 8) > addr)) { ((lm_base + (8 * i) + 8) > addr)) {
if (bridge->lm_callback[i] != NULL) if (bridge->lm_callback[i])
bridge->lm_callback[i]( bridge->lm_callback[i](
bridge->lm_data[i]); bridge->lm_data[i]);
} }
@ -866,7 +866,7 @@ static int fake_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base,
/* If we already have a callback attached, we can't move it! */ /* If we already have a callback attached, we can't move it! */
for (i = 0; i < lm->monitors; i++) { for (i = 0; i < lm->monitors; i++) {
if (bridge->lm_callback[i] != NULL) { if (bridge->lm_callback[i]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
pr_err("Location monitor callback attached, can't reset\n"); pr_err("Location monitor callback attached, can't reset\n");
return -EBUSY; return -EBUSY;
@ -940,7 +940,7 @@ static int fake_lm_attach(struct vme_lm_resource *lm, int monitor,
} }
/* Check that a callback isn't already attached */ /* Check that a callback isn't already attached */
if (bridge->lm_callback[monitor] != NULL) { if (bridge->lm_callback[monitor]) {
mutex_unlock(&lm->mtx); mutex_unlock(&lm->mtx);
pr_err("Existing callback attached\n"); pr_err("Existing callback attached\n");
return -EBUSY; return -EBUSY;
@ -978,7 +978,7 @@ static int fake_lm_detach(struct vme_lm_resource *lm, int monitor)
/* If all location monitors disabled, disable global Location Monitor */ /* If all location monitors disabled, disable global Location Monitor */
tmp = 0; tmp = 0;
for (i = 0; i < lm->monitors; i++) { for (i = 0; i < lm->monitors; i++) {
if (bridge->lm_callback[i] != NULL) if (bridge->lm_callback[i])
tmp = 1; tmp = 1;
} }
@ -1003,7 +1003,7 @@ static void *fake_alloc_consistent(struct device *parent, size_t size,
{ {
void *alloc = kmalloc(size, GFP_KERNEL); void *alloc = kmalloc(size, GFP_KERNEL);
if (alloc != NULL) if (alloc)
*dma = fake_ptr_to_pci(alloc); *dma = fake_ptr_to_pci(alloc);
return alloc; return alloc;
@ -1039,7 +1039,7 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge)
/* Allocate mem for CR/CSR image */ /* Allocate mem for CR/CSR image */
bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL); bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL);
bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel); bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
if (bridge->crcsr_kernel == NULL) if (!bridge->crcsr_kernel)
return -ENOMEM; return -ENOMEM;
vstat = fake_slot_get(fake_bridge); vstat = fake_slot_get(fake_bridge);
@ -1076,13 +1076,13 @@ static int __init fake_init(void)
* dynamically allocate this so we get one per device. * dynamically allocate this so we get one per device.
*/ */
fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL); fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL);
if (fake_bridge == NULL) { if (!fake_bridge) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_struct; goto err_struct;
} }
fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL); fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL);
if (fake_device == NULL) { if (!fake_device) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_driver; goto err_driver;
} }
@ -1105,7 +1105,7 @@ static int __init fake_init(void)
INIT_LIST_HEAD(&fake_bridge->master_resources); INIT_LIST_HEAD(&fake_bridge->master_resources);
for (i = 0; i < FAKE_MAX_MASTER; i++) { for (i = 0; i < FAKE_MAX_MASTER; i++) {
master_image = kmalloc(sizeof(*master_image), GFP_KERNEL); master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
if (master_image == NULL) { if (!master_image) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_master; goto err_master;
} }
@ -1131,7 +1131,7 @@ static int __init fake_init(void)
INIT_LIST_HEAD(&fake_bridge->slave_resources); INIT_LIST_HEAD(&fake_bridge->slave_resources);
for (i = 0; i < FAKE_MAX_SLAVE; i++) { for (i = 0; i < FAKE_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL); slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
if (slave_image == NULL) { if (!slave_image) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_slave; goto err_slave;
} }
@ -1153,7 +1153,7 @@ static int __init fake_init(void)
/* Add location monitor to list */ /* Add location monitor to list */
INIT_LIST_HEAD(&fake_bridge->lm_resources); INIT_LIST_HEAD(&fake_bridge->lm_resources);
lm = kmalloc(sizeof(*lm), GFP_KERNEL); lm = kmalloc(sizeof(*lm), GFP_KERNEL);
if (lm == NULL) { if (!lm) {
retval = -ENOMEM; retval = -ENOMEM;
goto err_lm; goto err_lm;
} }