Lines Matching refs:property

3  * Thunderbolt XDomain property support
82 struct tb_property *property;
84 property = kzalloc(sizeof(*property), GFP_KERNEL);
85 if (!property)
88 strcpy(property->key, key);
89 property->type = type;
90 INIT_LIST_HEAD(&property->list);
92 return property;
99 struct tb_property *property;
108 property = tb_property_alloc(key, entry->type);
109 if (!property)
112 property->length = entry->length;
114 switch (property->type) {
119 kfree(property);
122 property->value.dir = dir;
126 property->value.data = kcalloc(property->length, sizeof(u32),
128 if (!property->value.data) {
129 kfree(property);
132 parse_dwdata(property->value.data, block + entry->value,
137 property->value.text = kcalloc(property->length, sizeof(u32),
139 if (!property->value.text) {
140 kfree(property);
143 parse_dwdata(property->value.text, block + entry->value,
146 property->value.text[property->length * 4 - 1] = '\0';
150 property->value.immediate = entry->value;
154 property->type = TB_PROPERTY_TYPE_UNKNOWN;
158 return property;
193 struct tb_property *property;
195 property = tb_property_parse(block, block_len, &entries[i]);
196 if (!property) {
201 list_add_tail(&property->list, &dir->properties);
208 * tb_property_parse_dir() - Parses properties from given property block
210 * @block_len: Number of dword elements in the property block
236 * tb_property_create_dir() - Creates new property directory
239 * Creates new, empty property directory. If @uuid is %NULL then the
263 static void tb_property_free(struct tb_property *property)
265 switch (property->type) {
267 tb_property_free_dir(property->value.dir);
271 kfree(property->value.data);
275 kfree(property->value.text);
282 kfree(property);
286 * tb_property_free_dir() - Release memory allocated for property directory
295 struct tb_property *property, *tmp;
300 list_for_each_entry_safe(property, tmp, &dir->properties, list) {
301 list_del(&property->list);
302 tb_property_free(property);
312 const struct tb_property *property;
320 list_for_each_entry(property, &dir->properties, list) {
323 switch (property->type) {
327 property->value.dir, recurse, data_len);
337 *data_len += property->length;
352 const struct tb_property *property;
358 * The structure of property block looks like following. Leaf
427 list_for_each_entry(property, &dir->properties, list) {
430 format_dwdata(entry, property->key, 2);
431 entry->type = property->type;
433 switch (property->type) {
435 child = property->value.dir;
447 format_dwdata(&block[data_offset], property->value.data,
448 property->length);
449 entry->length = property->length;
455 format_dwdata(&block[data_offset], property->value.text,
456 property->length);
457 entry->length = property->length;
463 entry->length = property->length;
464 entry->value = property->value.immediate;
481 * @block_len: Length of the property block
505 * tb_property_add_immediate() - Add immediate property to directory
506 * @parent: Directory to add the property
507 * @key: Key for the property
508 * @value: Immediate value to store with the property
513 struct tb_property *property;
518 property = tb_property_alloc(key, TB_PROPERTY_TYPE_VALUE);
519 if (!property)
522 property->length = 1;
523 property->value.immediate = value;
525 list_add_tail(&property->list, &parent->properties);
531 * tb_property_add_data() - Adds arbitrary data property to directory
532 * @parent: Directory to add the property
533 * @key: Key for the property
544 struct tb_property *property;
549 property = tb_property_alloc(key, TB_PROPERTY_TYPE_DATA);
550 if (!property)
553 property->length = size / 4;
554 property->value.data = kzalloc(size, GFP_KERNEL);
555 if (!property->value.data) {
556 kfree(property);
560 memcpy(property->value.data, buf, buflen);
562 list_add_tail(&property->list, &parent->properties);
568 * tb_property_add_text() - Adds string property to directory
569 * @parent: Directory to add the property
570 * @key: Key for the property
580 struct tb_property *property;
585 property = tb_property_alloc(key, TB_PROPERTY_TYPE_TEXT);
586 if (!property)
589 property->length = size / 4;
590 property->value.text = kzalloc(size, GFP_KERNEL);
591 if (!property->value.text) {
592 kfree(property);
596 strcpy(property->value.text, text);
598 list_add_tail(&property->list, &parent->properties);
605 * @parent: Directory to add the property
606 * @key: Key for the property
612 struct tb_property *property;
617 property = tb_property_alloc(key, TB_PROPERTY_TYPE_DIRECTORY);
618 if (!property)
621 property->value.dir = dir;
623 list_add_tail(&property->list, &parent->properties);
629 * tb_property_remove() - Removes property from a parent directory
630 * @property: Property to remove
632 * Note memory for @property is released as well so it is not allowed to
635 void tb_property_remove(struct tb_property *property)
637 list_del(&property->list);
638 kfree(property);
643 * tb_property_find() - Find a property from a directory
644 * @dir: Directory where the property is searched
646 * @type: Type of the property
648 * Finds and returns property from the given directory. Does not recurse
649 * into sub-directories. Returns %NULL if the property was not found.
654 struct tb_property *property;
656 list_for_each_entry(property, &dir->properties, list) {
657 if (property->type == type && !strcmp(property->key, key))
658 return property;
666 * tb_property_get_next() - Get next property from directory
668 * @prev: Previous property in the directory (%NULL returns the first)