Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751746AbdHANkU (ORCPT ); Tue, 1 Aug 2017 09:40:20 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:47813 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916AbdHANjh (ORCPT ); Tue, 1 Aug 2017 09:39:37 -0400 Date: Tue, 1 Aug 2017 15:39:34 +0200 From: Andrew Lunn To: Egil Hjelmeland Cc: vivien.didelot@savoirfairelinux.com, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH v2 net-next 1/3] net: dsa: lan9303: Refactor lan9303_xxx_packet_processing() Message-ID: <20170801133934.GB23157@lunn.ch> References: <20170801111439.1143-1-privat@egil-hjelmeland.no> <20170801111439.1143-2-privat@egil-hjelmeland.no> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170801111439.1143-2-privat@egil-hjelmeland.no> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 720 Lines: 25 > @@ -704,7 +710,7 @@ static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port, > unsigned int u, poff; > int ret; > > - poff = port * 0x400; > + poff = LAN9303_SWITCH_PORT_REG(port, 0); > > for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) { > ret = lan9303_read_switch_reg(chip, So the actual code is: for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) { ret = lan9303_read_switch_reg(chip, lan9303_mib[u].offset + poff, ®); Could this be written as for (u = 0; u < ARRAY_SIZE(lan9303_mib); u++) { ret = lan9303_read_switch_port(chip, port, lan9303_mib[u].offset, ®); It is then clear you are reading the statistics from a port register. Andrew