diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-12-06 17:10:40 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-01-09 18:51:47 -0500 |
commit | 5f4d6214ef5e9b1ff6a72ddfa387c1d72adfac98 (patch) | |
tree | 66575b6bd2294fdeb4f007486bfdead5991b74ee /drivers/nfc | |
parent | 9e2d493e74aca105aa86de56dbf80a0a654c4c53 (diff) |
NFC: nfcwilink: Use devm_kzalloc
devm_kzalloc allocates memory that is released when a driver detaches.
This patch uses devm_kzalloc for data that is allocated in the probe
function of a platform device and is only freed in the remove function.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/nfcwilink.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c index 50b1ee41afc6..c7c182d2b7df 100644 --- a/drivers/nfc/nfcwilink.c +++ b/drivers/nfc/nfcwilink.c | |||
@@ -526,7 +526,7 @@ static int nfcwilink_probe(struct platform_device *pdev) | |||
526 | 526 | ||
527 | nfc_dev_dbg(&pdev->dev, "probe entry"); | 527 | nfc_dev_dbg(&pdev->dev, "probe entry"); |
528 | 528 | ||
529 | drv = kzalloc(sizeof(struct nfcwilink), GFP_KERNEL); | 529 | drv = devm_kzalloc(&pdev->dev, sizeof(struct nfcwilink), GFP_KERNEL); |
530 | if (!drv) { | 530 | if (!drv) { |
531 | rc = -ENOMEM; | 531 | rc = -ENOMEM; |
532 | goto exit; | 532 | goto exit; |
@@ -547,7 +547,7 @@ static int nfcwilink_probe(struct platform_device *pdev) | |||
547 | if (!drv->ndev) { | 547 | if (!drv->ndev) { |
548 | nfc_dev_err(&pdev->dev, "nci_allocate_device failed"); | 548 | nfc_dev_err(&pdev->dev, "nci_allocate_device failed"); |
549 | rc = -ENOMEM; | 549 | rc = -ENOMEM; |
550 | goto free_exit; | 550 | goto exit; |
551 | } | 551 | } |
552 | 552 | ||
553 | nci_set_parent_dev(drv->ndev, &pdev->dev); | 553 | nci_set_parent_dev(drv->ndev, &pdev->dev); |
@@ -566,9 +566,6 @@ static int nfcwilink_probe(struct platform_device *pdev) | |||
566 | free_dev_exit: | 566 | free_dev_exit: |
567 | nci_free_device(drv->ndev); | 567 | nci_free_device(drv->ndev); |
568 | 568 | ||
569 | free_exit: | ||
570 | kfree(drv); | ||
571 | |||
572 | exit: | 569 | exit: |
573 | return rc; | 570 | return rc; |
574 | } | 571 | } |
@@ -588,8 +585,6 @@ static int nfcwilink_remove(struct platform_device *pdev) | |||
588 | nci_unregister_device(ndev); | 585 | nci_unregister_device(ndev); |
589 | nci_free_device(ndev); | 586 | nci_free_device(ndev); |
590 | 587 | ||
591 | kfree(drv); | ||
592 | |||
593 | dev_set_drvdata(&pdev->dev, NULL); | 588 | dev_set_drvdata(&pdev->dev, NULL); |
594 | 589 | ||
595 | return 0; | 590 | return 0; |