Lines Matching defs:fwnode
15 #include <linux/fwnode.h>
53 * Create a fwnode link between fwnode handles @con and @sup. The fwnode link
54 * represents the detail that the firmware lists @sup fwnode as supplying a
57 * The driver core will use the fwnode link to create a device link between the
59 * driver core will automatically delete the fwnode link between @con and @sup
62 * Attempts to create duplicate links between the same pair of fwnode handles
88 pr_debug("%pfwf Linked as a fwnode consumer to %pfwf\n",
112 pr_debug("%pfwf Dropping the fwnode link to %pfwf\n",
120 * __fwnode_link_cycle - Mark a fwnode link as being part of a cycle.
134 * @fwnode: fwnode whose supplier links need to be deleted
136 * Deletes all supplier links connecting directly to @fwnode.
138 static void fwnode_links_purge_suppliers(struct fwnode_handle *fwnode)
143 list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook)
150 * @fwnode: fwnode whose consumer links need to be deleted
152 * Deletes all consumer links connecting directly to @fwnode.
154 static void fwnode_links_purge_consumers(struct fwnode_handle *fwnode)
159 list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook)
166 * @fwnode: fwnode whose links needs to be deleted
168 * Deletes all links connecting directly to a fwnode.
170 void fwnode_links_purge(struct fwnode_handle *fwnode)
172 fwnode_links_purge_suppliers(fwnode);
173 fwnode_links_purge_consumers(fwnode);
176 void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode)
181 if (fwnode->dev)
184 fwnode->flags |= FWNODE_FLAG_NOT_DEVICE;
185 fwnode_links_purge_consumers(fwnode);
187 fwnode_for_each_available_child_node(fwnode, child)
194 * @from: move consumers away from this fwnode
195 * @to: move consumers to this fwnode
197 * Move all consumer links from @from fwnode to @to fwnode.
212 * @fwnode: fwnode from which to pick up dangling consumers
213 * @new_sup: fwnode of new supplier
215 * If the @fwnode has a corresponding struct device and the device supports
217 * MANAGED device links to this device, so leave @fwnode and its descendant's
218 * fwnode links alone.
222 static void __fw_devlink_pickup_dangling_consumers(struct fwnode_handle *fwnode,
227 if (fwnode->dev && fwnode->dev->bus)
230 fwnode->flags |= FWNODE_FLAG_NOT_DEVICE;
231 __fwnode_links_move_consumers(fwnode, new_sup);
233 fwnode_for_each_available_child_node(fwnode, child)
1001 (dev->fwnode && (dev->fwnode->flags & FWNODE_FLAG_BEST_EFFORT));
1005 struct fwnode_handle *fwnode)
1009 if (!fwnode || fw_devlink_is_permissive())
1012 list_for_each_entry(link, &fwnode->suppliers, c_hook)
1046 sup_fw = fwnode_links_check_suppliers(dev->fwnode);
1234 val = !!fwnode_links_check_suppliers(dev->fwnode);
1306 if (dev->fwnode && dev->fwnode->dev == dev) {
1308 fwnode_links_purge_suppliers(dev->fwnode);
1310 fwnode_for_each_available_child_node(dev->fwnode, child)
1312 dev->fwnode);
1714 static void fw_devlink_parse_fwnode(struct fwnode_handle *fwnode)
1716 if (fwnode->flags & FWNODE_FLAG_LINKS_ADDED)
1719 fwnode_call_int_op(fwnode, add_links);
1720 fwnode->flags |= FWNODE_FLAG_LINKS_ADDED;
1723 static void fw_devlink_parse_fwtree(struct fwnode_handle *fwnode)
1727 fw_devlink_parse_fwnode(fwnode);
1729 while ((child = fwnode_get_next_available_child_node(fwnode, child)))
1874 static bool fwnode_init_without_drv(struct fwnode_handle *fwnode)
1879 if (!(fwnode->flags & FWNODE_FLAG_INITIALIZED))
1882 dev = get_dev_from_fwnode(fwnode);
1889 static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode)
1893 fwnode_for_each_parent_node(fwnode, parent) {
1906 * @sup_handle: Potential supplier's fwnode.
1914 * all fwnode links in the cycle with FWLINK_FLAG_CYCLE so that when they are
1970 * Give priority to device parent over fwnode parent to account for any
1978 if (par_dev && __fw_devlink_relax_cycles(con, par_dev->fwnode))
1994 dev_link->supplier->fwnode)) {
2009 * fw_devlink_create_devlink - Create a device link from a consumer to fwnode
2011 * @sup_handle: fwnode handle of supplier
2012 * @link: fwnode link that's being converted to a device link
2017 * The supplier has to be provided as a fwnode because incorrect cycles in
2018 * fwnode links can sometimes cause the supplier device to never be created.
2036 if (con->fwnode == link->consumer)
2057 fwnode_is_ancestor_of(sup_handle, con->fwnode))
2135 * of the consumer fwnode. This is necessary to make sure @dev doesn't get a
2140 * fwnode links are deleted.
2144 struct fwnode_handle *fwnode = dev->fwnode;
2147 list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) {
2172 fwnode_is_ancestor_of(con_dev->fwnode, fwnode)) {
2183 ret = fw_devlink_create_devlink(con_dev, fwnode, link);
2195 * @fwnode: Root of the fwnode tree that is used to create device links
2197 * This function looks at all the supplier fwnodes of fwnode tree rooted at
2198 * @fwnode and creates device links between @dev (consumer) and all the
2199 * supplier devices of the entire fwnode tree at @fwnode.
2203 * fwnode links are deleted.
2205 * In addition, it also looks at all the suppliers of the entire fwnode tree
2211 * their device links. The fwnode links that correspond to the child devices
2216 struct fwnode_handle *fwnode)
2218 bool own_link = (dev->fwnode == fwnode);
2222 list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) {
2239 while ((child = fwnode_get_next_available_child_node(fwnode, child)))
2245 struct fwnode_handle *fwnode = dev->fwnode;
2250 fw_devlink_parse_fwtree(fwnode);
2254 __fw_devlink_link_to_suppliers(dev, fwnode);
2863 if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) {
3626 if (dev->fwnode && !dev->fwnode->dev) {
3627 dev->fwnode->dev = dev;
3638 if (dev->fwnode && fw_devlink_drv_reg_done && !dev->can_match)
3786 if (dev->fwnode && dev->fwnode->dev == dev)
3787 dev->fwnode->dev = NULL;
4983 static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
4985 return fwnode && !IS_ERR(fwnode->secondary);
4991 * @fwnode: New primary firmware node of the device.
4993 * Set the device's firmware node pointer to @fwnode, but if a secondary
4996 * Valid fwnode cases are:
5002 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
5005 struct fwnode_handle *fn = dev->fwnode;
5007 if (fwnode) {
5012 WARN_ON(fwnode->secondary);
5013 fwnode->secondary = fn;
5015 dev->fwnode = fwnode;
5018 dev->fwnode = fn->secondary;
5021 if (parent && fn == parent->fwnode)
5024 /* Set fn->secondary = NULL, so fn remains the primary fwnode */
5027 dev->fwnode = NULL;
5036 * @fwnode: New secondary firmware node of the device.
5039 * pointer to @fwnode. Otherwise, set the device's firmware node pointer to
5040 * @fwnode.
5042 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
5044 if (fwnode)
5045 fwnode->secondary = ERR_PTR(-ENODEV);
5047 if (fwnode_is_primary(dev->fwnode))
5048 dev->fwnode->secondary = fwnode;
5050 dev->fwnode = fwnode;
5070 void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
5072 dev->fwnode = fwnode;
5073 dev->of_node = to_of_node(fwnode);
5089 int device_match_fwnode(struct device *dev, const void *fwnode)
5091 return dev_fwnode(dev) == fwnode;