Lines Matching refs:unit
91 struct pwrseq_unit *unit; in pwrseq_unit_new() local
93 unit = kzalloc(sizeof(*unit), GFP_KERNEL); in pwrseq_unit_new()
94 if (!unit) in pwrseq_unit_new()
97 unit->name = kstrdup_const(data->name, GFP_KERNEL); in pwrseq_unit_new()
98 if (!unit->name) { in pwrseq_unit_new()
99 kfree(unit); in pwrseq_unit_new()
103 kref_init(&unit->ref); in pwrseq_unit_new()
104 INIT_LIST_HEAD(&unit->deps); in pwrseq_unit_new()
105 unit->enable = data->enable; in pwrseq_unit_new()
106 unit->disable = data->disable; in pwrseq_unit_new()
108 return unit; in pwrseq_unit_new()
111 static struct pwrseq_unit *pwrseq_unit_get(struct pwrseq_unit *unit) in pwrseq_unit_get() argument
113 kref_get(&unit->ref); in pwrseq_unit_get()
115 return unit; in pwrseq_unit_get()
120 static void pwrseq_unit_put(struct pwrseq_unit *unit) in pwrseq_unit_put() argument
122 kref_put(&unit->ref, pwrseq_unit_release); in pwrseq_unit_put()
134 struct pwrseq_unit *unit; member
137 static struct pwrseq_unit_dep *pwrseq_unit_dep_new(struct pwrseq_unit *unit) in pwrseq_unit_dep_new() argument
145 dep->unit = unit; in pwrseq_unit_dep_new()
152 pwrseq_unit_put(ref->unit); in pwrseq_unit_dep_free()
168 struct pwrseq_unit *unit = container_of(ref, struct pwrseq_unit, ref); in pwrseq_unit_release() local
170 pwrseq_unit_free_deps(&unit->deps); in pwrseq_unit_release()
171 list_del(&unit->list); in pwrseq_unit_release()
172 kfree_const(unit->name); in pwrseq_unit_release()
173 kfree(unit); in pwrseq_unit_release()
189 struct pwrseq_unit *unit; member
215 if (!IS_ERR_OR_NULL(target->unit)) in pwrseq_target_free()
216 pwrseq_unit_put(target->unit); in pwrseq_target_free()
332 if (!data->unit) in pwrseq_check_target_deps()
336 ret = pwrseq_check_unit_deps(data->unit, &visited_units); in pwrseq_check_target_deps()
353 struct pwrseq_unit *unit; in pwrseq_unit_setup() local
356 unit = radix_tree_lookup(processed_units, (unsigned long)data); in pwrseq_unit_setup()
357 if (unit) in pwrseq_unit_setup()
358 return pwrseq_unit_get(unit); in pwrseq_unit_setup()
360 unit = pwrseq_unit_new(data); in pwrseq_unit_setup()
361 if (!unit) in pwrseq_unit_setup()
365 ret = pwrseq_unit_setup_deps(data->deps, &unit->deps, in pwrseq_unit_setup()
368 pwrseq_unit_put(unit); in pwrseq_unit_setup()
373 ret = radix_tree_insert(processed_units, (unsigned long)data, unit); in pwrseq_unit_setup()
375 pwrseq_unit_put(unit); in pwrseq_unit_setup()
379 list_add_tail(&unit->list, unit_list); in pwrseq_unit_setup()
381 return unit; in pwrseq_unit_setup()
391 struct pwrseq_unit *unit; in pwrseq_unit_setup_deps() local
397 unit = pwrseq_unit_setup(pos, unit_list, processed_units); in pwrseq_unit_setup_deps()
398 if (IS_ERR(unit)) in pwrseq_unit_setup_deps()
399 return PTR_ERR(unit); in pwrseq_unit_setup_deps()
401 dep = pwrseq_unit_dep_new(unit); in pwrseq_unit_setup_deps()
403 pwrseq_unit_put(unit); in pwrseq_unit_setup_deps()
432 target->unit = pwrseq_unit_setup(pos->unit, &pwrseq->units, in pwrseq_do_setup_targets()
434 if (IS_ERR(target->unit)) { in pwrseq_do_setup_targets()
435 ret = PTR_ERR(target->unit); in pwrseq_do_setup_targets()
550 WARN(target->unit->enable_count, in pwrseq_device_unregister()
764 ret = pwrseq_unit_enable(pwrseq, pos->unit); in pwrseq_unit_enable_deps()
767 pwrseq_unit_disable(pwrseq, pos->unit); in pwrseq_unit_enable_deps()
782 ret = pwrseq_unit_disable(pwrseq, pos->unit); in pwrseq_unit_disable_deps()
785 pwrseq_unit_enable(pwrseq, pos->unit); in pwrseq_unit_disable_deps()
794 struct pwrseq_unit *unit) in pwrseq_unit_enable() argument
801 if (unit->enable_count != 0) { in pwrseq_unit_enable()
802 unit->enable_count++; in pwrseq_unit_enable()
806 ret = pwrseq_unit_enable_deps(pwrseq, &unit->deps); in pwrseq_unit_enable()
810 unit->name, ret); in pwrseq_unit_enable()
814 if (unit->enable) { in pwrseq_unit_enable()
815 ret = unit->enable(pwrseq); in pwrseq_unit_enable()
819 unit->name, ret); in pwrseq_unit_enable()
820 pwrseq_unit_disable_deps(pwrseq, &unit->deps); in pwrseq_unit_enable()
825 unit->enable_count++; in pwrseq_unit_enable()
831 struct pwrseq_unit *unit) in pwrseq_unit_disable() argument
838 if (unit->enable_count == 0) { in pwrseq_unit_disable()
840 unit->name); in pwrseq_unit_disable()
844 if (unit->enable_count != 1) { in pwrseq_unit_disable()
845 unit->enable_count--; in pwrseq_unit_disable()
849 if (unit->disable) { in pwrseq_unit_disable()
850 ret = unit->disable(pwrseq); in pwrseq_unit_disable()
854 unit->name, ret); in pwrseq_unit_disable()
859 ret = pwrseq_unit_disable_deps(pwrseq, &unit->deps); in pwrseq_unit_disable()
863 unit->name, ret); in pwrseq_unit_disable()
864 if (unit->enable) in pwrseq_unit_disable()
865 unit->enable(pwrseq); in pwrseq_unit_disable()
869 unit->enable_count--; in pwrseq_unit_disable()
892 struct pwrseq_unit *unit; in pwrseq_power_on() local
902 unit = target->unit; in pwrseq_power_on()
909 ret = pwrseq_unit_enable(pwrseq, unit); in pwrseq_power_on()
917 pwrseq_unit_disable(pwrseq, unit); in pwrseq_power_on()
942 struct pwrseq_unit *unit; in pwrseq_power_off() local
951 unit = desc->target->unit; in pwrseq_power_off()
959 ret = pwrseq_unit_disable(pwrseq, unit); in pwrseq_power_off()
1019 target->name, target->unit->name); in pwrseq_debugfs_seq_show_target()
1023 struct pwrseq_unit *unit) in pwrseq_debugfs_seq_show_unit() argument
1028 unit->name, unit->enable_count); in pwrseq_debugfs_seq_show_unit()
1030 if (list_empty(&unit->deps)) in pwrseq_debugfs_seq_show_unit()
1034 list_for_each_entry(ref, &unit->deps, list) in pwrseq_debugfs_seq_show_unit()
1035 seq_printf(seq, " [%s]\n", ref->unit->name); in pwrseq_debugfs_seq_show_unit()
1043 struct pwrseq_unit *unit; in pwrseq_debugfs_seq_show() local
1052 list_for_each_entry(unit, &pwrseq->units, list) in pwrseq_debugfs_seq_show()
1053 pwrseq_debugfs_seq_show_unit(seq, unit); in pwrseq_debugfs_seq_show()