Lines Matching refs:property
82 struct tb_property *property; in tb_property_alloc() local
84 property = kzalloc(sizeof(*property), GFP_KERNEL); in tb_property_alloc()
85 if (!property) in tb_property_alloc()
88 strcpy(property->key, key); in tb_property_alloc()
89 property->type = type; in tb_property_alloc()
90 INIT_LIST_HEAD(&property->list); in tb_property_alloc()
92 return property; in tb_property_alloc()
99 struct tb_property *property; in tb_property_parse() local
108 property = tb_property_alloc(key, entry->type); in tb_property_parse()
109 if (!property) in tb_property_parse()
112 property->length = entry->length; in tb_property_parse()
114 switch (property->type) { in tb_property_parse()
119 kfree(property); in tb_property_parse()
122 property->value.dir = dir; in tb_property_parse()
126 property->value.data = kcalloc(property->length, sizeof(u32), in tb_property_parse()
128 if (!property->value.data) { in tb_property_parse()
129 kfree(property); in tb_property_parse()
132 parse_dwdata(property->value.data, block + entry->value, in tb_property_parse()
137 property->value.text = kcalloc(property->length, sizeof(u32), in tb_property_parse()
139 if (!property->value.text) { in tb_property_parse()
140 kfree(property); in tb_property_parse()
143 parse_dwdata(property->value.text, block + entry->value, in tb_property_parse()
146 property->value.text[property->length * 4 - 1] = '\0'; in tb_property_parse()
150 property->value.immediate = entry->value; in tb_property_parse()
154 property->type = TB_PROPERTY_TYPE_UNKNOWN; in tb_property_parse()
158 return property; in tb_property_parse()
193 struct tb_property *property; in __tb_property_parse_dir() local
195 property = tb_property_parse(block, block_len, &entries[i]); in __tb_property_parse_dir()
196 if (!property) { in __tb_property_parse_dir()
201 list_add_tail(&property->list, &dir->properties); in __tb_property_parse_dir()
263 static void tb_property_free(struct tb_property *property) in tb_property_free() argument
265 switch (property->type) { in tb_property_free()
267 tb_property_free_dir(property->value.dir); in tb_property_free()
271 kfree(property->value.data); in tb_property_free()
275 kfree(property->value.text); in tb_property_free()
282 kfree(property); in tb_property_free()
295 struct tb_property *property, *tmp; in tb_property_free_dir() local
300 list_for_each_entry_safe(property, tmp, &dir->properties, list) { in tb_property_free_dir()
301 list_del(&property->list); in tb_property_free_dir()
302 tb_property_free(property); in tb_property_free_dir()
312 const struct tb_property *property; in tb_property_dir_length() local
320 list_for_each_entry(property, &dir->properties, list) { in tb_property_dir_length()
323 switch (property->type) { in tb_property_dir_length()
327 property->value.dir, recurse, data_len); in tb_property_dir_length()
337 *data_len += property->length; in tb_property_dir_length()
352 const struct tb_property *property; in __tb_property_format_dir() local
427 list_for_each_entry(property, &dir->properties, list) { in __tb_property_format_dir()
430 format_dwdata(entry, property->key, 2); in __tb_property_format_dir()
431 entry->type = property->type; in __tb_property_format_dir()
433 switch (property->type) { in __tb_property_format_dir()
435 child = property->value.dir; in __tb_property_format_dir()
447 format_dwdata(&block[data_offset], property->value.data, in __tb_property_format_dir()
448 property->length); in __tb_property_format_dir()
449 entry->length = property->length; in __tb_property_format_dir()
455 format_dwdata(&block[data_offset], property->value.text, in __tb_property_format_dir()
456 property->length); in __tb_property_format_dir()
457 entry->length = property->length; in __tb_property_format_dir()
463 entry->length = property->length; in __tb_property_format_dir()
464 entry->value = property->value.immediate; in __tb_property_format_dir()
514 struct tb_property *property, *p = NULL; in tb_property_copy_dir() local
524 list_for_each_entry(property, &dir->properties, list) { in tb_property_copy_dir()
527 p = tb_property_alloc(property->key, property->type); in tb_property_copy_dir()
531 p->length = property->length; in tb_property_copy_dir()
533 switch (property->type) { in tb_property_copy_dir()
535 p->value.dir = tb_property_copy_dir(property->value.dir); in tb_property_copy_dir()
541 p->value.data = kmemdup(property->value.data, in tb_property_copy_dir()
542 property->length * 4, in tb_property_copy_dir()
552 strcpy(p->value.text, property->value.text); in tb_property_copy_dir()
556 p->value.immediate = property->value.immediate; in tb_property_copy_dir()
584 struct tb_property *property; in tb_property_add_immediate() local
589 property = tb_property_alloc(key, TB_PROPERTY_TYPE_VALUE); in tb_property_add_immediate()
590 if (!property) in tb_property_add_immediate()
593 property->length = 1; in tb_property_add_immediate()
594 property->value.immediate = value; in tb_property_add_immediate()
596 list_add_tail(&property->list, &parent->properties); in tb_property_add_immediate()
615 struct tb_property *property; in tb_property_add_data() local
620 property = tb_property_alloc(key, TB_PROPERTY_TYPE_DATA); in tb_property_add_data()
621 if (!property) in tb_property_add_data()
624 property->length = size / 4; in tb_property_add_data()
625 property->value.data = kzalloc(size, GFP_KERNEL); in tb_property_add_data()
626 if (!property->value.data) { in tb_property_add_data()
627 kfree(property); in tb_property_add_data()
631 memcpy(property->value.data, buf, buflen); in tb_property_add_data()
633 list_add_tail(&property->list, &parent->properties); in tb_property_add_data()
651 struct tb_property *property; in tb_property_add_text() local
656 property = tb_property_alloc(key, TB_PROPERTY_TYPE_TEXT); in tb_property_add_text()
657 if (!property) in tb_property_add_text()
660 property->length = size / 4; in tb_property_add_text()
661 property->value.text = kzalloc(size, GFP_KERNEL); in tb_property_add_text()
662 if (!property->value.text) { in tb_property_add_text()
663 kfree(property); in tb_property_add_text()
667 strcpy(property->value.text, text); in tb_property_add_text()
669 list_add_tail(&property->list, &parent->properties); in tb_property_add_text()
683 struct tb_property *property; in tb_property_add_dir() local
688 property = tb_property_alloc(key, TB_PROPERTY_TYPE_DIRECTORY); in tb_property_add_dir()
689 if (!property) in tb_property_add_dir()
692 property->value.dir = dir; in tb_property_add_dir()
694 list_add_tail(&property->list, &parent->properties); in tb_property_add_dir()
706 void tb_property_remove(struct tb_property *property) in tb_property_remove() argument
708 list_del(&property->list); in tb_property_remove()
709 kfree(property); in tb_property_remove()
725 struct tb_property *property; in tb_property_find() local
727 list_for_each_entry(property, &dir->properties, list) { in tb_property_find()
728 if (property->type == type && !strcmp(property->key, key)) in tb_property_find()
729 return property; in tb_property_find()