From 0c566659237c910696c5187fd3edb3e5ef085af7 Mon Sep 17 00:00:00 2001 From: Amitoj Kaur Chawla Date: Tue, 23 Feb 2016 01:52:33 +0530 Subject: [PATCH] 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_pio2_core.c | 24 ++++++--------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vme/devices/vme_pio2_core.c b/drivers/staging/vme/devices/vme_pio2_core.c index 4f3cdbcedb3e..28a45689e2f4 100644 --- a/drivers/staging/vme/devices/vme_pio2_core.c +++ b/drivers/staging/vme/devices/vme_pio2_core.c @@ -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; } -- 2.39.5