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>
This commit is contained in:
Родитель
5084d7c662
Коммит
0c56665923
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче