Commit 0c566659 authored by Amitoj Kaur Chawla's avatar Amitoj Kaur Chawla Committed by Greg Kroah-Hartman

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