Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3094399rdb; Fri, 22 Sep 2023 19:21:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZOAHfk96Am2ol0Q1fUlZUh7dv0Aa+83mDNmxmIgDp7B22F2pqXmU4jAFcYtWKQe1Yn+b7 X-Received: by 2002:a17:90b:e07:b0:268:798:a28b with SMTP id ge7-20020a17090b0e0700b002680798a28bmr6400651pjb.23.1695435670961; Fri, 22 Sep 2023 19:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695435670; cv=none; d=google.com; s=arc-20160816; b=e3JQoGzTHTr1ucjbhTE2ed2NX8qq0TxRcLLcM0PYm/Cb+fQs6/DWvesEbiULW4Mbfc IUA6Iu+44ELk9CZxG/fHDBu3SZTKg3YvNK57hc6SCRcekR2w3O2/R2OtVgKZT8WRfubz 8sVrZzvCfzSjJo775muN3hGqFyF4E5bUAs4pJbN2drTt/DN5FViYrbTi80NfHTCtkM4N XkoR/RpvLKVK3xuX2uZg4IpvI/WUgY+u0I0mAVSUGubIOBZOvfXHvTKYOiRlwaDWuJYu i2nz2+ZwM/d068zAcSrbIPtHmjTGrokcr7hypmcONjMvmd2Pi4/VYY0ybO/ji1zjxQMm fNKw== 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=QyQZgh18+AEb/uaLubc8YIM3M5wmKXPg7nTWgiyLM4w=; fh=pS1C7Vbe/+UXtC8+indT5iG8c7LzMoOEoDfoWy8vSDc=; b=k+zmXD9Q6z/Un7iloQr0fCtG1iLT+0cWw0e0jHvW2C3Hd/DZmgd5OBuS163yzEXDyE MRckGs5bEhMmD00gwzkuUAHNVrcr0fKkf+aPblitpU4hyxhcYvDouwjs9RhEdASCDRTU h21Py7owDTG78MsR9h3zPsqNCB2I5bDR2Iv+Ju8Azm0jtCyfC1YPFb4wCwvBfrQBQLmZ xHAX1OnWPTjMsQvY1h8DZP+sB3/YJtz07VHvKPyeoZ9Du6IOJDWBpxouB4fXd5zwJ5C1 rqOGLJF96tRVwiJbuzy3OlJE/Yi/52qS/1BgraZiWvRweTXm37RXwv3+hbXCaX+k07KH cepQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=YF9fD0pH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id mq16-20020a17090b381000b0026d0a89ad68si8248975pjb.43.2023.09.22.19.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 19:21:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=YF9fD0pH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 35EA683FEC13; Fri, 22 Sep 2023 06:31:47 -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 S229989AbjIVNbk (ORCPT + 99 others); Fri, 22 Sep 2023 09:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234068AbjIVNbi (ORCPT ); Fri, 22 Sep 2023 09:31:38 -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 EC050E8; Fri, 22 Sep 2023 06:31:31 -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 42B7E864E9; Fri, 22 Sep 2023 15:31:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1695389490; bh=QyQZgh18+AEb/uaLubc8YIM3M5wmKXPg7nTWgiyLM4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YF9fD0pHpL8SzSJrY0vT0DlLryhTyO9TWcsO+cSbleew31hHs4n70XTC6hlHSMjXM Wp+eHma85e4U8x7uqlrdLY5qGEyNGd0Mps0H1hzJDLUjYzv4+QVY2tPkhrD9rhxqnE gG/ehkZ1zVsRtME3MYXeKIojg3nC/73O23dGXmUP169hVFM6BtBR+b1cPeBFzL5TvZ ZYKC1Gw10lHYZgpgW0TQX28tYkd0FTOsDw3F88NEOVXcbD19hw3hMWxCBzuMeT00bf t1yxkYGZDux6yrVBHbuS4wNB51OG4MQ10QHrY/i//rOC+wFrm2c3tlBxhIxq5v8tyj nq3mVbBhQvmmw== 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 , Florian Fainelli Subject: [PATCH v6 net-next 4/5] net: dsa: microchip: move REG_SW_MAC_ADDR to dev->info->regs[] Date: Fri, 22 Sep 2023 15:31:07 +0200 Message-Id: <20230922133108.2090612-5-lukma@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230922133108.2090612-1-lukma@denx.de> References: <20230922133108.2090612-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.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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]); Fri, 22 Sep 2023 06:31:47 -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 Reviewed-by: Florian Fainelli --- Changes for v5: - New patch Changes for v6: - None --- 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 d33db4f86c64..3c9dae53e4d8 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 504e085aab52..f3a205ee483f 100644 --- a/drivers/net/dsa/microchip/ksz9477_reg.h +++ b/drivers/net/dsa/microchip/ksz9477_reg.h @@ -153,13 +153,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 173ad8f04671..6c31d51410e3 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -364,6 +364,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, @@ -492,6 +493,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 d180c8a34e27..07c7723dbc37 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -212,6 +212,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