Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1470576rdb; Wed, 20 Sep 2023 09:57:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAocfutkUgQfT4Q76fXpwtsAoQChh8DB2HiP7lYaJw7pDL00or9y75biqaWQWfUyErKkAr X-Received: by 2002:a05:6a20:3c8a:b0:158:143d:e215 with SMTP id b10-20020a056a203c8a00b00158143de215mr8781000pzj.1.1695229071474; Wed, 20 Sep 2023 09:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695229071; cv=none; d=google.com; s=arc-20160816; b=HYrGtTWT4XaPQnM7YJDspYiS0Z9+X1vKwroP4dTMH9TqPC44+8LtiAMVX+Gw9jaEo5 qfDgeRiQF/iDhWRVcE0fzh2bFcswiTZNstp/3D0bfDlLGIW8TccXgAP+GOQBVBjGvaT2 xlPErH+kuu/KaKXzi3JYzPRlN4CpFSVSC2JF337F1/mLEmcwKyvsWF1NFBZG/0Ogg7vQ ut0DGJlPE4GGNY+e46d3y0u36PkwbThAr6WHO4CBs1KEp+iSk/FsF/XFac8CLZDPr8Ay vOXfQ5DI9LnpQnBWMv01C5v6qKdDZ7N8TYfXqFurrzQZ3it7a/2YKqVczeanDRym7ozk tL+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JFsLFOJrmcJ4WHo0K+13UYlyXYwrIUlqnx9nfro4rc4=; fh=pGwbM9Xdy06QfzFRKeZ1f/bKJ9dlh/YmY6K4NMyqr4g=; b=WuOLlVZmQF5aNwrMQq6P/4KatRoLRWt+glmFQaIM3fRK/RskKuUo37gLHvJt9sTy3d IdfW3NxEuRV2zDQXtcZRzZyiw9Ylt1ypA2HasHMB3EI9XY72/9l3n3J9LM1J0a/Micqc AWN8pPkcuPIQ8iQxNno0lJ0c5X6dagV9y+kMOSxEzz6975rq7CPen0g6f0srOHQ7rrB3 NZD5ok76vWZUiAO7I2O8fP3oXlxpa8xd/mTWmaIti596qi1IhfmHL9K8NvKJpOmoh9+z xcZOD7+rgo1VJgU7nymgAaX/9teB52WwYLhnCoKNHUnJ8tg07rNuJTgrU5sSswR5U80H ohfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=FhpcstQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id c131-20020a633589000000b00563da455862si4583942pga.311.2023.09.20.09.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 09:57:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=FhpcstQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8D6BD82A2D9D; Wed, 20 Sep 2023 04:44:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234470AbjITLoM (ORCPT + 99 others); Wed, 20 Sep 2023 07:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234330AbjITLoL (ORCPT ); Wed, 20 Sep 2023 07:44:11 -0400 Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEBBECE; Wed, 20 Sep 2023 04:44:02 -0700 (PDT) Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 9A48B86AFA; Wed, 20 Sep 2023 13:44:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1695210241; bh=JFsLFOJrmcJ4WHo0K+13UYlyXYwrIUlqnx9nfro4rc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FhpcstQm6M9ponOIec9P+seV2I0OG5IQJqPO+5j65+8RsJAPN0pBPAeB/MSUSgF+z G8+dGU46JZWHiFvhPkF14XzeH3WaJEl8DRBT3YbtyUmAN3k9qmWk9VQ3NxypL6R8ME KUvnQ5i7d7pGaEk9PvKriEDGAQnncY4IT6UYOfqLk3WciKeEh/AwT2SJn5aunYxF6i OCtSdGNE+bJsHxnhzLGp0PDSbnNRDQwZPpK7+WhHvs4Feo43uDDJemwsguuwbGPgek bMmMcfU3TGkX0zPAwv7GUMXRHJtJEvymN7UDS2rM0ocjJeZs9Pn3qh012Uvu1o1m2X Ed65zvLriioNw== From: Lukasz Majewski To: Tristram.Ha@microchip.com, Eric Dumazet , Andrew Lunn , davem@davemloft.net, Woojung Huh , Vladimir Oltean , Oleksij Rempel Cc: Florian Fainelli , Jakub Kicinski , Paolo Abeni , UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Oltean , Lukasz Majewski Subject: [PATCH v5 net-next 4/5] net: dsa: microchip: move REG_SW_MAC_ADDR to dev->info->regs[] Date: Wed, 20 Sep 2023 13:43:42 +0200 Message-Id: <20230920114343.1979843-5-lukma@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230920114343.1979843-1-lukma@denx.de> References: <20230920114343.1979843-1-lukma@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 20 Sep 2023 04:44:12 -0700 (PDT) From: Vladimir Oltean Defining macros which have the same name but different values is bad practice, because it makes it hard to avoid code duplication. The same code does different things, depending on the file it's placed in. Case in point, we want to access REG_SW_MAC_ADDR from ksz_common.c, but currently we can't, because we don't know which kszXXXX_reg.h to include from the common code. Remove the REG_SW_MAC_ADDR_{0..5} macros from ksz8795_reg.h and ksz9477_reg.h, and re-add this register offset to the dev->info->regs[] array. Signed-off-by: Vladimir Oltean Signed-off-by: Lukasz Majewski --- Changes for v5: - New patch --- drivers/net/dsa/microchip/ksz8795_reg.h | 7 ------- drivers/net/dsa/microchip/ksz9477_reg.h | 7 ------- drivers/net/dsa/microchip/ksz_common.c | 2 ++ drivers/net/dsa/microchip/ksz_common.h | 1 + 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 7a57c6088f80..ee1b673d5f30 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -323,13 +323,6 @@ ((addr) + REG_PORT_1_CTRL_0 + (port) * \ (REG_PORT_2_CTRL_0 - REG_PORT_1_CTRL_0)) -#define REG_SW_MAC_ADDR_0 0x68 -#define REG_SW_MAC_ADDR_1 0x69 -#define REG_SW_MAC_ADDR_2 0x6A -#define REG_SW_MAC_ADDR_3 0x6B -#define REG_SW_MAC_ADDR_4 0x6C -#define REG_SW_MAC_ADDR_5 0x6D - #define TABLE_EXT_SELECT_S 5 #define TABLE_EEE_V 1 #define TABLE_ACL_V 2 diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h b/drivers/net/dsa/microchip/ksz9477_reg.h index cba3dba58bc3..c8866c180fe5 100644 --- a/drivers/net/dsa/microchip/ksz9477_reg.h +++ b/drivers/net/dsa/microchip/ksz9477_reg.h @@ -166,13 +166,6 @@ #define SW_DOUBLE_TAG BIT(7) #define SW_RESET BIT(1) -#define REG_SW_MAC_ADDR_0 0x0302 -#define REG_SW_MAC_ADDR_1 0x0303 -#define REG_SW_MAC_ADDR_2 0x0304 -#define REG_SW_MAC_ADDR_3 0x0305 -#define REG_SW_MAC_ADDR_4 0x0306 -#define REG_SW_MAC_ADDR_5 0x0307 - #define REG_SW_MTU__2 0x0308 #define REG_SW_MTU_MASK GENMASK(13, 0) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 42db7679c360..c67ad0f6e1fa 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -298,6 +298,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { }; static const u16 ksz8795_regs[] = { + [REG_SW_MAC_ADDR] = 0x68, [REG_IND_CTRL_0] = 0x6E, [REG_IND_DATA_8] = 0x70, [REG_IND_DATA_CHECK] = 0x72, @@ -426,6 +427,7 @@ static u8 ksz8863_shifts[] = { }; static const u16 ksz9477_regs[] = { + [REG_SW_MAC_ADDR] = 0x0302, [P_STP_CTRL] = 0x0B04, [S_START_CTRL] = 0x0300, [S_BROADCAST_CTRL] = 0x0332, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index a4de58847dea..1f3fb6c23f36 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -211,6 +211,7 @@ enum ksz_chip_id { }; enum ksz_regs { + REG_SW_MAC_ADDR, REG_IND_CTRL_0, REG_IND_DATA_8, REG_IND_DATA_CHECK, -- 2.20.1