1
0
Fork 0

staging: vme: devices: Replace kzalloc with devm_kzalloc

Devm_ functions allocate memory that is released when a driver
detaches. Replace kzalloc with devm_kzalloc and remove corresponding
kfrees from probe and remove functions of a platform
device.

Also, unnecessary labels have been removed.

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
hifive-unleashed-5.1
Amitoj Kaur Chawla 2016-02-23 01:52:33 +05:30 committed by Greg Kroah-Hartman
parent 5084d7c662
commit 0c56665923
1 changed files with 6 additions and 18 deletions

View File

@ -215,11 +215,9 @@ static int pio2_probe(struct vme_dev *vdev)
u8 reg;
int vec;
card = kzalloc(sizeof(*card), GFP_KERNEL);
if (!card) {
retval = -ENOMEM;
goto err_struct;
}
card = devm_kzalloc(&vdev->dev, sizeof(*card), GFP_KERNEL);
if (!card)
return -ENOMEM;
card->id = vdev->num;
card->bus = bus[card->id];
@ -232,8 +230,7 @@ static int pio2_probe(struct vme_dev *vdev)
for (i = 0; i < PIO2_VARIANT_LENGTH; i++) {
if (!isdigit(card->variant[i])) {
dev_err(&card->vdev->dev, "Variant invalid\n");
retval = -EINVAL;
goto err_variant;
return -EINVAL;
}
}
@ -244,8 +241,7 @@ static int pio2_probe(struct vme_dev *vdev)
if (card->irq_vector & ~PIO2_VME_VECTOR_MASK) {
dev_err(&card->vdev->dev,
"Invalid VME IRQ Vector, vector must not use lower 4 bits\n");
retval = -EINVAL;
goto err_vector;
return -EINVAL;
}
/*
@ -284,8 +280,7 @@ static int pio2_probe(struct vme_dev *vdev)
if (!card->window) {
dev_err(&card->vdev->dev,
"Unable to assign VME master resource\n");
retval = -EIO;
goto err_window;
return -EIO;
}
retval = vme_master_set(card->window, 1, card->base, 0x10000, VME_A24,
@ -430,11 +425,6 @@ err_read:
vme_master_set(card->window, 0, 0, 0, VME_A16, 0, VME_D16);
err_set:
vme_master_free(card->window);
err_window:
err_vector:
err_variant:
kfree(card);
err_struct:
return retval;
}
@ -466,8 +456,6 @@ static int pio2_remove(struct vme_dev *vdev)
vme_master_free(card->window);
kfree(card);
return 0;
}