aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2007-09-30 20:56:49 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:53:57 -0400
commit8336793baf962163c9fab5a3f39614295fdbab27 (patch)
tree6940426f8880928444e227d43085ca3d2fbfba80 /drivers/net/bnx2.c
parentb3448b0bde5f1a858397fe791f76632e978a1dc8 (diff)
[ZLIB]: Move bnx2 driver gzip unpacker into zlib.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Acked-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c48
1 files changed, 3 insertions, 45 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 73d4a579790c..6d6ea56fe384 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2761,48 +2761,6 @@ bnx2_set_rx_mode(struct net_device *dev)
2761 spin_unlock_bh(&bp->phy_lock); 2761 spin_unlock_bh(&bp->phy_lock);
2762} 2762}
2763 2763
2764/* To be moved to generic lib/ */
2765static int
2766bnx2_gunzip(void *gunzip_buf, unsigned sz, u8 *zbuf, int len)
2767{
2768 struct z_stream_s *strm;
2769 int rc;
2770
2771 /* gzip header (1f,8b,08... 10 bytes total + possible asciz filename)
2772 * is stripped */
2773
2774 rc = -ENOMEM;
2775 strm = kmalloc(sizeof(*strm), GFP_KERNEL);
2776 if (strm == NULL)
2777 goto gunzip_nomem2;
2778 strm->workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
2779 if (strm->workspace == NULL)
2780 goto gunzip_nomem3;
2781
2782 strm->next_in = zbuf;
2783 strm->avail_in = len;
2784 strm->next_out = gunzip_buf;
2785 strm->avail_out = sz;
2786
2787 rc = zlib_inflateInit2(strm, -MAX_WBITS);
2788 if (rc == Z_OK) {
2789 rc = zlib_inflate(strm, Z_FINISH);
2790 /* after Z_FINISH, only Z_STREAM_END is "we unpacked it all" */
2791 if (rc == Z_STREAM_END)
2792 rc = sz - strm->avail_out;
2793 else
2794 rc = -EINVAL;
2795 zlib_inflateEnd(strm);
2796 } else
2797 rc = -EINVAL;
2798
2799 kfree(strm->workspace);
2800gunzip_nomem3:
2801 kfree(strm);
2802gunzip_nomem2:
2803 return rc;
2804}
2805
2806static void 2764static void
2807load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len, 2765load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
2808 u32 rv2p_proc) 2766 u32 rv2p_proc)
@@ -2858,7 +2816,7 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2858 text = vmalloc(FW_BUF_SIZE); 2816 text = vmalloc(FW_BUF_SIZE);
2859 if (!text) 2817 if (!text)
2860 return -ENOMEM; 2818 return -ENOMEM;
2861 rc = bnx2_gunzip(text, FW_BUF_SIZE, fw->gz_text, fw->gz_text_len); 2819 rc = zlib_inflate_blob(text, FW_BUF_SIZE, fw->gz_text, fw->gz_text_len);
2862 if (rc < 0) { 2820 if (rc < 0) {
2863 vfree(text); 2821 vfree(text);
2864 return rc; 2822 return rc;
@@ -2935,14 +2893,14 @@ bnx2_init_cpus(struct bnx2 *bp)
2935 text = vmalloc(FW_BUF_SIZE); 2893 text = vmalloc(FW_BUF_SIZE);
2936 if (!text) 2894 if (!text)
2937 return -ENOMEM; 2895 return -ENOMEM;
2938 rc = bnx2_gunzip(text, FW_BUF_SIZE, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1)); 2896 rc = zlib_inflate_blob(text, FW_BUF_SIZE, bnx2_rv2p_proc1, sizeof(bnx2_rv2p_proc1));
2939 if (rc < 0) { 2897 if (rc < 0) {
2940 vfree(text); 2898 vfree(text);
2941 goto init_cpu_err; 2899 goto init_cpu_err;
2942 } 2900 }
2943 load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC1); 2901 load_rv2p_fw(bp, text, rc /* == len */, RV2P_PROC1);
2944 2902
2945 rc = bnx2_gunzip(text, FW_BUF_SIZE, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2)); 2903 rc = zlib_inflate_blob(text, FW_BUF_SIZE, bnx2_rv2p_proc2, sizeof(bnx2_rv2p_proc2));
2946 if (rc < 0) { 2904 if (rc < 0) {
2947 vfree(text); 2905 vfree(text);
2948 goto init_cpu_err; 2906 goto init_cpu_err;