From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9215307494; Tue, 27 Jan 2026 11:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769514831; cv=none; b=JLf/xOq42E6q938sBTrq0ubkMKKOKKjNJ+W7p52KaS/7Xu78oj0/E9E6B7FOMpYF+y6Fz4mO0Rirk7qbCiN7gYxAsqRyRKTyw4gPPMzeg0fldgHT0IgT9Yfgn0cPf0rQuyst7eodiqdkytRYEg9ZHGNK9G9Tw9I7lkB3xQS0slg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769514831; c=relaxed/simple; bh=0uuzltDyeIqpzLEcuqA6to0AWPnwQPXq94CKfGDwwaQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LLrQIKQMEPFUTI25RlL5R7D1s7TroeACDGFWKkW5UpzmLen5hvDyNMP7es+PI/vIZVnTb8RI5Krd5yMlTuord2FNUJIqlUuNyIZhCUMJOFXZGLjXZauXhvJ6MKodP5GXIBFv8z5rylzfMBy0zY2rXhFF7Ljvai/QOAWPQeWeXdY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1vkhdV-000000008UM-0oiX; Tue, 27 Jan 2026 11:53:33 +0000 Date: Tue, 27 Jan 2026 11:53:28 +0000 From: Daniel Golle To: Paolo Abeni Cc: Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiner Kallweit , Russell King , Simon Horman , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Wunderlich , Chad Monroe , Cezary Wilmanski , Avinash Jayaraman , Bing tao Xu , Liang Xu , Juraj Povazanec , "Fanni (Fang-Yi) Chan" , "Benny (Ying-Tsan) Weng" , "Livia M. Rosu" , John Crispin Subject: Re: [PATCH net-next v8 4/4] net: dsa: add basic initial driver for MxL862xx switches Message-ID: References: <18c6a24eef8617abb5073569fee162f1aa1c06ea.1769053079.git.daniel@makrotopia.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jan 27, 2026 at 11:41:00AM +0100, Paolo Abeni wrote: > On 1/22/26 4:42 AM, Daniel Golle wrote: > > +static int mxl862xx_send_cmd(struct mxl862xx_priv *priv, u16 cmd, u16 size, > > + bool quiet) > > +{ > > + int ret; > > + > > + ret = mxl862xx_reg_write(priv, MXL862XX_MMD_REG_LEN_RET, size); > > + if (ret) > > + return ret; > > + > > + ret = mxl862xx_reg_write(priv, MXL862XX_MMD_REG_CTRL, > > + cmd | CTRL_BUSY_MASK); > > + if (ret) > > + return ret; > > + > > + ret = mxl862xx_busy_wait(priv); > > + if (ret) > > + return ret; > > + > > + ret = mxl862xx_reg_read(priv, MXL862XX_MMD_REG_LEN_RET); > > + /* handle errors returned by the firmware as -EIO > > + * The firmware is based on Zephyr OS and uses the errors as > > + * defined in errno.h of Zephyr OS. See > > + * https://github.com/zephyrproject-rtos/zephyr/blob/v3.7.0/lib/libc/minimal/include/errno.h > > + */ > > + if ((s16)ret < 0) { > > The cast is likely not needed above? if `ret` values < S16_MIN are > possible this will return such values to the caller without the IO err > printk. Right, it should rather be if (ret > S16_MAX && ret <= U16_MAX) to really only catch the range of numbers which are negative 16-bit signed values represented as positive 32-bit signed values. mxl862xx_reg_read() primarily returns a signed 32-bit integer, as it is basically just a wrapper around __mdiodev_c45_read(). Negative values of that 32-bit integer mean that the MDIO Clause-45 read has somehow failed, ie. it's the error the MDIO bus .read_c45() operation has returned. In case __mdiodev_c45_read() succeeds it returns the 16-bit value of the register read. In this case, those 16-bit should be interpreted as a 16-bit signed integer here. A negative value denotes an error returned from the firmware running on the switch (see comment above the code). > > > + if (!quiet) > > + dev_err(&priv->mdiodev->dev, > > + "CMD %04x returned error %d\n", cmd, (s16)ret); > > + return -EIO; > > + } > > + > > + return ret; > > +} > > + > > +int mxl862xx_api_wrap(struct mxl862xx_priv *priv, u16 cmd, void *_data, > > + u16 size, bool read, bool quiet) > > +{ > > + __le16 *data = _data; > > + u16 max, i; > > + int ret, cmd_ret; > > Minor nit: reverse christmas tree above. Oh right.... I anyway found another minor issue, so I'm going to send v9 with the above as well as the other minor issue fixed. > BTW the initial port isolation LGTM, but I would appreciate some DSA > expert second opinion. +1