From patchwork Fri Feb 2 17:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13543209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0C4FC4828F for ; Fri, 2 Feb 2024 17:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RfmO4Vl1U51NPwJZOTkQwfppfampzmWHTm/53zN52WI=; b=Qvkv9eb/k/gL0i fdeD6bknMdSMvHCFrGfrdjwWk6xqzh32z7ns492qS13965gMS7Mh+HXGAOfzeChQQFEvkjiOfPf9D Y8r8xiXhS+581kfeKDhgk0BWHpMQ6/TnmvET6QdzDaUVUhjop76FpfkTReVQi0cd3rG/R30zRaM5N 2VC5ZY37fhWOMkWnY1d+ZSyF0l3qqmSIuay0LeIl6KigENloHWT6O0GPdScCusey6PQ4VnB/doySy HGiFoLsKUX+EwYDgoxe4eXiKOl5bbHzo7I4gSQiP5Vja4LTnSNswQ0SmtO9ZZWBiQgW+dRZW4vCcf AualBF+uXI6stz/yngrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVxY6-0000000Cecs-2ETe; Fri, 02 Feb 2024 17:41:58 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVxY3-0000000Ceac-25Zd for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 17:41:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9qR1zIZh07zNkVqp/d7/uODkvoKa5K4GkkM8O77GA6I=; b=wCMAc8a1bizfawvI7ySmVbmL6f tUP9l7N/KOa/mQFaabzUR8xrKhpdyapvgIXaYTMzNvcoaWFdYk5bX1hduxiA7BVVFQNOC0Pm2WIsk QOsXthzsT8OpL6tjOMaPIuaQXmTWeSlbBGbEirwFQgK6w9L8frFr2HFZu2f87CvAXhA+TU1hT2cbR O2n2u9xAvfNoMacBtFVmmuXm9qfrMB2O9l8mRQyZwvxxtagm59aJiBMyotBYo6O9JIvjUl1HeW47h 3UIo6+G19MwnHfNDk+dWsvGm2YcARFHSsluUz5zvGkRec6Znl1RJ9vzA23e4FATXoLWVfaPyyLUVE L13ltR7g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:38922 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rVxXu-0006I0-0h; Fri, 02 Feb 2024 17:41:46 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rVxXt-002YqY-9G; Fri, 02 Feb 2024 17:41:45 +0000 From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Christian Marangi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Simek , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next] net: phy: constify phydev->drv MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 02 Feb 2024 17:41:45 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240202_094155_561716_36817F6E X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Device driver structures are shared between all devices that they match, and thus nothing should never write to the device driver structure through the phydev->drv pointer. Let's make this pointer const to catch code that attempts to do so. Suggested-by: Christian Marangi Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phy.c | 3 +-- drivers/net/phy/phy_device.c | 6 +++--- drivers/net/phy/xilinx_gmii2rgmii.c | 2 +- include/linux/phy.h | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 3b9531143be1..14224e06d69f 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1290,7 +1290,6 @@ int phy_disable_interrupts(struct phy_device *phydev) static irqreturn_t phy_interrupt(int irq, void *phy_dat) { struct phy_device *phydev = phy_dat; - struct phy_driver *drv = phydev->drv; irqreturn_t ret; /* Wakeup interrupts may occur during a system sleep transition. @@ -1316,7 +1315,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) } mutex_lock(&phydev->lock); - ret = drv->handle_interrupt(phydev); + ret = phydev->drv->handle_interrupt(phydev); mutex_unlock(&phydev->lock); return ret; diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 52828d1c64f7..2eed8f03621d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1413,7 +1413,7 @@ int phy_sfp_probe(struct phy_device *phydev, } EXPORT_SYMBOL(phy_sfp_probe); -static bool phy_drv_supports_irq(struct phy_driver *phydrv) +static bool phy_drv_supports_irq(const struct phy_driver *phydrv) { return phydrv->config_intr && phydrv->handle_interrupt; } @@ -1867,7 +1867,7 @@ int phy_suspend(struct phy_device *phydev) { struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; struct net_device *netdev = phydev->attached_dev; - struct phy_driver *phydrv = phydev->drv; + const struct phy_driver *phydrv = phydev->drv; int ret; if (phydev->suspended) @@ -1892,7 +1892,7 @@ EXPORT_SYMBOL(phy_suspend); int __phy_resume(struct phy_device *phydev) { - struct phy_driver *phydrv = phydev->drv; + const struct phy_driver *phydrv = phydev->drv; int ret; lockdep_assert_held(&phydev->lock); diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c index 7fd9fe6a602b..7b1bc5fcef9b 100644 --- a/drivers/net/phy/xilinx_gmii2rgmii.c +++ b/drivers/net/phy/xilinx_gmii2rgmii.c @@ -22,7 +22,7 @@ struct gmii2rgmii { struct phy_device *phy_dev; - struct phy_driver *phy_drv; + const struct phy_driver *phy_drv; struct phy_driver conv_phy_drv; struct mdio_device *mdio; }; diff --git a/include/linux/phy.h b/include/linux/phy.h index a66f07d3f5f4..ad93f8b1b128 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -638,7 +638,7 @@ struct phy_device { /* Information about the PHY type */ /* And management functions */ - struct phy_driver *drv; + const struct phy_driver *drv; struct device_link *devlink;