From nobody Sun Dec 14 12:06:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DEA8D286425; Thu, 22 May 2025 11:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747912915; cv=none; b=SyuY8pfg2LALJdO2TvhiZ8dSdA8KipF8dtn2/SIAKjTr8RPOZycDesWzKH2FiOsKqYfhphWAHfggGghoyKF/xhCejG1trgXR22C3oVMPoV4tn8EwXmXn9ZdUsfXfgGRIbRVFCO8fVa3KYVlVhZLRPUk38rOT5Njj9GvX+NadTeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747912915; c=relaxed/simple; bh=GCD+itmTe0b/J+qM5d/v9KELzW7ui94Qc8QFqpcbKRU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DpM7q3h0PXUrJ/6emdB/LrHb25vmq8Nso8VT3PJBKzeaPZethEt7/LcVBOq+coGEyETcFJpK8qsr+0Fj8RmCm+S94aNwmDv9Ize3LgJNfTVCG6ArzIo6SsCVGdqjjWnzuHGd/MxWU706pd7HuWjLVucEKA69zp9FqoBf/+qrnLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X2UF6ukk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="X2UF6ukk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8CB5C4CEE4; Thu, 22 May 2025 11:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747912914; bh=GCD+itmTe0b/J+qM5d/v9KELzW7ui94Qc8QFqpcbKRU=; h=From:To:Cc:Subject:Date:From; b=X2UF6ukk+tKDTt0kPLw/7GhH+/e7aKlEhp97dDHCPLmB5yeIHdByPelphTX4hh0Zs p7pdo+v+5HoR4wQc4uxD4Chrl0aItfyGalhUTTqwbtblQnW+EhcroRTIfyd1Y5/yp3 ydDrXXADhUJML9MjTBwAZaLIBYEda7aQgZUA4lpM= From: Greg Kroah-Hartman To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Alexander Lobakin , Andrew Lunn , Heiner Kallweit , Russell King Subject: [PATCH net-next] net: phy: fix up const issues in to_mdio_device() and to_phy_device() Date: Thu, 22 May 2025 13:21:47 +0200 Message-ID: <2025052246-conduit-glory-8fc9@gregkh> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1872; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=GCD+itmTe0b/J+qM5d/v9KELzW7ui94Qc8QFqpcbKRU=; b=owGbwMvMwCRo6H6F97bub03G02pJDBn6HKdmMJrd3yc0ewrXk/0MpXzXFie97J75PVmRu6jv7 tvDD2LYOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAizwUYFswO3Xj21hmN8/Eq zNsDX0isiOE3sGZYcILp8+Tsnn6HzHXbbif6/zkh/FrjGAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Both to_mdio_device() and to_phy_device() "throw away" the const pointer attribute passed to them and return a non-const pointer, which generally is not a good thing overall. Fix this up by using container_of_const() which was designed for this very problem. Cc: Alexander Lobakin Cc: Andrew Lunn Cc: Heiner Kallweit Cc: Russell King Fixes: 7eab14de73a8 ("mdio, phy: fix -Wshadow warnings triggered by nested = container_of()") Signed-off-by: Greg Kroah-Hartman --- include/linux/mdio.h | 5 +---- include/linux/phy.h | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 3c3deac57894..e43ff9f980a4 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -45,10 +45,7 @@ struct mdio_device { unsigned int reset_deassert_delay; }; =20 -static inline struct mdio_device *to_mdio_device(const struct device *dev) -{ - return container_of(dev, struct mdio_device, dev); -} +#define to_mdio_device(__dev) container_of_const(__dev, struct mdio_device= , dev) =20 /* struct mdio_driver_common: Common to all MDIO drivers */ struct mdio_driver_common { diff --git a/include/linux/phy.h b/include/linux/phy.h index a2bfae80c449..bef68f6af99a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -744,10 +744,7 @@ struct phy_device { #define PHY_F_NO_IRQ 0x80000000 #define PHY_F_RXC_ALWAYS_ON 0x40000000 =20 -static inline struct phy_device *to_phy_device(const struct device *dev) -{ - return container_of(to_mdio_device(dev), struct phy_device, mdio); -} +#define to_phy_device(__dev) container_of_const(to_mdio_device(__dev), str= uct phy_device, mdio) =20 /** * struct phy_tdr_config - Configuration of a TDR raw test --=20 2.49.0