Skip to content

Commit 1c4002a

Browse files
andy-shevgregkh
authored andcommitted
driver core: Move fw_devlink stuff to where it belongs
A few APIs, i.e. fwnode_is_ancestor_of(), fwnode_get_next_parent_dev(), and get_dev_from_fwnode(), that belong specifically to the fw_devlink APIs, may be static, but they are not. Resolve this mess by moving them to the driver/base/core where the all users are being resided and make static. No functional changes intended. Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: "Rafael J. Wysocki" <rafael@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240301180138.271590-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bbf6cfb commit 1c4002a

4 files changed

Lines changed: 58 additions & 59 deletions

File tree

drivers/base/core.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,7 @@ static void fw_devlink_unblock_consumers(struct device *dev)
18711871
device_links_write_unlock();
18721872
}
18731873

1874+
#define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev)
18741875

18751876
static bool fwnode_init_without_drv(struct fwnode_handle *fwnode)
18761877
{
@@ -1901,6 +1902,63 @@ static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode)
19011902
return false;
19021903
}
19031904

1905+
/**
1906+
* fwnode_is_ancestor_of - Test if @ancestor is ancestor of @child
1907+
* @ancestor: Firmware which is tested for being an ancestor
1908+
* @child: Firmware which is tested for being the child
1909+
*
1910+
* A node is considered an ancestor of itself too.
1911+
*
1912+
* Return: true if @ancestor is an ancestor of @child. Otherwise, returns false.
1913+
*/
1914+
static bool fwnode_is_ancestor_of(const struct fwnode_handle *ancestor,
1915+
const struct fwnode_handle *child)
1916+
{
1917+
struct fwnode_handle *parent;
1918+
1919+
if (IS_ERR_OR_NULL(ancestor))
1920+
return false;
1921+
1922+
if (child == ancestor)
1923+
return true;
1924+
1925+
fwnode_for_each_parent_node(child, parent) {
1926+
if (parent == ancestor) {
1927+
fwnode_handle_put(parent);
1928+
return true;
1929+
}
1930+
}
1931+
return false;
1932+
}
1933+
1934+
/**
1935+
* fwnode_get_next_parent_dev - Find device of closest ancestor fwnode
1936+
* @fwnode: firmware node
1937+
*
1938+
* Given a firmware node (@fwnode), this function finds its closest ancestor
1939+
* firmware node that has a corresponding struct device and returns that struct
1940+
* device.
1941+
*
1942+
* The caller is responsible for calling put_device() on the returned device
1943+
* pointer.
1944+
*
1945+
* Return: a pointer to the device of the @fwnode's closest ancestor.
1946+
*/
1947+
static struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwnode)
1948+
{
1949+
struct fwnode_handle *parent;
1950+
struct device *dev;
1951+
1952+
fwnode_for_each_parent_node(fwnode, parent) {
1953+
dev = get_dev_from_fwnode(parent);
1954+
if (dev) {
1955+
fwnode_handle_put(parent);
1956+
return dev;
1957+
}
1958+
}
1959+
return NULL;
1960+
}
1961+
19041962
/**
19051963
* __fw_devlink_relax_cycles - Relax and mark dependency cycles.
19061964
* @con: Potential consumer device.

drivers/base/property.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -699,34 +699,6 @@ struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode)
699699
}
700700
EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
701701

702-
/**
703-
* fwnode_get_next_parent_dev - Find device of closest ancestor fwnode
704-
* @fwnode: firmware node
705-
*
706-
* Given a firmware node (@fwnode), this function finds its closest ancestor
707-
* firmware node that has a corresponding struct device and returns that struct
708-
* device.
709-
*
710-
* The caller is responsible for calling put_device() on the returned device
711-
* pointer.
712-
*
713-
* Return: a pointer to the device of the @fwnode's closest ancestor.
714-
*/
715-
struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwnode)
716-
{
717-
struct fwnode_handle *parent;
718-
struct device *dev;
719-
720-
fwnode_for_each_parent_node(fwnode, parent) {
721-
dev = get_dev_from_fwnode(parent);
722-
if (dev) {
723-
fwnode_handle_put(parent);
724-
return dev;
725-
}
726-
}
727-
return NULL;
728-
}
729-
730702
/**
731703
* fwnode_count_parents - Return the number of parents a node has
732704
* @fwnode: The node the parents of which are to be counted
@@ -773,34 +745,6 @@ struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwnode,
773745
}
774746
EXPORT_SYMBOL_GPL(fwnode_get_nth_parent);
775747

776-
/**
777-
* fwnode_is_ancestor_of - Test if @ancestor is ancestor of @child
778-
* @ancestor: Firmware which is tested for being an ancestor
779-
* @child: Firmware which is tested for being the child
780-
*
781-
* A node is considered an ancestor of itself too.
782-
*
783-
* Return: true if @ancestor is an ancestor of @child. Otherwise, returns false.
784-
*/
785-
bool fwnode_is_ancestor_of(const struct fwnode_handle *ancestor, const struct fwnode_handle *child)
786-
{
787-
struct fwnode_handle *parent;
788-
789-
if (IS_ERR_OR_NULL(ancestor))
790-
return false;
791-
792-
if (child == ancestor)
793-
return true;
794-
795-
fwnode_for_each_parent_node(child, parent) {
796-
if (parent == ancestor) {
797-
fwnode_handle_put(parent);
798-
return true;
799-
}
800-
}
801-
return false;
802-
}
803-
804748
/**
805749
* fwnode_get_next_child_node - Return the next child node handle for a node
806750
* @fwnode: Firmware node to find the next child node for.

include/linux/fwnode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ struct fwnode_operations {
187187
if (fwnode_has_op(fwnode, op)) \
188188
(fwnode)->ops->op(fwnode, ## __VA_ARGS__); \
189189
} while (false)
190-
#define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev)
191190

192191
static inline void fwnode_init(struct fwnode_handle *fwnode,
193192
const struct fwnode_operations *ops)

include/linux/property.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@ struct fwnode_handle *fwnode_get_next_parent(struct fwnode_handle *fwnode);
156156
for (parent = fwnode_get_parent(fwnode); parent; \
157157
parent = fwnode_get_next_parent(parent))
158158

159-
struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwnode);
160159
unsigned int fwnode_count_parents(const struct fwnode_handle *fwn);
161160
struct fwnode_handle *fwnode_get_nth_parent(struct fwnode_handle *fwn,
162161
unsigned int depth);
163-
bool fwnode_is_ancestor_of(const struct fwnode_handle *ancestor, const struct fwnode_handle *child);
164162
struct fwnode_handle *fwnode_get_next_child_node(
165163
const struct fwnode_handle *fwnode, struct fwnode_handle *child);
166164
struct fwnode_handle *fwnode_get_next_available_child_node(

0 commit comments

Comments
 (0)