Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1223709rwb; Thu, 8 Dec 2022 08:05:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf4o1V2g6qv9LsncwAE3xux0MdlM59jc57o5mBj4odNU5vFIbTo2HjByh3i0cksi8GF+Ul2U X-Received: by 2002:a05:6402:2b8a:b0:46b:2979:7397 with SMTP id fj10-20020a0564022b8a00b0046b29797397mr43288576edb.332.1670515557502; Thu, 08 Dec 2022 08:05:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670515557; cv=none; d=google.com; s=arc-20160816; b=mP8dbXeL5QqTy7y90fR9esI04au+qFPD+QkIirX6FoYLeK5zT3Gh0HdewRjng6Nw+/ hVSieZlHuK6/TJpgK/AeTvI7V75567wAaeDZz50hd4rjrt/mTqUs5z1sxxvNdecYIV20 wjsaGtfee7p+83qnqqznyc3U46gqkCDHGTVgCca4VD+TAa/vv/3ZS6EjGQ0v5+kc7JBh wcq6N47Ew9EvHbObovGqfS7xLaHel7Nma90MpVfwBHllqFENP2nFrOV9Krbshxqs1fNb H6SsYJGFA+w25u4n4qkmTg6yaTwVMc1V5Tsx3KtOvHD+ZQQENLayWmxd8U+CV+grU0hV yaKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=+76gdjb4ml67Jkqt4RrOnjZf/kZrAJbshFGU/r7BGa0=; b=SWAYjMEDP/pI23EZ6kC/05Bnid1Ema+qw9D2/im3toQTgpc3tADYKVURmqFUYzjKlq Za7JrpFyr8TOqvCfMdFPHefYarOLc91lrH44LdfZrvekE+wy87gEcUY8pLV2qxmaLgI7 2LAwXrcWD+QlcTzvOXBqIOaJr5kT8kwuPcf0dvKvcPtnq1UzjaNgvc6SfYh7ayFnYM9H FZbXmBJGXUZZ0SwMfm2oA35UF6I2TX95AJpxa6FCULRuu0mLRSi8N80VLeXJLeo+0TaH tfuNFKQtvPMcBM8eXlRG0tem2PWONPH3noK9i/xbhpYdleyBjm/npoUH6Rqy7DcDWbWf iEpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=PpvkmZRX; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn6-20020a1709070d0600b0078239e3f846si13411401ejc.1.2022.12.08.08.05.36; Thu, 08 Dec 2022 08:05:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=PpvkmZRX; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbiLHQCE (ORCPT + 65 others); Thu, 8 Dec 2022 11:02:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbiLHQCA (ORCPT ); Thu, 8 Dec 2022 11:02:00 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CC749B2B2 for ; Thu, 8 Dec 2022 08:01:59 -0800 (PST) X-UUID: 3bfcb07e07774fe69ddd84d4ca08b9ef-20221209 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=+76gdjb4ml67Jkqt4RrOnjZf/kZrAJbshFGU/r7BGa0=; b=PpvkmZRXeSXSTMf7x0jMxeHBnL8ac7yUvzIs1cOHRNZ9f2Tn285LIbSceWp9PoBDyWjN/b6v+1Q35peSxSIS+snKH5ovp+PwW9At7MT1i5abzypSUjavFDa3H8Jte02ArsY373U0HD3Y1vHaBOXDKMt2JlnkRAv5kzBulIH6yyw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:541b9653-7d4e-4313-9025-ee13273eac9e,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:dcaaed0,CLOUDID:b3a10ad2-652d-43fd-a13a-a5dd3c69a43d,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 3bfcb07e07774fe69ddd84d4ca08b9ef-20221209 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1945983699; Fri, 09 Dec 2022 00:01:53 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Fri, 9 Dec 2022 00:01:52 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 9 Dec 2022 00:01:52 +0800 From: Shayne Chen To: Felix Fietkau CC: linux-wireless , Lorenzo Bianconi , Ryder Lee , Evelyn Tsai , linux-mediatek , Shayne Chen Subject: [PATCH] wifi: mt76: mt7915: add chip id condition in mt7915_check_eeprom() Date: Fri, 9 Dec 2022 00:01:37 +0800 Message-ID: <20221208160137.3855-1-shayne.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When flash mode is enabled, and the eeprom data in the flash is not for the current chipset, it'll still be checked valid, and the default eeprom bin won't be loaded. (e.g., mt7915 NIC inserted with mt7916 eeprom data in the flash.) Fix this kind of case by adding chip id into consideration in mt7915_check_eeprom(). Reported-by: Cheng-Ji Li Signed-off-by: Shayne Chen --- drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c index 59069fb86414..e21aa03c85b1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c @@ -33,14 +33,12 @@ static int mt7915_check_eeprom(struct mt7915_dev *dev) u8 *eeprom = dev->mt76.eeprom.data; u16 val = get_unaligned_le16(eeprom); - switch (val) { - case 0x7915: - case 0x7916: - case 0x7986: + if ((is_mt7915(&dev->mt76) && val == 0x7915) || + (is_mt7916(&dev->mt76) && val == 0x7916) || + (is_mt7986(&dev->mt76) && val == 0x7986)) return 0; - default: - return -EINVAL; - } + + return -EINVAL; } static char *mt7915_eeprom_name(struct mt7915_dev *dev) -- 2.25.1