From patchwork Sun Sep 9 20:32:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10593423 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 0BAFB13BB for ; Sun, 9 Sep 2018 20:33:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B7B28451 for ; Sun, 9 Sep 2018 20:32:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E61FF28534; Sun, 9 Sep 2018 20:32:59 +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 CD37C28521 for ; Sun, 9 Sep 2018 20:32:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbeIJBXu (ORCPT ); Sun, 9 Sep 2018 21:23:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46742 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbeIJBXt (ORCPT ); Sun, 9 Sep 2018 21:23:49 -0400 Received: by mail-wr1-f66.google.com with SMTP id a108-v6so19725685wrc.13 for ; Sun, 09 Sep 2018 13:32:56 -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=0YRXia5BMsG3NGaBH4UFOy4Y2mIbsEamlijwF522L4M=; b=NmacsZ71HhiiJeNtjIwrAOCFYxBTbA2TPfBmbsLD7N0FLoGf+sdfZUT4tXUzVoPFHk 5guAPZwmWHm8smjycuvGfYoO3QhB04yIyLUcM7uoKuxFgZ4AFkhwpz8wIemyP8oC7sYz 4A8RzgrOQk036IicGNRoyq6801XYr5epIXwVubLFUe0D5DeLKgAsXadY8ugc/9Wogtyu ZHE8iGHsmI1oRDTs3An6gz3khFNWJOiyY5fCtrgYT/fRF5mIHHZG8ot0rk9s3NK9bJuX 4PYylOfyD6l+kcPftsqd5e3rkaVpyfv7QAo5EjPfEfIuWrUVHRqFvV3srDF8BQYvXufF lvUw== X-Gm-Message-State: APzg51AOovGvQUz+kCCFMOuFI2OI9x10lxAl9MYSdWg6l/qxZPPrYKiS Ht8djBRGD443mWv80EJPINcZhw== X-Google-Smtp-Source: ANB0VdZ20RxosgzTLW6RhtMA77F1LSBiecIF0/67ZfMry7/REX9Ah5sWk1y6M5rXUm50iKRZvu/JGA== X-Received: by 2002:adf:f391:: with SMTP id m17-v6mr13208225wro.279.1536525175499; Sun, 09 Sep 2018 13:32:55 -0700 (PDT) Received: from localhost.localdomain ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id y184-v6sm13652006wmg.17.2018.09.09.13.32.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 13:32:54 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH 02/11] mt76: add mt76_mcu_ops data structure for mcu related pointers Date: Sun, 9 Sep 2018 22:32:37 +0200 Message-Id: <20180909203246.21608-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 Introduce mt76_mcu_ops data structure to contain mcu related function pointers. This is a preliminary patch to move mt76x02 usb mcu code in mt76x02-usb module Acked-by: Stanislaw Gruszka Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76.h | 11 +++++++++++ drivers/net/wireless/mediatek/mt76/usb.c | 1 + drivers/net/wireless/mediatek/mt76/usb_mcu.c | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 80390be041cb..d36ffc030b15 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -118,6 +118,12 @@ struct mt76_queue { struct sk_buff *rx_head; }; +struct mt76_mcu_ops { + struct sk_buff *(*mcu_msg_alloc)(const void *data, int len); + int (*mcu_send_msg)(struct mt76_dev *dev, struct sk_buff *skb, + int cmd, bool wait_resp); +}; + struct mt76_queue_ops { int (*init)(struct mt76_dev *dev); @@ -335,6 +341,7 @@ struct mt76_dev { const struct mt76_bus_ops *bus; const struct mt76_driver_ops *drv; + const struct mt76_mcu_ops *mcu_ops; void __iomem *regs; struct device *dev; @@ -435,6 +442,9 @@ struct mt76_rx_status { #define mt76_rmw(dev, ...) (dev)->mt76.bus->rmw(&((dev)->mt76), __VA_ARGS__) #define mt76_wr_copy(dev, ...) (dev)->mt76.bus->copy(&((dev)->mt76), __VA_ARGS__) +#define mt76_mcu_msg_alloc(dev, ...) (dev)->mt76.mcu_ops->mcu_msg_alloc(__VA_ARGS__) +#define mt76_mcu_send_msg(dev, ...) (dev)->mt76.mcu_ops->mcu_send_msg(&((dev)->mt76), __VA_ARGS__) + #define mt76_set(dev, offset, val) mt76_rmw(dev, offset, 0, val) #define mt76_clear(dev, offset, val) mt76_rmw(dev, offset, val, 0) @@ -642,5 +652,6 @@ int mt76u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, void mt76u_mcu_fw_reset(struct mt76_dev *dev); int mt76u_mcu_init_rx(struct mt76_dev *dev); void mt76u_mcu_deinit(struct mt76_dev *dev); +void mt76u_init_mcu_ops(struct mt76_dev *dev); #endif diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index 5785e54c32d0..5d568c910979 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -836,6 +836,7 @@ int mt76u_init(struct mt76_dev *dev, mutex_init(&usb->usb_ctrl_mtx); dev->bus = &mt76u_ops; dev->queue_ops = &usb_queue_ops; + mt76u_init_mcu_ops(dev); return mt76u_set_endpoints(intf, usb); } diff --git a/drivers/net/wireless/mediatek/mt76/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/usb_mcu.c index d80dbfafba6d..4cce807ec24e 100644 --- a/drivers/net/wireless/mediatek/mt76/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/usb_mcu.c @@ -296,3 +296,13 @@ void mt76u_mcu_deinit(struct mt76_dev *dev) mt76u_buf_free(&usb->mcu.res); } EXPORT_SYMBOL_GPL(mt76u_mcu_deinit); + +void mt76u_init_mcu_ops(struct mt76_dev *dev) +{ + static const struct mt76_mcu_ops mt76u_mcu_ops = { + .mcu_msg_alloc = mt76u_mcu_msg_alloc, + .mcu_send_msg = mt76u_mcu_send_msg, + }; + + dev->mcu_ops = &mt76u_mcu_ops; +}