The dev_pm_genpd_set_performance_state() could in principle be called for a
device that has a different PM domain type attached than a genpd. This
would lead to a problem as dev_to_genpd() uses the container_of macro.
Address this problem by using dev_to_genpd_safe() instead.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
        unsigned int prev;
        int ret;
 
-       genpd = dev_to_genpd(dev);
-       if (IS_ERR(genpd))
+       genpd = dev_to_genpd_safe(dev);
+       if (!genpd)
                return -ENODEV;
 
        if (unlikely(!genpd->set_performance_state))