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: 9136785 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 35A67607D3 for ; Thu, 26 May 2016 08:27:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25B6427D10 for ; Thu, 26 May 2016 08:27:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A9A1282EE; Thu, 26 May 2016 08:27:38 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B1F227D10 for ; Thu, 26 May 2016 08:27:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753258AbcEZI1f (ORCPT ); Thu, 26 May 2016 04:27:35 -0400 Received: from wolverine01.qualcomm.com ([199.106.114.254]:54222 "EHLO wolverine01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751479AbcEZI1R (ORCPT ); Thu, 26 May 2016 04:27:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1464251237; x=1495787237; h=from:to:cc:subject:date:message-id:mime-version; bh=NnCkc3+iMC07aJXEOajR6+YepjxlTMlEFZpBlmvNFLo=; b=UeoWzBnt0W2q9ciQBfrr53W53BszTpxXdLUMgn4eYv6qUlfNFgHNZ9SS NNP8vhCZvzlAEhiXW0YNTj3wNFrAHf0VWRz2wOYZzUvC0y229opjXjKiq 9OT+ZbyEKtOrtvJaMUBxsOkKPxftL2Vfz3uGqYVWiTrOqNYJ8OYn9hB+M U=; X-IronPort-AV: E=Sophos;i="5.26,367,1459839600"; d="scan'208";a="195830019" Received: from ironmsg04-r-new.qualcomm.com (HELO Ironmsg04-R.qualcomm.com) ([10.53.140.108]) by wolverine01.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 May 2016 01:27:16 -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: CC: , , "Mohammed Shafi Shajakhan" , Maharaja Kennadyrajan 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) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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);