From patchwork Sat Aug 25 10:40:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10576061 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-2.web.codeaurora.org (Postfix) with ESMTP id 5984914BD for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481072AEE7 for ; Sat, 25 Aug 2018 10:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C8422AF1F; Sat, 25 Aug 2018 10:41:09 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 B987B2AEE7 for ; Sat, 25 Aug 2018 10:41:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbeHYOTj (ORCPT ); Sat, 25 Aug 2018 10:19:39 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36973 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbeHYOTj (ORCPT ); Sat, 25 Aug 2018 10:19:39 -0400 Received: by mail-wm0-f65.google.com with SMTP id n11-v6so3849615wmc.2 for ; Sat, 25 Aug 2018 03:41:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4xBbERyQOtISFMnh9oSyb9XM7lpJ6qdF/QTvEzQL7cc=; b=j5CN8mHfzVHAX13Iud1s9cjpMDjZS+z1Z9wwUMviOOXJVbYHZSfMP06p8AncvZ4aO4 TbYPYt/P0hHvtdPFNiWkHdR1W82Vyvr9nQl9YRPnZb0EFtgYVZn70GmWvYP/zB/k1Ujd AXmMshszEnbhD4ErTizmgdgfFHiKAQqv5nsbOXyJoRBh2hsabXMX3Q0Uv+QvfVwNb/KV h3isEZEPG3DlVbWyG+uBcbeAFj/kp7LWwK4XsFU/Ah3D1JIR0QHltEpUkf8TqTS4ERqd N6T7qAioHLe8sJthHNWQQyswweryAlR78U0Rv6f+XjDcyzrXo0+1i1fdR+C6FplUtQbR uWEg== X-Gm-Message-State: APzg51AP1G/4jPmsy0u9xe5UtY2lzbd2OzPBYlmdl8Xx6IVPXq9vj7xg 0bxG/lg+VKLY8zZt0l6u0EZ80Q== X-Google-Smtp-Source: ANB0Vdb/6vpW17BpsuYf7EUzRKh+VAA3Zw4nwCBSU/KfhokcDvFT2+lsxu2+aZQbJVDSsGGIRoAT/w== X-Received: by 2002:a1c:1092:: with SMTP id 140-v6mr859326wmq.120.1535193664009; Sat, 25 Aug 2018 03:41:04 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id l18-v6sm16391708wru.75.2018.08.25.03.41.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Aug 2018 03:41:03 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 02/16] mt76: split __mt76u_mcu_send_msg and mt76u_mcu_send_msg routines Date: Sat, 25 Aug 2018 12:40:42 +0200 Message-Id: <20180825104056.9130-3-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.18.0 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 Split __mt76u_mcu_send_msg and mt76u_mcu_send_msg in order to be reused by mt76x0 driver in usb mcu layer unification between mt76x0 and mt76x2u drivers Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ drivers/net/wireless/mediatek/mt76/usb_mcu.c | 27 +++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index fc27260080af..5579b90afee9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -623,6 +623,8 @@ int mt76u_mcu_fw_send_data(struct mt76_dev *dev, const void *data, int data_len, u32 max_payload, u32 offset); void mt76u_mcu_complete_urb(struct urb *urb); struct sk_buff *mt76u_mcu_msg_alloc(const void *data, int len); +int __mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, + int cmd, bool wait_resp); int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, int cmd, bool wait_resp); void mt76u_mcu_fw_reset(struct mt76_dev *dev); diff --git a/drivers/net/wireless/mediatek/mt76/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/usb_mcu.c index ebf3e7ffb26b..4039b0b709a0 100644 --- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c @@ -86,8 +86,8 @@ static int mt76u_mcu_wait_resp(struct mt76_dev *dev, u8 seq) return -ETIMEDOUT; } -int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, - int cmd, bool wait_resp) +int __mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, + int cmd, bool wait_resp) { struct usb_interface *intf = to_usb_interface(dev->dev); struct usb_device *udev = interface_to_usbdev(intf); @@ -100,8 +100,6 @@ int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, if (test_bit(MT76_REMOVED, &dev->state)) return 0; - mutex_lock(&usb->mcu.mutex); - pipe = usb_sndbulkpipe(udev, usb->out_ep[MT_EP_OUT_INBAND_CMD]); if (wait_resp) { seq = ++usb->mcu.msg_seq & 0xf; @@ -114,22 +112,33 @@ int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, MT_MCU_MSG_TYPE_CMD; ret = mt76u_skb_dma_info(skb, CPU_TX_PORT, info); if (ret) - goto out; + return ret; ret = usb_bulk_msg(udev, pipe, skb->data, skb->len, &sent, 500); if (ret) - goto out; + return ret; if (wait_resp) ret = mt76u_mcu_wait_resp(dev, seq); -out: - mutex_unlock(&usb->mcu.mutex); - consume_skb(skb); return ret; } +EXPORT_SYMBOL_GPL(__mt76u_mcu_send_msg); + +int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, + int cmd, bool wait_resp) +{ + struct mt76_usb *usb = &dev->usb; + int err; + + mutex_lock(&usb->mcu.mutex); + err = __mt76u_mcu_send_msg(dev, skb, cmd, wait_resp); + mutex_unlock(&usb->mcu.mutex); + + return err; +} EXPORT_SYMBOL_GPL(mt76u_mcu_send_msg); void mt76u_mcu_fw_reset(struct mt76_dev *dev)