Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp392617ybi; Fri, 7 Jun 2019 09:44:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxOicOG9egWXmxy8cfuQ8hFRRvCzUucYaqs/XcLW19u8ljt5HUnkd0s07YpWP2QAx4OR8p X-Received: by 2002:a65:60d9:: with SMTP id r25mr3716021pgv.228.1559925876672; Fri, 07 Jun 2019 09:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559925876; cv=none; d=google.com; s=arc-20160816; b=GHApBEVDKq4a3rMfBw7a1uKd6+Y0aVfdDSYoNU3G3cQaEjL8freu/Cdp9KCiZbOkO8 ypeLHGAgJpftmRqCrFyV+Hu3xDVtN1/ItWA1ZuUVnwjt5PoappJ87QYwO68BsIh+Gdx/ IIs5Z+NSyq0IzqJ0cMuaqTAb+SVknfE79BvTEXa5wuuli0qNmaLlRK8YDZtyRJNP0m5q DUrrofUzyY+CuBB84KSQfA3rc6DZb2s87JjrIk3+RdVYQR1tm5ITHSejjLpsesGaGk0O Nr1k2OZgvv5NjGZzTDz7MPuZI1jes7x35L8+Mr38yCRy4CgHyi0U3Esxl5INk0pV2kX4 MdXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature; bh=ztfmCLh7/+hc7Bz5FdvHk4iOr4N3Xc+lH4FXCpCceBI=; b=NRUyXIBqm+SjFw0JiDAcE7he5SaOHv/kgOQdP3Mu/byZS2mFyQfZkSMf0KDAwcfqVv vZMTQbns709dTtGjOh5bdSxhkfVmTfOrOxST8v8paL6TNclD72niXxsU3lzky/rrq367 wodC30i5zT8J1oppPlD8HL+ojAFKmhqX+pUQAXF+exgu7ZSjI4NXsilPrU6bW81EZWs0 6YRcR1F+8I/+4fi876lks9uCXOMCBy7IANR7ghbpNLmyUB2yNAlcA3obZ+Bimk3sCJAs LSyC6/Ke6bLDa+wtjILW8NZoNASwWkm/9PXZBy8ztSUz+fBvtp4o3q6bme5UEdLYYpyA 5qRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b="nWxyvI/A"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u11si2050235pgp.200.2019.06.07.09.44.21; Fri, 07 Jun 2019 09:44:36 -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=fail header.i=@nbd.name header.s=20160729 header.b="nWxyvI/A"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730915AbfFGQoA (ORCPT + 99 others); Fri, 7 Jun 2019 12:44:00 -0400 Received: from nbd.name ([46.4.11.11]:58274 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730484AbfFGQn7 (ORCPT ); Fri, 7 Jun 2019 12:43:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender: Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ztfmCLh7/+hc7Bz5FdvHk4iOr4N3Xc+lH4FXCpCceBI=; b=nWxyvI/AxmHiA8YN5F4jjfv2oV vX2UhlVJLPQvuFEoWfWQ6wJTwYRRQPnDNLQGpacyA+ZxEt1I4esCcV6XdTd0Iq6QcUCT1cULwzuE+ iCD7qpwSc3PZ+Yh1qF96YNuBaGKR7ogXDVrKhL3KJIBJR0zD2P5rhV3Nb8ZtRbUEl+rQ=; Received: from p4ff13bc7.dip0.t-ipconnect.de ([79.241.59.199] helo=maeck-3.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hZHyA-0008DC-IK for linux-wireless@vger.kernel.org; Fri, 07 Jun 2019 18:43:58 +0200 Received: by maeck-3.local (Postfix, from userid 501) id B3CEA5C32BC0; Fri, 7 Jun 2019 18:43:56 +0200 (CEST) From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 2/4] mt76: fix setting chan->max_power Date: Fri, 7 Jun 2019 18:43:53 +0200 Message-Id: <20190607164355.51876-2-nbd@nbd.name> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190607164355.51876-1-nbd@nbd.name> References: <20190607164355.51876-1-nbd@nbd.name> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When setting chan->max_power after registering the wiphy, chan->max_reg_power needs to be used as a limit Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7603/init.c | 2 +- drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 5 +++-- drivers/net/wireless/mediatek/mt76/mt76x2/init.c | 9 +++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/init.c b/drivers/net/wireless/mediatek/mt76/mt7603/init.c index 2238e3daedc6..bce51997ff3b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/init.c @@ -494,7 +494,7 @@ mt7603_init_txpower(struct mt7603_dev *dev, for (i = 0; i < sband->n_channels; i++) { chan = &sband->channels[i]; - chan->max_power = target_power; + chan->max_power = min_t(int, chan->max_reg_power, target_power); chan->orig_mpwr = target_power; } } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index 57e46d57b449..d67401f895ca 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c @@ -279,8 +279,9 @@ mt76x0_init_txpower(struct mt76x02_dev *dev, mt76x0_get_tx_power_per_rate(dev, chan, &t); mt76x0_get_power_info(dev, chan, &tp); - chan->max_power = (mt76x02_get_max_rate_power(&t) + tp) / 2; - chan->orig_mpwr = chan->max_power; + chan->orig_mpwr = (mt76x02_get_max_rate_power(&t) + tp) / 2; + chan->max_power = min_t(int, chan->max_reg_power, + chan->orig_mpwr); } } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c index c6078e90ca43..97c3543eed8a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/init.c @@ -173,13 +173,14 @@ void mt76x2_init_txpower(struct mt76x02_dev *dev, mt76x2_get_power_info(dev, &txp, chan); mt76x2_get_rate_power(dev, &t, chan); - chan->max_power = mt76x02_get_max_rate_power(&t) + + chan->orig_mpwr = mt76x02_get_max_rate_power(&t) + txp.target_power; - chan->max_power = DIV_ROUND_UP(chan->max_power, 2); + chan->orig_mpwr = DIV_ROUND_UP(chan->orig_mpwr, 2); /* convert to combined output power on 2x2 devices */ - chan->max_power += 3; - chan->orig_mpwr = chan->max_power; + chan->orig_mpwr += 3; + chan->max_power = min_t(int, chan->max_reg_power, + chan->orig_mpwr); } } EXPORT_SYMBOL_GPL(mt76x2_init_txpower); -- 2.17.0