From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbdK2TM2 (ORCPT ); Wed, 29 Nov 2017 14:12:28 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:32735 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751537AbdK2TM0 (ORCPT ); Wed, 29 Nov 2017 14:12:26 -0500 Date: Wed, 29 Nov 2017 22:11:38 +0300 From: Dan Carpenter To: Souptick Joarder Cc: David Daney , Mark Rutland , linux-mips@linux-mips.org, devel@driverdev.osuosl.org, devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ralf@linux-mips.org, Carlos Munoz , Rob Herring , Andrew Lunn , "Steven J. Hill" , Greg Kroah-Hartman , Florian Fainelli , James Hogan , "David S. Miller" Subject: Re: [PATCH v4 7/8] netdev: octeon-ethernet: Add Cavium Octeon III support. Message-ID: <20171129191138.ntlfw5fb4xacwyun@mwanda> References: <20171129005540.28829-1-david.daney@cavium.com> <20171129005540.28829-8-david.daney@cavium.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 29, 2017 at 09:37:15PM +0530, Souptick Joarder wrote: > >> +static int bgx_port_sgmii_set_link_speed(struct bgx_port_priv *priv, struct port_status status) > >> +{ > >> + u64 data; > >> + u64 prtx; > >> + u64 miscx; > >> + int timeout; > >> + > > >> + > >> + switch (status.speed) { > >> + case 10: > > > > In my opinion, instead of hard coding the value, is it fine to use ENUM ? > Similar comments applicable in other places where hard coded values are used. > 10 means 10M right? That's not really a magic number. It's fine. > >> +static int bgx_port_init_xaui_link(struct bgx_port_priv *priv) > >> +{ > > >> + > >> + if (use_ber) { > >> + timeout = 10000; > >> + do { > >> + data = > >> + oct_csr_read(BGX_SPU_BR_STATUS1(priv->node, priv->bgx, priv->index)); > >> + if (data & BIT(0)) > >> + break; > >> + timeout--; > >> + udelay(1); > >> + } while (timeout); > > > > In my opinion, it's better to implement similar kind of loops inside macros. I don't understand what you mean here. For what it's worth this code seems clear enough to me (except for the bad indenting of oct_csr_read(). It should be something like: data = oct_csr_read(BGX_SPU_BR_STATUS1(priv->node, priv->bgx, priv->index)); That's over the 80 char limit but so is the original code. regards, dan carpenter