From patchwork Mon Sep 4 07:34:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wright Feng X-Patchwork-Id: 9936761 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 5980D603F9 for ; Mon, 4 Sep 2017 07:31:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B1C928757 for ; Mon, 4 Sep 2017 07:31:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49B932876A; Mon, 4 Sep 2017 07:31:01 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 1764328775 for ; Mon, 4 Sep 2017 07:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753290AbdIDHa3 (ORCPT ); Mon, 4 Sep 2017 03:30:29 -0400 Received: from smtp1.cypress.com ([157.95.67.100]:60013 "EHLO smtp1.cypress.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949AbdIDHa2 (ORCPT ); Mon, 4 Sep 2017 03:30:28 -0400 Received: from corpmail1.cypress.com (corpmail1.mis.cypress.com [172.16.5.228]) by smtp1.cypress.com (8.13.8/8.13.8) with ESMTP id v847UNiX017080; Mon, 4 Sep 2017 00:30:23 -0700 Received: from mailhost.mis.cypress.com (mailhost [172.16.2.5]) by corpmail1.cypress.com (8.14.4/8.14.4) with ESMTP id v847UNDW011784; Mon, 4 Sep 2017 00:30:23 -0700 Received: from localhost ([10.240.113.31]) by mailhost.mis.cypress.com (8.12.11/8.12.11) with ESMTP id v847ULSs014712; Mon, 4 Sep 2017 00:30:22 -0700 (PDT) From: Wright Feng To: arend.vanspriel@broadcom.com, franky.lin@broadcom.com, hante.meuleman@broadcom.com, kvalo@codeaurora.org, chi-hsien.lin@cypress.com Cc: wright.feng@cypress.com, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com Subject: [PATCH] brcmfmac: return -EPERM when getting error in vendor command handler Date: Mon, 4 Sep 2017 15:34:33 +0800 Message-Id: <1504510473-13549-1-git-send-email-wright.feng@cypress.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-Virus-Scanned: ClamAV using ClamSMTP Firmware returns proprietary error code when getting error in fil_cmd_data_set or fil_cmd_data_get. The vendor tools or utilities which uses libnl may stuck in some commands when wl is down. For example, issue "scan" command after issuing "down" command, the "scan" command will be the blocking call and stuck as no response from libnl. It is caused by that firmware returns BCME_NOTUP(-4) when wl is down, but the -4 is -EINTR in Linux kernel, so libnl catches the error and not passes to upper layer. Because of that, the driver should return Linux error code instead of the proprietary error code, and the tools or utilities need to get the real firmware error code by command "bcmerror" or "bcmerrorstr" after receiving the error. Signed-off-by: Wright Feng --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c index 8eff275..2b88ba1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c @@ -80,8 +80,12 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy, else ret = brcmf_fil_cmd_data_get(ifp, cmdhdr->cmd, dcmd_buf, ret_len); - if (ret != 0) + + if (ret != 0) { + brcmf_dbg(INFO, "error(%d), return -EPERM\n", ret); + ret = -EPERM; goto exit; + } wr_pointer = dcmd_buf; while (ret_len > 0) {