From: Christian Marangi <ansuelsmth@gmail.com>
To: Christian Marangi <ansuelsmth@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [net-next RFC PATCH 1/4] net: mdio: implement mdio_mutex_nested guard() variant
Date: Mon, 21 Oct 2024 15:01:56 +0200 [thread overview]
Message-ID: <20241021130209.15660-2-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20241021130209.15660-1-ansuelsmth@gmail.com>
Implement mdio_mutex_nested guard() variant.
guard() comes from the cleanup.h API that defines handy class to
handle the lifecycle of a critical section.
Several drivers use of the mutex_lock_nested()/mutex_unlock() function
call pair hence it is sensible to provide a variant of the generic
guard(mutex), guard(mdio_mutex_nested) so that drivers can be better
supported with the call variant "mutex_lock_nested(..., MDIO_MUTEX_NESTED)"
Example usage:
guard(mutex_lock_nested)(&bus->mdio_lock)
scoped_guard(mutex_lock_nested, &bus->mdio_lock) { ... }
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
include/linux/mdio.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index efeca5bd7600..3f0691dee46a 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -8,6 +8,7 @@
#include <uapi/linux/mdio.h>
#include <linux/bitfield.h>
+#include <linux/mutex.h>
#include <linux/mod_devicetable.h>
struct gpio_desc;
@@ -25,6 +26,9 @@ enum mdio_mutex_lock_class {
MDIO_MUTEX_NESTED,
};
+DEFINE_GUARD(mdio_mutex_nested, struct mutex *,
+ mutex_lock_nested(_T, MDIO_MUTEX_NESTED), mutex_unlock(_T))
+
struct mdio_device {
struct device dev;
--
2.45.2
next prev parent reply other threads:[~2024-10-21 13:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 13:01 [net-next RFC PATCH 0/4] net: dsa: Add Airoha AN8855 support Christian Marangi
2024-10-21 13:01 ` Christian Marangi [this message]
2024-10-21 13:01 ` [net-next RFC PATCH 2/4] dt-bindings: net: dsa: Add Airoha AN8855 Gigabit Switch documentation Christian Marangi
2024-10-21 13:01 ` [net-next RFC PATCH 3/4] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2024-10-21 14:08 ` Russell King (Oracle)
2024-10-21 14:39 ` Christian Marangi
2024-10-24 11:58 ` kernel test robot
2024-10-24 15:52 ` kernel test robot
2024-10-21 13:01 ` [net-next RFC PATCH 4/4] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2024-10-21 13:36 ` [net-next RFC PATCH 0/4] net: dsa: Add Airoha AN8855 support Vladimir Oltean
2024-10-21 13:39 ` Christian Marangi
2024-10-21 13:50 ` Vladimir Oltean
2024-10-21 14:11 ` Russell King (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241021130209.15660-2-ansuelsmth@gmail.com \
--to=ansuelsmth@gmail.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.