From patchwork Tue Mar 3 04:24:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fred.chou.nd@gmail.com X-Patchwork-Id: 5919751 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 960529F691 for ; Tue, 3 Mar 2015 04:21:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0BE32024F for ; Tue, 3 Mar 2015 04:21:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8D5B2026C for ; Tue, 3 Mar 2015 04:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754104AbbCCEUv (ORCPT ); Mon, 2 Mar 2015 23:20:51 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:41949 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751556AbbCCEUt (ORCPT ); Mon, 2 Mar 2015 23:20:49 -0500 Received: by pablj1 with SMTP id lj1so14202739pab.8; Mon, 02 Mar 2015 20:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=aJtb43m5sD0NdYpYxLG+qLyj+WZ8Cq9/KBDuVgww210=; b=Yjq/bq7T18MSydz0MHa14x+4r6iuLNMeFTiW2DjJBrBeb72O3De6kQO1IZYeIPnPxX gccmEWvU0tn8FbYgbU/r6e4dXWl69Lh86VWod1y9Tr8bw+btKXEzWzELubrCqfe6EicI YTKs8TMntWJanLbxDR+9FFBDd7mNpFjYD0YvWWM2UzW6qBSQKrcgdwqX7S9GugAR5wSY gJUrU/FhN6B+Pm4PonPBnzRrGK9qVLAu4rUkm9oFwLXUysyEK9Lz7PX0MFGhf/+BcMA+ pjyvkLH0Axgb4rEM2iEuzqXpeKrlTbrVoUtPF85tlaOIKMcpBUA0d/LyBP+8YL3jFF6k /faQ== X-Received: by 10.68.136.167 with SMTP id qb7mr51743854pbb.155.1425356449330; Mon, 02 Mar 2015 20:20:49 -0800 (PST) Received: from fred-EP43-DS3L.a-star.edu.sg ([192.122.131.10]) by mx.google.com with ESMTPSA id vl1sm13367577pbc.62.2015.03.02.20.20.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Mar 2015 20:20:48 -0800 (PST) From: Fred Chou X-Google-Original-From: Fred Chou To: ath9k-devel@qca.qualcomm.com, kvalo@codeaurora.org, linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Fred Chou Subject: [PATCH] ath9k_htc: avoid memcpy when downloading firmware Date: Tue, 3 Mar 2015 12:24:03 +0800 Message-Id: <1425356643-2707-1-git-send-email-fred.chou.nd@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fred Chou The temporary buffer to hold firmware data is not really needed, and memcpy can be avoided by using data pointer instead. Signed-off-by: Fred Chou --- drivers/net/wireless/ath/ath9k/hif_usb.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c index 10c02f5..0bc35a8 100644 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c @@ -986,30 +986,22 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) const void *data = hif_dev->fw_data; size_t len = hif_dev->fw_size; u32 addr = AR9271_FIRMWARE; - u8 *buf = kzalloc(4096, GFP_KERNEL); u32 firm_offset; - if (!buf) - return -ENOMEM; - while (len) { transfer = min_t(size_t, len, 4096); - memcpy(buf, data, transfer); err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0), FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT, - addr >> 8, 0, buf, transfer, HZ); - if (err < 0) { - kfree(buf); + addr >> 8, 0, data, transfer, HZ); + if (err < 0) return err; - } len -= transfer; data += transfer; addr += transfer; } - kfree(buf); if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info)) firm_offset = AR7010_FIRMWARE_TEXT;