* @brief Get a clock object from a device tree node without acquiring a lock * * @param np point to ofw node * @param index index of clock in ofw * @param name connection identifier for the clock * @param locked lock flag for indicating whether the caller holds the lock * * @return struct rt_clk* point to the newly created clock object,
| 1189 | * @return struct rt_clk* point to the newly created clock object, or an error pointer |
| 1190 | */ |
| 1191 | static struct rt_clk *ofw_get_clk_no_lock(struct rt_ofw_node *np, int index, const char *name, rt_bool_t locked) |
| 1192 | { |
| 1193 | struct rt_clk *clk = RT_NULL; |
| 1194 | struct rt_ofw_cell_args clk_args; |
| 1195 | |
| 1196 | if (!rt_ofw_parse_phandle_cells(np, "clocks", "#clock-cells", index, &clk_args)) |
| 1197 | { |
| 1198 | int count; |
| 1199 | struct rt_object *obj; |
| 1200 | struct rt_clk_node *clk_np = RT_NULL; |
| 1201 | struct rt_ofw_node *clk_ofw_np = clk_args.data; |
| 1202 | |
| 1203 | if (!rt_ofw_data(clk_ofw_np)) |
| 1204 | { |
| 1205 | if (locked) |
| 1206 | { |
| 1207 | rt_hw_spin_unlock(&_clk_lock.lock); |
| 1208 | } |
| 1209 | |
| 1210 | rt_platform_ofw_request(clk_ofw_np); |
| 1211 | |
| 1212 | if (locked) |
| 1213 | { |
| 1214 | rt_hw_spin_lock(&_clk_lock.lock); |
| 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | if (rt_ofw_data(clk_ofw_np) && (obj = rt_ofw_parse_object(clk_ofw_np, |
| 1219 | RT_CLK_NODE_OBJ_NAME, "#clock-cells"))) |
| 1220 | { |
| 1221 | clk_np = rt_container_of(obj, struct rt_clk_node, rt_parent); |
| 1222 | |
| 1223 | count = rt_ofw_count_of_clk(clk_ofw_np); |
| 1224 | } |
| 1225 | |
| 1226 | rt_ofw_node_put(clk_ofw_np); |
| 1227 | |
| 1228 | if (clk_np) |
| 1229 | { |
| 1230 | if (count > 1) |
| 1231 | { |
| 1232 | /* args[0] must be the index of CLK */ |
| 1233 | clk_np = &clk_np[clk_args.args[0]]; |
| 1234 | } |
| 1235 | |
| 1236 | clk = clk_create(clk_np, np->full_name, name, &clk_args, np); |
| 1237 | } |
| 1238 | else |
| 1239 | { |
| 1240 | clk = rt_err_ptr(-RT_ERROR); |
| 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | return clk; |
| 1245 | } |
| 1246 | |
| 1247 | /** |
| 1248 | * @brief Get clock from ofw with acquiring a spin lock |
no test coverage detected