Lines Matching refs:control_type

328 static bool control_type_valid(void *control_type)  in control_type_valid()  argument
336 if (pos == control_type) { in control_type_valid()
406 struct powercap_control_type *control_type = in powercap_release() local
410 allocated = control_type->allocated; in powercap_release()
411 idr_destroy(&control_type->idr); in powercap_release()
412 mutex_destroy(&control_type->lock); in powercap_release()
413 if (control_type->ops && control_type->ops->release) in powercap_release()
414 control_type->ops->release(control_type); in powercap_release()
416 kfree(control_type); in powercap_release()
433 struct powercap_control_type *control_type = in enabled_show() local
435 if (control_type->ops && control_type->ops->get_enable) in enabled_show()
436 if (control_type->ops->get_enable(control_type, &mode)) in enabled_show()
457 struct powercap_control_type *control_type = in enabled_store() local
459 if (control_type->ops && control_type->ops->set_enable) in enabled_store()
460 if (!control_type->ops->set_enable(control_type, mode)) in enabled_store()
483 struct powercap_control_type *control_type, in powercap_register_zone() argument
493 if (!name || !control_type || !ops || in powercap_register_zone()
496 !control_type_valid(control_type)) in powercap_register_zone()
510 power_zone->control_type_inst = control_type; in powercap_register_zone()
512 power_zone->dev.parent = &control_type->dev; in powercap_register_zone()
513 power_zone->parent_idr = &control_type->idr; in powercap_register_zone()
520 mutex_lock(&control_type->lock); in powercap_register_zone()
561 control_type->nr_zones++; in powercap_register_zone()
562 mutex_unlock(&control_type->lock); in powercap_register_zone()
577 mutex_unlock(&control_type->lock); in powercap_register_zone()
583 int powercap_unregister_zone(struct powercap_control_type *control_type, in powercap_unregister_zone() argument
586 if (!power_zone || !control_type) in powercap_unregister_zone()
589 mutex_lock(&control_type->lock); in powercap_unregister_zone()
590 control_type->nr_zones--; in powercap_unregister_zone()
591 mutex_unlock(&control_type->lock); in powercap_unregister_zone()
600 struct powercap_control_type *control_type, in powercap_register_control_type() argument
608 if (control_type) { in powercap_register_control_type()
611 memset(control_type, 0, sizeof(*control_type)); in powercap_register_control_type()
613 control_type = kzalloc(sizeof(*control_type), GFP_KERNEL); in powercap_register_control_type()
614 if (!control_type) in powercap_register_control_type()
616 control_type->allocated = true; in powercap_register_control_type()
618 mutex_init(&control_type->lock); in powercap_register_control_type()
619 control_type->ops = ops; in powercap_register_control_type()
620 INIT_LIST_HEAD(&control_type->node); in powercap_register_control_type()
621 control_type->dev.class = &powercap_class; in powercap_register_control_type()
622 dev_set_name(&control_type->dev, "%s", name); in powercap_register_control_type()
623 result = device_register(&control_type->dev); in powercap_register_control_type()
625 if (control_type->allocated) in powercap_register_control_type()
626 kfree(control_type); in powercap_register_control_type()
629 idr_init(&control_type->idr); in powercap_register_control_type()
632 list_add_tail(&control_type->node, &powercap_cntrl_list); in powercap_register_control_type()
635 return control_type; in powercap_register_control_type()
639 int powercap_unregister_control_type(struct powercap_control_type *control_type) in powercap_unregister_control_type() argument
643 if (control_type->nr_zones) { in powercap_unregister_control_type()
644 dev_err(&control_type->dev, "Zones of this type still not freed\n"); in powercap_unregister_control_type()
649 if (pos == control_type) { in powercap_unregister_control_type()
650 list_del(&control_type->node); in powercap_unregister_control_type()
652 device_unregister(&control_type->dev); in powercap_unregister_control_type()