Re: [PATCH v20 2/6] phy: core: Add phy_get_by_of_node()
From: Bryan O'Donoghue
Date: Fri Sep 18 2026 - 11:27:10 EST
On 18/09/2026 15:10, Neil Armstrong wrote:
EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);
+/**
+ * phy_get_by_of_node() - lookup and obtain a reference to a phy by device_node
+ * @np: node containing the phy
+ *
+ * Returns: the phy associated with the device node or ERR_PTR.
+ */
+struct phy *phy_get_by_of_node(struct device_node *np)
+{
+ struct of_phandle_args args = { .np = np, .args_count = 0 };
+ struct phy *phy;
+
+ mutex_lock(&phy_provider_mutex);
I don't really understand the usage of lockdep_assert_held(), but why
does _of_phy_get() uses lockdep_assert_held() and here you use mutex_lock()
like before patch 1 ?
Neil
assert_lockdep_held() is just an assertion that the lock is held, Loic suggested adding it BTW. It ensures that when another function calls this function it holds phy_provider_mutex.
i.e.
phy_get_by_of_node()
{
mutex_lock(&phy_provider_mutex);
_of_phy_get();
mutex_unlock(&phy_provider_mutex);
}
EXPORT_SYMBOL(phy_get_by_of_node);
_of_phy_get()
{
lockdep_assert_held(&phy_provider_mutex);
/* happy days */
}
phy_broken_locking()
{
_of_phy_get();
}
EXPORT_SYMBOL(phy_broken_locking);
_of_phy_get()
{
lockdep_assert_held(&phy_provider_mutex);
/* wails plaintively into the void */
}
---
bod