Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6340406rdb; Thu, 14 Dec 2023 15:54:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGMO5wwy2GlLRk3NF+Bj8FzXXahI3HUbQ+6MwEqD9hOkCY3bVlXZPuYiOt/BItFHenZy3o X-Received: by 2002:a50:f68e:0:b0:552:76a7:2067 with SMTP id d14-20020a50f68e000000b0055276a72067mr969667edn.67.1702598092546; Thu, 14 Dec 2023 15:54:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702598092; cv=none; d=google.com; s=arc-20160816; b=hcZn9vObDGle2kZhEkDyOhQAzoJRZ7z09whZWGk9yIgmWddmyXZJkSGP79lleR3JKW 2wnCybEiLpcHLlCW65BpPM1UVVk65Id9PZdTJremXsL9i1dLe35vYYTnfTe8M4/2koBj WloX4MNpXmGZYbEg1OPiJirUZNBME7RO+lUJIme076y+RR1D0aNAjyLAAKqiR0Dr72RP 4xzXLjd20wZ06yYnsGJ8mTWdNtiO0xhN21K+buCD/oQJw5yjXzFY4Bhu5A4D2LifMmVC /TmJgiNVkgzxPgmLhDb4sY9p2KS6xfRXHPJ+XClqnClTXqGK/9yj6D5HVl4rY/OpeZZW m66Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=AGhWCo3kebEsFhbGunIR4r1yUG3IKZL5BCf/J4dBVOQ=; fh=LGSOQ228QAUynDa/vXbuzvXIWpQ7ysUFfAoDYzISVGE=; b=cdeB581vEbL9MgW5Fap5H4lZRfIGhdpEIoYq0u/NPPecFyGUoVW6HLcykq+P1IS3XW 3VDZZ0RGPW6QkbcXqdL1Whu3xPL74Gj6vhY3b6RGx3DhoZATHRuefTZHN9SbQSlDoztm zmGW8uScUukw6U7A6wEekPOzUBvnyBm5SniRPDqa+ACujeO6Z4OSAdZMH2dgXEDFQWLo B7PC/DbjHm7KRmDNXY13MBtaAeugX7bX9DO5QG/meI8OmYTwgr/52xvwiL33TsCAt5Rr Ck2MmTWSGXvaA/bNDJsH6Ccz58s6A0wYJmQ5iC3C+b6WnISBgi87UN3FpPcyChlULBOS 61Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Cql5vmFx; spf=pass (google.com: domain of linux-kernel+bounces-262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y19-20020a056402359300b00551e8b3340bsi2318266edc.356.2023.12.14.15.54.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 15:54:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Cql5vmFx; spf=pass (google.com: domain of linux-kernel+bounces-262-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-262-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 485161F22B59 for ; Thu, 14 Dec 2023 23:54:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 479E52DB6D; Thu, 14 Dec 2023 23:54:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="Cql5vmFx" X-Original-To: linux-kernel@vger.kernel.org Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 68E196C6F1; Thu, 14 Dec 2023 23:54:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AGhWCo3kebEsFhbGunIR4r1yUG3IKZL5BCf/J4dBVOQ=; b=Cql5vmFxeviq3QAIJKNd8I3mxr NrqSPnVL6vLMh91+DwSjADq0qrXQhRM2LLdgcPEnlQQ0fIUbcrpauHxf2yELgwE89CjqyrvFkAGA5 8dtazzKrPvBCPtowDPdgoieulYKJeO4lsxY82qYOzYAKXKP+iL4gpyFAaZBRVDWNnrzoe3vl44lqz UaHO0O2kThTU01YlF3j4MxV8z3CYqVmf9urD6g1hMJcFGyqPGpJtfJMRJaUrVBidsPMEKy8locyid XxLjaK+o0yvAwqIMBAEWo/MuJ/boMvjc97shseIqZF+qpgH6XoRgVgY5zaaqZiowbr4sZS/wTsaQg hZGbL4Dw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:50276) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDvX8-00022X-2X; Thu, 14 Dec 2023 23:54:26 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDvX8-0002zR-2g; Thu, 14 Dec 2023 23:54:26 +0000 Date: Thu, 14 Dec 2023 23:54:26 +0000 From: "Russell King (Oracle)" To: Christian Marangi Cc: Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , David Epping , Harini Katakam , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [net-next PATCH v7 2/4] net: phy: extend PHY package API to support multiple global address Message-ID: References: <20231214121026.4340-1-ansuelsmth@gmail.com> <20231214121026.4340-3-ansuelsmth@gmail.com> <657b921d.5d0a0220.7815b.87dd@mx.google.com> Precedence: bulk X-Mailing-List: linux-kernel@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: <657b921d.5d0a0220.7815b.87dd@mx.google.com> Sender: Russell King (Oracle) On Thu, Dec 14, 2023 at 05:54:51PM +0100, Christian Marangi wrote: > What I don't like is the wrap check. > > But I wonder... Isn't it easier to have > > unsigned int addr = shared->base_addr + addr_offset; > > and check if >= PHY_MAC_ADDR? > > Everything is unsigned (so no negative case) and wrap is not possible as > nothing is downcasted. I'm afraid that I LOL'd at "wrap is not possible" ! Of course it's possible. Here's an example: shared->base_addr is 20 addr_offset is ~0 (or -1 casted to an unsigned int) addr becomes 19 How about: if (addr_offset >= PHY_MAX_ADDR) return -EIO; addr = shared->base_addr + addr_offset; if (addr >= PHY_MAX_ADDR) return -EIO; and then we could keep 'addr' as u8. Honestly, I have wondered why the mdio bus address is a signed int, but never decided to do anything about it. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!