History

PM / Domains: Introduce a genpd OF helper that removes a subdomain

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.

Ulf Hansson committed 6 years ago

Commit dedd1491 parent 9c6ceec2 files · +46 −0Browse files

Unified · Split

2 files
  1. drivers/base/power/domain.c +38 −0
  2. include/linux/pm_domain.h +8 −0
drivers/base/power/domain.c+38−0
@@ -2302,6 +2302,44 @@ out: · 2301 unmodified lines
23022302 }
23032303 EXPORT_SYMBOL_GPL(of_genpd_add_subdomain);
23042304
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+
23052343 /**
23062344 * of_genpd_remove_last - Remove the last PM domain registered for a provider
23072345 * @provider: Pointer to device structure associated with provider
include/linux/pm_domain.h+8−0
@@ -284,6 +284,8 @@ void of_genpd_del_provider(struct device_node *np); · 283 unmodified lines
284284 int of_genpd_add_device(struct of_phandle_args *args, struct device *dev);
285285 int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
286286 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);
287289 struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
288290 int of_genpd_parse_idle_states(struct device_node *dn,
289291 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
322324 return -ENODEV;
323325 }
324326
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+
325333 static inline int of_genpd_parse_idle_states(struct device_node *dn,
326334 struct genpd_power_state **states, int *n)
327335 {