Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6276317yba; Wed, 1 May 2019 09:09:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkUmA/MnWp8tdGg5dnW1ix6ykbU1olpcnrh71MpaQu6zORXCnxLddD57ohsqKGOFxNNM25 X-Received: by 2002:a05:6a00:cc:: with SMTP id e12mr20140976pfj.207.1556726953006; Wed, 01 May 2019 09:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556726952; cv=none; d=google.com; s=arc-20160816; b=G9qXFuhT72GR79g1P5dt1xOgVeM8aV3Vu5Gd6mmaZJy58hSZ2SWQS6wGbVEkiJOIy/ a4seRh0IK2AtixYLGbu8Q+oAl2BDB8AX4lqAIeyNPXD7xPbK68wCMaJQiTrtPKRtZe2I JjrTewcTP6PGG8ElvD8Wo+i6wM9kpMXPhm+jhakjl3o5ZvBXiaj8TQxk+BBGgypxfrIH RX2Qq/gU4EUdGVCXbjVXhg640D8ojoFAyxRe4JLiU15Qr99v3vWLUaG3qEiptwR52LER W4Xk1pBZ+RJh/WFRXojKsOrhE+tI/cemTtoFUfdzY/NAPp4uIZjX9WAmv2xjknL4ngcz mnVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3XfuwS9wOW3ejZagvmzyqstBAWswuQqtZoq0b9yXNVc=; b=SfjnOXjQRnzmVy7jXXiw1Mc2c9WkhjvoztmBYbfgA99ocRwfIIVxGdml2LGvZbbi5o ecVmbGYLaHJiGNYOtu0xfLJvarqeUzQu0Xg9wyTweb0mj0aEtayN1KiRMw8/6dG2wDNO CP9VbqU+pZxu6iZPy89syqUm7pBNlIKDoSiJgOrk60sLECsey8Zt5sJIu9KMEuo3eK+U xCUBzjMk5PoqKQV9Ubvn6V1YI0C7+vpGZ+JS4cp21TZqmhvmHdLkIznsgsM2T5elRBlT ddGr1OgfDFRQi7+azufb0O+4XFdT2FNnvJeK82e9n2YXI0YDWuPb9ekTiyUDBu2c8Tss a/4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKIgKPVL; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si41363697pls.12.2019.05.01.09.08.58; Wed, 01 May 2019 09:09:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKIgKPVL; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726952AbfEAQIK (ORCPT + 99 others); Wed, 1 May 2019 12:08:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbfEAQIJ (ORCPT ); Wed, 1 May 2019 12:08:09 -0400 Received: from localhost.localdomain (unknown [151.66.22.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC79420866; Wed, 1 May 2019 16:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556726888; bh=fFYeoJRQWNyPR9/+FW5/vqpZg9B0dwYZOukgsfElaWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xKIgKPVLoeLk+8JW4ntciiEpMnewF6GN1Qk9z9e9WLn2WS289M7N6pNPsxjtfp7cL f3huToNF5UhxnoPTRFk0gypnUUDn7tlezRgoV4Mwc186skFCYU0JLMYx+Ov8IqeIIy HTm7PHAnAk55BUK37Dkee+g0K+kF4dl6Xc/X82nM= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, ryder.lee@mediatek.com, royluo@google.com Subject: [RFC 11/17] mt7615: mcu: unify __mt7615_mcu_set_dev_info and mt7615_mcu_set_dev_info Date: Wed, 1 May 2019 18:07:33 +0200 Message-Id: <6a8e21e2466fcfc468fb9b7c06fb37b02d242ec3.1556726268.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Unify mt7615_mcu_set_dev_info and __mt7615_mcu_set_dev_info since the latter is run just by mt7615_mcu_set_dev_info Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 91 ++++++++----------- .../wireless/mediatek/mt76/mt7615/mt7615.h | 4 +- 2 files changed, 38 insertions(+), 57 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 4d1d4c0bc2e2..c90ae77db22b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -633,68 +633,49 @@ int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter) return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_PM_STATE_CTRL); } -static int __mt7615_mcu_set_dev_info(struct mt7615_dev *dev, - struct dev_info *dev_info) +int mt7615_mcu_set_dev_info(struct mt7615_dev *dev, + struct ieee80211_vif *vif, bool enable) { - struct req_hdr { - u8 omac_idx; - u8 band_idx; - __le16 tlv_num; - u8 is_tlv_append; - u8 rsv[3]; - } __packed req_hdr = {0}; - struct req_tlv { - __le16 tag; - __le16 len; - u8 active; - u8 band_idx; - u8 omac_addr[ETH_ALEN]; - } __packed; - struct sk_buff *skb; - u16 tlv_num = 0; - - skb = mt7615_mcu_msg_alloc(NULL, sizeof(req_hdr) + - sizeof(struct req_tlv)); - skb_reserve(skb, sizeof(req_hdr)); - - if (dev_info->feature & BIT(DEV_INFO_ACTIVE)) { - struct req_tlv req_tlv = { + struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; + struct { + struct req_hdr { + u8 omac_idx; + u8 band_idx; + __le16 tlv_num; + u8 is_tlv_append; + u8 rsv[3]; + } __packed hdr; + struct req_tlv { + __le16 tag; + __le16 len; + u8 active; + u8 band_idx; + u8 omac_addr[ETH_ALEN]; + } __packed tlv; + } data = { + .hdr = { + .omac_idx = mvif->omac_idx, + .band_idx = mvif->band_idx, + .tlv_num = cpu_to_le16(1), + .is_tlv_append = 1, + }, + .tlv = { .tag = cpu_to_le16(DEV_INFO_ACTIVE), - .len = cpu_to_le16(sizeof(req_tlv)), - .active = dev_info->enable, - .band_idx = dev_info->band_idx, - }; - memcpy(req_tlv.omac_addr, dev_info->omac_addr, ETH_ALEN); - memcpy(skb_put(skb, sizeof(req_tlv)), &req_tlv, - sizeof(req_tlv)); - tlv_num++; - } - - req_hdr.omac_idx = dev_info->omac_idx; - req_hdr.band_idx = dev_info->band_idx; - req_hdr.tlv_num = cpu_to_le16(tlv_num); - req_hdr.is_tlv_append = tlv_num ? 1 : 0; + .len = cpu_to_le16(sizeof(struct req_tlv)), + .active = enable, + .band_idx = mvif->band_idx, + }, + }; + struct sk_buff *skb; - memcpy(skb_push(skb, sizeof(req_hdr)), &req_hdr, sizeof(req_hdr)); + memcpy(data.tlv.omac_addr, vif->addr, ETH_ALEN); + skb = mt7615_mcu_msg_alloc(&data, sizeof(data)); + if (!skb) + return -ENOMEM; return mt7615_mcu_msg_send(dev, skb, MCU_EXT_CMD_DEV_INFO_UPDATE); } -int mt7615_mcu_set_dev_info(struct mt7615_dev *dev, struct ieee80211_vif *vif, - int en) -{ - struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; - struct dev_info dev_info = {0}; - - dev_info.omac_idx = mvif->omac_idx; - memcpy(dev_info.omac_addr, vif->addr, ETH_ALEN); - dev_info.band_idx = mvif->band_idx; - dev_info.enable = en; - dev_info.feature = BIT(DEV_INFO_ACTIVE); - - return __mt7615_mcu_set_dev_info(dev, &dev_info); -} - static void bss_info_omac_handler (struct mt7615_dev *dev, struct bss_info *bss_info, struct sk_buff *skb) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index 81501cb64f1f..e19739f9668b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -108,8 +108,8 @@ int mt7615_eeprom_init(struct mt7615_dev *dev); int mt7615_dma_init(struct mt7615_dev *dev); void mt7615_dma_cleanup(struct mt7615_dev *dev); int mt7615_mcu_init(struct mt7615_dev *dev); -int mt7615_mcu_set_dev_info(struct mt7615_dev *dev, struct ieee80211_vif *vif, - int en); +int mt7615_mcu_set_dev_info(struct mt7615_dev *dev, + struct ieee80211_vif *vif, bool enable); int mt7615_mcu_set_bss_info(struct mt7615_dev *dev, struct ieee80211_vif *vif, int en); int mt7615_mcu_set_wtbl_key(struct mt7615_dev *dev, int wcid, -- 2.20.1