082-03-USB-bcma-use-devm_kzalloc.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From c27da2b22b558390acc515e71e47b1b307f85d5a Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Thu, 11 Jun 2015 22:57:37 +0200
  4. Subject: [PATCH] USB: bcma: use devm_kzalloc
  5. Instead of manually handling the frees use devm. There was also a free
  6. missing in the unregister call which is not needed with devm.
  7. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  8. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  9. ---
  10. drivers/usb/host/bcma-hcd.c | 11 ++++-------
  11. 1 file changed, 4 insertions(+), 7 deletions(-)
  12. --- a/drivers/usb/host/bcma-hcd.c
  13. +++ b/drivers/usb/host/bcma-hcd.c
  14. @@ -225,7 +225,8 @@ static int bcma_hcd_probe(struct bcma_de
  15. if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
  16. return -EOPNOTSUPP;
  17. - usb_dev = kzalloc(sizeof(struct bcma_hcd_device), GFP_KERNEL);
  18. + usb_dev = devm_kzalloc(&dev->dev, sizeof(struct bcma_hcd_device),
  19. + GFP_KERNEL);
  20. if (!usb_dev)
  21. return -ENOMEM;
  22. @@ -239,10 +240,8 @@ static int bcma_hcd_probe(struct bcma_de
  23. ohci_addr = 0x18009000;
  24. usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
  25. - if (IS_ERR(usb_dev->ohci_dev)) {
  26. - err = PTR_ERR(usb_dev->ohci_dev);
  27. - goto err_free_usb_dev;
  28. - }
  29. + if (IS_ERR(usb_dev->ohci_dev))
  30. + return PTR_ERR(usb_dev->ohci_dev);
  31. usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
  32. if (IS_ERR(usb_dev->ehci_dev)) {
  33. @@ -255,8 +254,6 @@ static int bcma_hcd_probe(struct bcma_de
  34. err_unregister_ohci_dev:
  35. platform_device_unregister(usb_dev->ohci_dev);
  36. -err_free_usb_dev:
  37. - kfree(usb_dev);
  38. return err;
  39. }