From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 960C5582BAF for ; Tue, 8 Sep 2026 15:57:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788883038; cv=none; b=QroYFHXIuBsfeGCRMJrPvjhQhxSb+m523ph5Nq33Yq1LOiIhvxcUP/1XKHlqa6kNqMDNLELoyM54dUDLZGOGy1nOzgAxSsMxHKLlAngh8GJ9g0Qdv6O61nYa8D3tJbCCJc+QWDn/EA3+/Z4FS8835+G+GbQNdiiTF+44EphbV4k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788883038; c=relaxed/simple; bh=K244GoaR/SBN1qTkqznMbdB/qRyg1uAQxHof7eZyYLA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GYSC/kBTJD4WkMdHv0UJIh0nSz7Cp+PV822P0WnY7HKDajEDuxt1ppRaVtej9yTgEqfl3PThDtcPcko6M6Y7JhBt3xpDQRzBEfLhG1ihwfQOTu6bfXdJoXL8gNDUVU/mthuQGgpOTNZMNm7782LO9vLZjzrGNwihrIGlqwRaIDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la; spf=pass smtp.mailfrom=lex.la; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b=BP8nITiC; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=lex.la Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lex.la Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lex.la header.i=@lex.la header.b="BP8nITiC" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-482dd6ee390so5489599f8f.3 for ; Tue, 08 Sep 2026 08:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lex.la; s=google; t=1788883033; x=1789487833; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nwJE/G6DLPhkatwmSaqyq8HEYQKnbZm9tru5auWihS0=; b=BP8nITiCIEsy0JEGklGDMKuWpAgorlXpkH2F6YRnmPqaFXdDadP5kPIJNyMvNluzlG aM539YAje5/MxDx7hzLBGUoaBuLKGfS9kPHLa+GT43rnS+S2dy3WxZ50e0V4RqrKO20z QrN5H7GtW4XojmW1rowEd73eYpdM3VpBh4Vsa+uNh+LzdLLPFz/SFLDOsg3QA7Lssb1i 1/qSvlHJRXiEKXy0xHpte6oxGp8vk1XkJBYLpsA7QPMHyaknAlcGqVV3LBpWaU/2rmOp ngC8yS/WL9i4K3epRWdtH3OrAG0tWU7Dyv3j1aYUwkkrQ5mKxGPpYeRulDnJO/oDGwkS FW2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788883033; x=1789487833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=nwJE/G6DLPhkatwmSaqyq8HEYQKnbZm9tru5auWihS0=; b=BeiT+/jpfIJZZC/9GFNdmI4hOQc2DYxDPyEGVcj5oAIB6ib0+8KLMEW0D3BR+Y2mqP hdKKxYlrVS0YM6FS+lmaPcheYHl0By7ICPb/SEmp9N4TeaqGRMPqqZxCJAxALwZz8eNS dmloE9f74kYJCsLXpsgnxFbG3qhJ0kznZN8kcOCbMNesZh4RAfTfVxC+8wQChncWOJOl 5IxdmLCaxmo5Y0Q3IRbsPjC+XwLqPeot07aD3k5/urn6huQGjSH8rqWUFVbnKXM4dtF8 78OhhOm+eOfqrf+efj2x/WgdU46vRTVFQFh4AtSq1CpNVOqi8Tzw7SEo/0IsPnXDNZor Q70A== X-Forwarded-Encrypted: i=1; AKwUvBxQDBLTIMGXlw0hyX+4k6i7u3OcJAIyPTcC8Zmua/qDX5Gt+DApaoSqcLc6IohLDEvDFQ4rDGBCpzJr@vger.kernel.org X-Gm-Message-State: AFuF++kta2f+yBFhq6lDfHn79DjII3GVieXnYvX1/hUopFAUEUHFbtM0 t7ouzj1P5tPCPF/J5Mm0OoACbV3bCf1wjUWfpaSt9PcEBXq5EOntSC3beKt7SUdxgIE= X-Gm-Gg: AYBFou0M85QYFgcccUcVEhxlP5BdCmGADKBoMOPnXPllrrU98wDYj0necBT9Yq0r8Oq Z/JxYpV5F0nAJDfkQDMSUTSVCdFD6dOON1zUlEEFWzW0zWZZoH4kTV27fyzlblDDBs+KAxoJnik hy+IwhmAwegLKwctgNgq08zxxkhpLO9Dx6V33hh1b7M7wtMBHKi49SKfeFsRbti5wZTsD8ozW6/ qt4XMR+70oZijw8nIHam4VdOsg590SE07OMZZLaA7/BM2ZDFAbi7PozB/osngKQYUcU+96EQwl8 T2pjVH1tsZfqlLginNYKnBvnGcirNRdKNFBNQfQqRrbS2jTKWyvwuEPAD9nOktHFDW3a/nIhdTI K2Da5O/xytCjfy3Yv7GcX83LzfORtgKMSCUarANTzMyoGFpZndnVXLxy+P2D1ujlvU2X7JJdSnr 7pRsZis78jaSN09Xh+PtqyKwkSW5HjKx9HWNtt9m47jr48PYioUg== X-Received: by 2002:a05:6000:2c11:b0:485:8c16:a340 with SMTP id ffacd0b85a97d-4858c16a82bmr28568008f8f.53.1788883033146; Tue, 08 Sep 2026 08:57:13 -0700 (PDT) Received: from remote-01 ([84.17.55.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-485883be709sm37345704f8f.21.2026.09.08.08.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2026 08:57:12 -0700 (PDT) From: Aleksei Sviridkin To: andrew@lunn.ch, andrew+netdev@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org Cc: ericwouds@gmail.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Aleksei Sviridkin Subject: [RFC PATCH net-next v2 2/7] net: phy: add mdiodev_lock(), mdiodev_lock_nested() and mdiodev_unlock() Date: Tue, 8 Sep 2026 15:57:02 +0000 Message-ID: <20260908155707.4164559-3-f@lex.la> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260908155707.4164559-1-f@lex.la> References: <20260908155707.4164559-1-f@lex.la> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Code that holds the MDIO bus across a burst of transactions has phy_lock_mdio_bus(), which needs a phy_device. A library serving a chip before its phy_device exists has to open-code the same mutex. Add the mdio_device spelling beside it. The nested form is for a library whose caller already holds the bus one level up, which is what the EN8811H MDIO driver later in this series does. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- include/linux/phy.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 3d8afe6b7f1c..e74a8f5cf5c6 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -2284,6 +2284,22 @@ static inline void phy_unlock_mdio_bus(struct phy_device *phydev) mutex_unlock(&phydev->mdio.bus->mdio_lock); } +static inline void mdiodev_lock(struct mdio_device *mdiodev) +{ + mutex_lock(&mdiodev->bus->mdio_lock); +} + +/* For a bus reached through another one, as mdiobus_read_nested() is. */ +static inline void mdiodev_lock_nested(struct mdio_device *mdiodev) +{ + mutex_lock_nested(&mdiodev->bus->mdio_lock, MDIO_MUTEX_NESTED); +} + +static inline void mdiodev_unlock(struct mdio_device *mdiodev) +{ + mutex_unlock(&mdiodev->bus->mdio_lock); +} + void phy_attached_print(struct phy_device *phydev, const char *fmt, ...) __printf(2, 3); char *phy_attached_info_irq(struct phy_device *phydev) -- 2.53.0