We already have the of_genpd_add_subdomain() helper, but no corresponding of_genpd_remove_subdomain(), so let's add it. Subsequent changes starts to make use of it.
Unified · Split
| @@ -2302,6 +2302,44 @@ out: · 2301 unmodified lines | |||
| 2302 | } | 2302 | } |
| 2303 | EXPORT_SYMBOL_GPL(of_genpd_add_subdomain); | 2303 | EXPORT_SYMBOL_GPL(of_genpd_add_subdomain); |
| 2304 | 2304 | ||
| 2305 | /** | ||
| 2306 | * of_genpd_remove_subdomain - Remove a subdomain from an I/O PM domain. | ||
| 2307 | * @parent_spec: OF phandle args to use for parent PM domain look-up | ||
| 2308 | * @subdomain_spec: OF phandle args to use for subdomain look-up | ||
| 2309 | * | ||
| 2310 | * Looks-up a parent PM domain and subdomain based upon phandle args | ||
| 2311 | * provided and removes the subdomain from the parent PM domain. Returns a | ||
| 2312 | * negative error code on failure. | ||
| 2313 | */ | ||
| 2314 | int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec, | ||
| 2315 | struct of_phandle_args *subdomain_spec) | ||
| 2316 | { | ||
| 2317 | struct generic_pm_domain *parent, *subdomain; | ||
| 2318 | int ret; | ||
| 2319 | |||
| 2320 | mutex_lock(&gpd_list_lock); | ||
| 2321 | |||
| 2322 | parent = genpd_get_from_provider(parent_spec); | ||
| 2323 | if (IS_ERR(parent)) { | ||
| 2324 | ret = PTR_ERR(parent); | ||
| 2325 | goto out; | ||
| 2326 | } | ||
| 2327 | |||
| 2328 | subdomain = genpd_get_from_provider(subdomain_spec); | ||
| 2329 | if (IS_ERR(subdomain)) { | ||
| 2330 | ret = PTR_ERR(subdomain); | ||
| 2331 | goto out; | ||
| 2332 | } | ||
| 2333 | |||
| 2334 | ret = pm_genpd_remove_subdomain(parent, subdomain); | ||
| 2335 | |||
| 2336 | out: | ||
| 2337 | mutex_unlock(&gpd_list_lock); | ||
| 2338 | |||
| 2339 | return ret; | ||
| 2340 | } | ||
| 2341 | EXPORT_SYMBOL_GPL(of_genpd_remove_subdomain); | ||
| 2342 | |||
| 2305 | /** | 2343 | /** |
| 2306 | * of_genpd_remove_last - Remove the last PM domain registered for a provider | 2344 | * of_genpd_remove_last - Remove the last PM domain registered for a provider |
| 2307 | * @provider: Pointer to device structure associated with provider | 2345 | * @provider: Pointer to device structure associated with provider |
| @@ -284,6 +284,8 @@ void of_genpd_del_provider(struct device_node *np); · 283 unmodified lines | |||
| 284 | int of_genpd_add_device(struct of_phandle_args *args, struct device *dev); | 284 | int of_genpd_add_device(struct of_phandle_args *args, struct device *dev); |
| 285 | int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, | 285 | int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, |
| 286 | struct of_phandle_args *subdomain_spec); | 286 | struct of_phandle_args *subdomain_spec); |
| 287 | int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec, | ||
| 288 | struct of_phandle_args *subdomain_spec); | ||
| 287 | struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); | 289 | struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); |
| 288 | int of_genpd_parse_idle_states(struct device_node *dn, | 290 | int of_genpd_parse_idle_states(struct device_node *dn, |
| 289 | struct genpd_power_state **states, int *n); | 291 | struct genpd_power_state **states, int *n); |
| @@ -322,6 +324,12 @@ static inline int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, · 32 unmodified lines | |||
| 322 | return -ENODEV; | 324 | return -ENODEV; |
| 323 | } | 325 | } |
| 324 | 326 | ||
| 327 | static inline int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec, | ||
| 328 | struct of_phandle_args *subdomain_spec) | ||
| 329 | { | ||
| 330 | return -ENODEV; | ||
| 331 | } | ||
| 332 | |||
| 325 | static inline int of_genpd_parse_idle_states(struct device_node *dn, | 333 | static inline int of_genpd_parse_idle_states(struct device_node *dn, |
| 326 | struct genpd_power_state **states, int *n) | 334 | struct genpd_power_state **states, int *n) |
| 327 | { | 335 | { |