PageRenderTime 94ms CodeModel.GetById 59ms RepoModel.GetById 3ms app.codeStats 1ms

/drivers/net/bna/cna_fwimg.c

https://bitbucket.org/slukk/jb-tsm-kernel-4.2
C | 64 lines | 39 code | 8 blank | 17 comment | 3 complexity | 5d7fb76106719114f6453a2e7990b39f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /*
  2. * Linux network driver for Brocade Converged Network Adapter.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License (GPL) Version 2 as
  6. * published by the Free Software Foundation
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. /*
  14. * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
  15. * All rights reserved
  16. * www.brocade.com
  17. */
  18. #include <linux/firmware.h>
  19. #include "cna.h"
  20. const struct firmware *bfi_fw;
  21. static u32 *bfi_image_ct_cna;
  22. static u32 bfi_image_ct_cna_size;
  23. static u32 *
  24. cna_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
  25. u32 *bfi_image_size, char *fw_name)
  26. {
  27. const struct firmware *fw;
  28. if (request_firmware(&fw, fw_name, &pdev->dev)) {
  29. pr_alert("Can't locate firmware %s\n", fw_name);
  30. goto error;
  31. }
  32. *bfi_image = (u32 *)fw->data;
  33. *bfi_image_size = fw->size/sizeof(u32);
  34. bfi_fw = fw;
  35. return *bfi_image;
  36. error:
  37. return NULL;
  38. }
  39. u32 *
  40. cna_get_firmware_buf(struct pci_dev *pdev)
  41. {
  42. if (bfi_image_ct_cna_size == 0)
  43. cna_read_firmware(pdev, &bfi_image_ct_cna,
  44. &bfi_image_ct_cna_size, CNA_FW_FILE_CT);
  45. return bfi_image_ct_cna;
  46. }
  47. u32 *
  48. bfa_cb_image_get_chunk(int type, u32 off)
  49. {
  50. return (u32 *)(bfi_image_ct_cna + off);
  51. }
  52. u32
  53. bfa_cb_image_get_size(int type)
  54. {
  55. return bfi_image_ct_cna_size;
  56. }