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 C21EF364E95; Tue, 27 Jan 2026 19:10:44 +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=1769541049; cv=none; b=SgDmZ+qb3K5zOQ7xQlU8SYeEUdUnSPstqeYW5rcDOoN1clvpdbYV/K09YI1KfpOUSkEeHsvV/ihrzXR3sEkf5hXOjn2B+ukHZHOb/pPbmECJSCipGYlhnCdD3jpc7ZelfVT1gTiUMx6HeU2LVqI9aBkZz+ikCIzweqj7Z7oF09U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769541049; c=relaxed/simple; bh=TZIdSLXmIauKxvF1SwbChtRMQd40Hew97TKUK2jdNfk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LSFmUR+vpi4SvbStAMsNXLHwx+voTicX61+eOBlCiN5Hf+D6XBCBEoVjF+zE4wi+Yr3XsRKzU7CsfKww2MGkDPes1v2202RPDoL6jyRHSZOkQvdeYGtQJtNNolMZ4z2jOk3tcQYU3gTI0vAUxVdSQXzp5ehb38dZXXaymvMZeYw= 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 1vkoSU-000000002Sb-1IRu; Tue, 27 Jan 2026 19:10:38 +0000 Date: Tue, 27 Jan 2026 19:10:34 +0000 From: Daniel Golle To: Andrew Lunn Cc: Paolo Abeni , 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> <5e7c2f9c-bf49-4564-91b3-a639ef1c97d8@lunn.ch> <8f267321-25fc-447f-8ff3-5d5b2d844d30@lunn.ch> 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 07:34:41PM +0100, Andrew Lunn wrote: > On Tue, Jan 27, 2026 at 04:07:10PM +0000, Daniel Golle wrote: > > On Tue, Jan 27, 2026 at 04:04:10PM +0100, Andrew Lunn wrote: > > > > > int mxl862xx_to_zephyr_errno(u16 reg) > > > > so that would then just be > > > > return (s16)reg; > > > > right? > > > > > > Yes. > > > > +1 > > > > Maybe better to check if bit 16~31 is actually zero as well, so > > int mxl862xx_to_zephyr_errno(int reg) > > { > > if (reg >= 0 && reg <= U16_MAX) > > return (s16)reg; > > > > return 0; > > If bits 16~31 are not zero, i would say the MDIO driver is broken, and > we should fix it. Returning 0 is going to hide such issues. If you are > worried about it, at least add a WARN_ON() or something. The MDIO bus driver can very well return things like -ETIMEDOUT or -ENODEV as a result of its .read_c45() operation (both values got all bits 16~31 set, on every architecture I've checked) This hints towards broken hardware, but not a broken driver. And I'd rather catch that case (int reg < 0) separately and outside of the mxl862xx_to_zephyr_errno() helper. The broken-driver case would be values between U16_MAX and S32_MAX which really don't make any sense. Making sure mxl862xx_to_zephyr_errno() isn't called if any of the bits 16~31 are set would still be good to not end up blaming the firmware for something which in reality is the MDIO bus driver or faulty hardware. In that sense my idea of return 0 was just to say "it isn't a value returned by the Zephyr firmware". If you prefer a WARN_ON() and return -EINVAL instead of the return 0 that would be fine as well, of course.