};
 
 /**
- * dtpm_alloc - Allocate and initialize a dtpm struct
- * @name: a string specifying the name of the node
- *
- * Return: a struct dtpm pointer, NULL in case of error
+ * dtpm_init - Allocate and initialize a dtpm struct
+ * @dtpm: The dtpm struct pointer to be initialized
+ * @ops: The dtpm device specific ops, NULL for a virtual node
  */
-struct dtpm *dtpm_alloc(struct dtpm_ops *ops)
+void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops)
 {
-       struct dtpm *dtpm;
-
-       dtpm = kzalloc(sizeof(*dtpm), GFP_KERNEL);
        if (dtpm) {
                INIT_LIST_HEAD(&dtpm->children);
                INIT_LIST_HEAD(&dtpm->sibling);
                dtpm->weight = 1024;
                dtpm->ops = ops;
        }
-
-       return dtpm;
 }
 
 /**
        return 0;
 }
 
-static int __init dtpm_init(void)
+static int __init init_dtpm(void)
 {
        struct dtpm_descr *dtpm_descr;
 
 
        return 0;
 }
-late_initcall(dtpm_init);
+late_initcall(init_dtpm);
 
 #include <linux/slab.h>
 #include <linux/units.h>
 
-static DEFINE_PER_CPU(struct dtpm *, dtpm_per_cpu);
-
 struct dtpm_cpu {
+       struct dtpm dtpm;
        struct freq_qos_request qos_req;
        int cpu;
 };
 
+static DEFINE_PER_CPU(struct dtpm_cpu *, dtpm_per_cpu);
+
+static struct dtpm_cpu *to_dtpm_cpu(struct dtpm *dtpm)
+{
+       return container_of(dtpm, struct dtpm_cpu, dtpm);
+}
+
 static u64 set_pd_power_limit(struct dtpm *dtpm, u64 power_limit)
 {
-       struct dtpm_cpu *dtpm_cpu = dtpm->private;
+       struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm);
        struct em_perf_domain *pd = em_cpu_get(dtpm_cpu->cpu);
        struct cpumask cpus;
        unsigned long freq;
 
 static u64 get_pd_power_uw(struct dtpm *dtpm)
 {
-       struct dtpm_cpu *dtpm_cpu = dtpm->private;
+       struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm);
        struct em_perf_domain *pd;
        struct cpumask cpus;
        unsigned long freq;
 
 static int update_pd_power_uw(struct dtpm *dtpm)
 {
-       struct dtpm_cpu *dtpm_cpu = dtpm->private;
+       struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm);
        struct em_perf_domain *em = em_cpu_get(dtpm_cpu->cpu);
        struct cpumask cpus;
        int nr_cpus;
 
 static void pd_release(struct dtpm *dtpm)
 {
-       struct dtpm_cpu *dtpm_cpu = dtpm->private;
+       struct dtpm_cpu *dtpm_cpu = to_dtpm_cpu(dtpm);
 
        if (freq_qos_request_active(&dtpm_cpu->qos_req))
                freq_qos_remove_request(&dtpm_cpu->qos_req);
 static int cpuhp_dtpm_cpu_offline(unsigned int cpu)
 {
        struct em_perf_domain *pd;
-       struct dtpm *dtpm;
+       struct dtpm_cpu *dtpm_cpu;
 
        pd = em_cpu_get(cpu);
        if (!pd)
                return -EINVAL;
 
-       dtpm = per_cpu(dtpm_per_cpu, cpu);
+       dtpm_cpu = per_cpu(dtpm_per_cpu, cpu);
 
-       return dtpm_update_power(dtpm);
+       return dtpm_update_power(&dtpm_cpu->dtpm);
 }
 
 static int cpuhp_dtpm_cpu_online(unsigned int cpu)
 {
-       struct dtpm *dtpm;
        struct dtpm_cpu *dtpm_cpu;
        struct cpufreq_policy *policy;
        struct em_perf_domain *pd;
        if (!pd)
                return -EINVAL;
 
-       dtpm = per_cpu(dtpm_per_cpu, cpu);
-       if (dtpm)
-               return dtpm_update_power(dtpm);
-
-       dtpm = dtpm_alloc(&dtpm_ops);
-       if (!dtpm)
-               return -EINVAL;
+       dtpm_cpu = per_cpu(dtpm_per_cpu, cpu);
+       if (dtpm_cpu)
+               return dtpm_update_power(&dtpm_cpu->dtpm);
 
        dtpm_cpu = kzalloc(sizeof(*dtpm_cpu), GFP_KERNEL);
        if (!dtpm_cpu)
-               goto out_kfree_dtpm;
+               return -ENOMEM;
 
-       dtpm->private = dtpm_cpu;
+       dtpm_init(&dtpm_cpu->dtpm, &dtpm_ops);
        dtpm_cpu->cpu = cpu;
 
        for_each_cpu(cpu, policy->related_cpus)
-               per_cpu(dtpm_per_cpu, cpu) = dtpm;
+               per_cpu(dtpm_per_cpu, cpu) = dtpm_cpu;
 
        snprintf(name, sizeof(name), "cpu%d-cpufreq", dtpm_cpu->cpu);
 
-       ret = dtpm_register(name, dtpm, NULL);
+       ret = dtpm_register(name, &dtpm_cpu->dtpm, NULL);
        if (ret)
                goto out_kfree_dtpm_cpu;
 
        return 0;
 
 out_dtpm_unregister:
-       dtpm_unregister(dtpm);
+       dtpm_unregister(&dtpm_cpu->dtpm);
        dtpm_cpu = NULL;
-       dtpm = NULL;
 
 out_kfree_dtpm_cpu:
        for_each_cpu(cpu, policy->related_cpus)
                per_cpu(dtpm_per_cpu, cpu) = NULL;
        kfree(dtpm_cpu);
 
-out_kfree_dtpm:
-       kfree(dtpm);
        return ret;
 }