diff options
author | Amitoj Kaur Chawla <amitoj1606@gmail.com> | 2016-02-23 01:52:33 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-03-11 22:09:09 -0800 |
commit | 0c566659237c910696c5187fd3edb3e5ef085af7 (patch) | |
tree | a4bb9fa3906da21737888663f1de3025d35cb81d /drivers/staging/vme | |
parent | 5084d7c66248394d3887805c7f13c5d274573bfd (diff) |
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>
Diffstat (limited to 'drivers/staging/vme')
-rw-r--r-- | drivers/staging/vme/devices/vme_pio2_core.c | 24 |
1 files 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; } |