From patchwork Thu May 26 08:27:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Shafi Shajakhan X-Patchwork-Id: 9136787 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C4125607D3 for ; Thu, 26 May 2016 08:27:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC3A027D10 for ; Thu, 26 May 2016 08:27:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0B06282F0; Thu, 26 May 2016 08:27:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4217127D10 for ; Thu, 26 May 2016 08:27:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5qdo-0005aA-32; Thu, 26 May 2016 08:27:40 +0000 Received: from wolverine02.qualcomm.com ([199.106.114.251]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5qdl-0005Y0-Fb for ath10k@lists.infradead.org; Thu, 26 May 2016 08:27:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1464251256; x=1495787256; h=from:to:cc:subject:date:message-id:mime-version; bh=NnCkc3+iMC07aJXEOajR6+YepjxlTMlEFZpBlmvNFLo=; b=HL3ty0he6SzYnputwPg2G+Y/TNAZAwdaNpyH0Q5ZVg1jLgemR7cYAHZg QRB924Qs7jfN+2Sxm8wTe16shOGZri0apI/4+1sJ2JaDjdR2bYMtPD9LK T/J3iJMU6uT5UCK6kPx/9TYTkgSYHj/EpQ/3nvK/eAGA2yuNrhA8kVBF5 Y=; X-IronPort-AV: E=Sophos;i="5.26,367,1459839600"; d="scan'208";a="290989036" Received: from ironmsg04-r-new.qualcomm.com (HELO Ironmsg04-R.qualcomm.com) ([10.53.140.108]) by wolverine02.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 May 2016 01:27:15 -0700 From: Mohammed Shafi Shajakhan X-IronPort-AV: E=McAfee;i="5700,7163,8176"; a="1203875887" Received: from nasanexm01h.na.qualcomm.com ([10.85.0.34]) by Ironmsg04-R.qualcomm.com with ESMTP/TLS/RC4-SHA; 26 May 2016 01:27:16 -0700 Received: from aphydexm01b.ap.qualcomm.com (10.252.127.11) by NASANEXM01H.na.qualcomm.com (10.85.0.34) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 26 May 2016 01:27:14 -0700 Received: from qcmail1.qualcomm.com (10.80.80.8) by aphydexm01b.ap.qualcomm.com (10.252.127.11) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Thu, 26 May 2016 13:57:02 +0530 Received: by qcmail1.qualcomm.com (sSMTP sendmail emulation); Thu, 26 May 2016 13:57:44 +0530 To: Subject: [PATCH] ath10k: Fix error while writing 'simulate_fw_crash' debugfs Date: Thu, 26 May 2016 13:57:42 +0530 Message-ID: <1464251262-4889-1-git-send-email-mohammed@qca.qualcomm.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01C.na.qualcomm.com (10.85.0.83) To aphydexm01b.ap.qualcomm.com (10.252.127.11) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160526_012737_625937_9642601C X-CRM114-Status: GOOD ( 11.95 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mohammed@codeaurora.org, Maharaja Kennadyrajan , linux-wireless@vger.kernel.org, Mohammed Shafi Shajakhan Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mohammed Shafi Shajakhan Fix invalid argument error while writing 'simulate_fw_crash', though the funcionality is working fine we get an error 'invalid argument' because 'count' value is not returned properly (no reason to reduce the count value for removing the newline) Fixes the below write error: /sys/kernel/debug/ieee80211/phy0/ath10k# echo hw-restart > simulate_fw_crash -bash: echo: write error: Invalid argument Also move the 'conf_mutex' as it is really not required for fetching the userspace buffer. Reported-by: Maharaja Kennadyrajan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: Maharaja Kennadyrajan --- drivers/net/wireless/ath/ath10k/debug.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index e251155..54cb629 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -609,25 +609,23 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file, char buf[32]; int ret; - mutex_lock(&ar->conf_mutex); - simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); /* make sure that buf is null terminated */ buf[sizeof(buf) - 1] = 0; + /* drop the possible '\n' from the end */ + if (buf[count - 1] == '\n') + buf[count - 1] = 0; + + mutex_lock(&ar->conf_mutex); + if (ar->state != ATH10K_STATE_ON && ar->state != ATH10K_STATE_RESTARTED) { ret = -ENETDOWN; goto exit; } - /* drop the possible '\n' from the end */ - if (buf[count - 1] == '\n') { - buf[count - 1] = 0; - count--; - } - if (!strcmp(buf, "soft")) { ath10k_info(ar, "simulating soft firmware crash\n"); ret = ath10k_wmi_force_fw_hang(ar, WMI_FORCE_FW_HANG_ASSERT, 0);