Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756721AbdLOOtk (ORCPT ); Fri, 15 Dec 2017 09:49:40 -0500 Received: from mail.savoirfairelinux.com ([208.88.110.44]:53944 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbdLOOtj (ORCPT ); Fri, 15 Dec 2017 09:49:39 -0500 From: Vivien Didelot To: Egil Hjelmeland , andrew@lunn.ch, f.fainelli@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Egil Hjelmeland Subject: Re: [PATCH net-next] net: dsa: lan9303: lan9303_csr_reg_wait cleanups In-Reply-To: <20171215132859.4553-1-privat@egil-hjelmeland.no> References: <20171215132859.4553-1-privat@egil-hjelmeland.no> Date: Fri, 15 Dec 2017 09:49:35 -0500 Message-ID: <87efnwjbb4.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2621 Lines: 80 Hi Egil, Egil Hjelmeland writes: > Non-functional cleanups in lan9303_csr_reg_wait(): > - Change type of param 'mask' from int to u32. > - Remove param 'value' (will probably never be used) > - Reduced retries from 1000 to 25, consistent with lan9303_read_wait. > - Corrected comments > > Signed-off-by: Egil Hjelmeland > --- > drivers/net/dsa/lan9303-core.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c > index f412aad58253..209882075e3b 100644 > --- a/drivers/net/dsa/lan9303-core.c > +++ b/drivers/net/dsa/lan9303-core.c > @@ -249,7 +249,7 @@ static int lan9303_read(struct regmap *regmap, unsigned int offset, u32 *reg) > return -EIO; > } > > -/* Wait a while until mask & reg == value. Otherwise return timeout. */ > +/* Wait a while until mask & reg == 0. Otherwise return timeout. */ I'd remove this comment completely. The related code below is quite explicit and speaks for itself, no need for an extra comment IMO. for (...) if (!(mask & reg)) return 0; return -ETIMEOUT; > static int lan9303_read_wait(struct lan9303 *chip, int offset, u32 mask) > { > int i; > @@ -541,20 +541,20 @@ lan9303_alr_cache_find_mac(struct lan9303 *chip, const u8 *mac_addr) > return NULL; > } > > -/* Wait a while until mask & reg == value. Otherwise return timeout. */ > -static int lan9303_csr_reg_wait(struct lan9303 *chip, int regno, > - int mask, char value) > +/* Wait a while until mask & reg == 0. Otherwise return timeout. */ Same here, no need to add some code in a comment. > +static int lan9303_csr_reg_wait(struct lan9303 *chip, int regno, u32 mask) > { > int i; > > - for (i = 0; i < 0x1000; i++) { > + for (i = 0; i < 25; i++) { > u32 reg; > > lan9303_read_switch_reg(chip, regno, ®); > - if ((reg & mask) == value) > + if (!(reg & mask)) > return 0; > usleep_range(1000, 2000); > } > + > return -ETIMEDOUT; > } > > @@ -564,8 +564,7 @@ static int lan9303_alr_make_entry_raw(struct lan9303 *chip, u32 dat0, u32 dat1) > lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_WR_DAT_1, dat1); > lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_CMD, > LAN9303_ALR_CMD_MAKE_ENTRY); > - lan9303_csr_reg_wait(chip, LAN9303_SWE_ALR_CMD_STS, ALR_STS_MAKE_PEND, > - 0); > + lan9303_csr_reg_wait(chip, LAN9303_SWE_ALR_CMD_STS, ALR_STS_MAKE_PEND); > lan9303_write_switch_reg(chip, LAN9303_SWE_ALR_CMD, 0); The rest of the patch makes sense. Thanks, Vivien