From patchwork Tue Mar 18 14:45:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Grumbach X-Patchwork-Id: 3853861 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0F13D9F369 for ; Wed, 19 Mar 2014 17:47:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 220C920131 for ; Wed, 19 Mar 2014 17:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09F4A200DF for ; Wed, 19 Mar 2014 17:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755924AbaCROpt (ORCPT ); Tue, 18 Mar 2014 10:45:49 -0400 Received: from mail-ee0-f52.google.com ([74.125.83.52]:47608 "EHLO mail-ee0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754380AbaCROpr (ORCPT ); Tue, 18 Mar 2014 10:45:47 -0400 Received: by mail-ee0-f52.google.com with SMTP id e49so5474358eek.11 for ; Tue, 18 Mar 2014 07:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dvDKszhuIcOVqJoOih2U1ST5thu7NALP1gqNs2omkoI=; b=ukzrtyftiGdLHtF1vOxVjqKiSsAQYycqVOyMI90Rc0GNeZ08Ht8JchqchfZt6tDz1l VfKnKu1nU4UELnVhlSIXQqSqpAaTp6YAyLpF4j0TW1zbuPDTD4ce/tz2pMY/8qTgLjPr vxUX8Tz5kCfJ0m4KNs6mCBZelRKVfKbQFN7iQP6fk6OFgvGujXJVoEPgX21sL9I/SlKi DUl8ailx+CmZdEHoaaZ9sqifopXVBtygDcRXGJBHkq2lA8c7Gr1/4JQylrWbjW+L2A9T wkj19Qeo7ETZM9pnT/ErlsspTGhlvaOxvUrO7FswCV2D621edQjvWVI8VRH46yTE4QQT xfcA== X-Received: by 10.14.180.2 with SMTP id i2mr30660545eem.53.1395153946821; Tue, 18 Mar 2014 07:45:46 -0700 (PDT) Received: from localhost.localdomain (109-186-95-36.bb.netvision.net.il. [109.186.95.36]) by mx.google.com with ESMTPSA id p8sm35492776eef.26.2014.03.18.07.45.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Mar 2014 07:45:45 -0700 (PDT) From: Emmanuel Grumbach To: linux-wireless@vger.kernel.org Cc: Eyal Shapira , Eyal Shapira , Emmanuel Grumbach Subject: [PATCH 03/35] iwlwifi: mvm: cleanups in iwl_dbgfs_frame_stats_read Date: Tue, 18 Mar 2014 16:45:07 +0200 Message-Id: <1395153939-23897-3-git-send-email-egrumbach@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <53285AF8.7050305@gmail.com> References: <53285AF8.7050305@gmail.com> 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: Eyal Shapira Switch pos to char * which makes the code a bit shorter as well as other minor cleanups suggested by Joe Perches. Signed-off-by: Eyal Shapira Reviewed-by: Johannes Berg Signed-off-by: Emmanuel Grumbach --- drivers/net/wireless/iwlwifi/mvm/debugfs.c | 34 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c index 41c6370..e3b42b4 100644 --- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c @@ -536,56 +536,60 @@ static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm, loff_t *ppos, struct iwl_mvm_frame_stats *stats) { - char *buff; - int pos = 0, idx, i; + char *buff, *pos, *endpos; + int idx, i; int ret; - size_t bufsz = 1024; + static const size_t bufsz = 1024; buff = kmalloc(bufsz, GFP_KERNEL); if (!buff) return -ENOMEM; spin_lock_bh(&mvm->drv_stats_lock); - pos += scnprintf(buff + pos, bufsz - pos, + + pos = buff; + endpos = pos + bufsz; + + pos += scnprintf(pos, endpos - pos, "Legacy/HT/VHT\t:\t%d/%d/%d\n", stats->legacy_frames, stats->ht_frames, stats->vht_frames); - pos += scnprintf(buff + pos, bufsz - pos, "20/40/80\t:\t%d/%d/%d\n", + pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n", stats->bw_20_frames, stats->bw_40_frames, stats->bw_80_frames); - pos += scnprintf(buff + pos, bufsz - pos, "NGI/SGI\t\t:\t%d/%d\n", + pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n", stats->ngi_frames, stats->sgi_frames); - pos += scnprintf(buff + pos, bufsz - pos, "SISO/MIMO2\t:\t%d/%d\n", + pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n", stats->siso_frames, stats->mimo2_frames); - pos += scnprintf(buff + pos, bufsz - pos, "FAIL/SCSS\t:\t%d/%d\n", + pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n", stats->fail_frames, stats->success_frames); - pos += scnprintf(buff + pos, bufsz - pos, "MPDUs agg\t:\t%d\n", + pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n", stats->agg_frames); - pos += scnprintf(buff + pos, bufsz - pos, "A-MPDUs\t\t:\t%d\n", + pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n", stats->ampdu_count); - pos += scnprintf(buff + pos, bufsz - pos, "Avg MPDUs/A-MPDU:\t%d\n", + pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n", stats->ampdu_count > 0 ? (stats->agg_frames / stats->ampdu_count) : 0); - pos += scnprintf(buff + pos, bufsz - pos, "Last Rates\n"); + pos += scnprintf(pos, endpos - pos, "Last Rates\n"); idx = stats->last_frame_idx - 1; for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) { idx = (idx + 1) % ARRAY_SIZE(stats->last_rates); if (stats->last_rates[idx] == 0) continue; - pos += scnprintf(buff + pos, bufsz - pos, "Rate[%d]: ", + pos += scnprintf(pos, endpos - pos, "Rate[%d]: ", (int)(ARRAY_SIZE(stats->last_rates) - i)); - pos += rs_pretty_print_rate(buff + pos, stats->last_rates[idx]); + pos += rs_pretty_print_rate(pos, stats->last_rates[idx]); } spin_unlock_bh(&mvm->drv_stats_lock); - ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos); + ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff); kfree(buff); return ret;