Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[pandora-kernel.git] / drivers / net / bna / cna_fwimg.c
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
21 const struct firmware *bfi_fw;
22 static u32 *bfi_image_ct_cna;
23 static u32 bfi_image_ct_cna_size;
24
25 static u32 *
26 cna_read_firmware(struct pci_dev *pdev, u32 **bfi_image,
27                         u32 *bfi_image_size, char *fw_name)
28 {
29         const struct firmware *fw;
30
31         if (request_firmware(&fw, fw_name, &pdev->dev)) {
32                 pr_alert("Can't locate firmware %s\n", fw_name);
33                 goto error;
34         }
35
36         *bfi_image = (u32 *)fw->data;
37         *bfi_image_size = fw->size/sizeof(u32);
38         bfi_fw = fw;
39
40         return *bfi_image;
41 error:
42         return NULL;
43 }
44
45 u32 *
46 cna_get_firmware_buf(struct pci_dev *pdev)
47 {
48         if (bfi_image_ct_cna_size == 0)
49                 cna_read_firmware(pdev, &bfi_image_ct_cna,
50                         &bfi_image_ct_cna_size, CNA_FW_FILE_CT);
51         return bfi_image_ct_cna;
52 }
53
54 u32 *
55 bfa_cb_image_get_chunk(int type, u32 off)
56 {
57         return (u32 *)(bfi_image_ct_cna + off);
58 }
59
60 u32
61 bfa_cb_image_get_size(int type)
62 {
63         return bfi_image_ct_cna_size;
64 }