Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver core: fw_devlink: Consolidate device link flag computation

Consolidate the code that computes the flags to be used when creating a
device link from a fwnode link.

Fixes: 2de9d8e0d2fe ("driver core: fw_devlink: Improve handling of cyclic dependencies")
Signed-off-by: Saravana Kannan <saravanak@google.com>
Tested-by: Colin Foster <colin.foster@in-advantage.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Luca Weiss <luca.weiss@fairphone.com> # qcom/sm7225-fairphone-fp4
Link: https://lore.kernel.org/r/20230207014207.1678715-8-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Saravana Kannan and committed by
Greg Kroah-Hartman
cd115c04 6a6dfdf8

+15 -14
+15 -13
drivers/base/core.c
··· 1727 1727 } 1728 1728 early_param("fw_devlink.strict", fw_devlink_strict_setup); 1729 1729 1730 - u32 fw_devlink_get_flags(void) 1730 + static inline u32 fw_devlink_get_flags(u8 fwlink_flags) 1731 1731 { 1732 + if (fwlink_flags & FWLINK_FLAG_CYCLE) 1733 + return FW_DEVLINK_FLAGS_PERMISSIVE | DL_FLAG_CYCLE; 1734 + 1732 1735 return fw_devlink_flags; 1733 1736 } 1734 1737 ··· 1941 1938 * fw_devlink_create_devlink - Create a device link from a consumer to fwnode 1942 1939 * @con: consumer device for the device link 1943 1940 * @sup_handle: fwnode handle of supplier 1944 - * @flags: devlink flags 1941 + * @link: fwnode link that's being converted to a device link 1945 1942 * 1946 1943 * This function will try to create a device link between the consumer device 1947 1944 * @con and the supplier device represented by @sup_handle. ··· 1958 1955 * possible to do that in the future 1959 1956 */ 1960 1957 static int fw_devlink_create_devlink(struct device *con, 1961 - struct fwnode_handle *sup_handle, u32 flags) 1958 + struct fwnode_handle *sup_handle, 1959 + struct fwnode_link *link) 1962 1960 { 1963 1961 struct device *sup_dev; 1964 1962 int ret = 0; 1963 + u32 flags; 1964 + 1965 + if (con->fwnode == link->consumer) 1966 + flags = fw_devlink_get_flags(link->flags); 1967 + else 1968 + flags = FW_DEVLINK_FLAGS_PERMISSIVE; 1965 1969 1966 1970 /* 1967 1971 * In some cases, a device P might also be a supplier to its child node ··· 2101 2091 struct fwnode_link *link, *tmp; 2102 2092 2103 2093 list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { 2104 - u32 dl_flags = fw_devlink_get_flags(); 2105 2094 struct device *con_dev; 2106 2095 bool own_link = true; 2107 2096 int ret; ··· 2130 2121 con_dev = NULL; 2131 2122 } else { 2132 2123 own_link = false; 2133 - dl_flags = FW_DEVLINK_FLAGS_PERMISSIVE; 2134 2124 } 2135 2125 } 2136 2126 2137 2127 if (!con_dev) 2138 2128 continue; 2139 2129 2140 - ret = fw_devlink_create_devlink(con_dev, fwnode, dl_flags); 2130 + ret = fw_devlink_create_devlink(con_dev, fwnode, link); 2141 2131 put_device(con_dev); 2142 2132 if (!own_link || ret == -EAGAIN) 2143 2133 continue; ··· 2177 2169 bool own_link = (dev->fwnode == fwnode); 2178 2170 struct fwnode_link *link, *tmp; 2179 2171 struct fwnode_handle *child = NULL; 2180 - u32 dl_flags; 2181 - 2182 - if (own_link) 2183 - dl_flags = fw_devlink_get_flags(); 2184 - else 2185 - dl_flags = FW_DEVLINK_FLAGS_PERMISSIVE; 2186 2172 2187 2173 list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { 2188 2174 int ret; 2189 2175 struct device *sup_dev; 2190 2176 struct fwnode_handle *sup = link->supplier; 2191 2177 2192 - ret = fw_devlink_create_devlink(dev, sup, dl_flags); 2178 + ret = fw_devlink_create_devlink(dev, sup, link); 2193 2179 if (!own_link || ret == -EAGAIN) 2194 2180 continue; 2195 2181
-1
include/linux/fwnode.h
··· 207 207 fwnode->flags &= ~FWNODE_FLAG_INITIALIZED; 208 208 } 209 209 210 - extern u32 fw_devlink_get_flags(void); 211 210 extern bool fw_devlink_is_strict(void); 212 211 int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup); 213 212 void fwnode_links_purge(struct fwnode_handle *fwnode);