uverbs_ioctl.h (3023a1e93656c02b8d6a3a46e712b815843fa514) uverbs_ioctl.h (cbfdd442c43eab8c62bf2ea5127511cd39e9046d)
1/*
2 * Copyright (c) 2017, Mellanox Technologies inc. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 705 unchanged lines hidden (view full) ---

714 const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx);
715
716 if (IS_ERR(attr))
717 return PTR_ERR(attr);
718
719 return attr->ptr_attr.len;
720}
721
1/*
2 * Copyright (c) 2017, Mellanox Technologies inc. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 705 unchanged lines hidden (view full) ---

714 const struct uverbs_attr *attr = uverbs_attr_get(attrs_bundle, idx);
715
716 if (IS_ERR(attr))
717 return PTR_ERR(attr);
718
719 return attr->ptr_attr.len;
720}
721
722/*
723 * uverbs_attr_ptr_get_array_size() - Get array size pointer by a ptr
724 * attribute.
725 * @attrs: The attribute bundle
726 * @idx: The ID of the attribute
727 * @elem_size: The size of the element in the array
728 */
729static inline int
730uverbs_attr_ptr_get_array_size(struct uverbs_attr_bundle *attrs, u16 idx,
731 size_t elem_size)
732{
733 int size = uverbs_attr_get_len(attrs, idx);
734
735 if (size < 0)
736 return size;
737
738 if (size % elem_size)
739 return -EINVAL;
740
741 return size / elem_size;
742}
743
722/**
723 * uverbs_attr_get_uobjs_arr() - Provides array's properties for attribute for
724 * UVERBS_ATTR_TYPE_IDRS_ARRAY.
725 * @arr: Returned pointer to array of pointers for uobjects or NULL if
726 * the attribute isn't provided.
727 *
728 * Return: The array length or 0 if no attribute was provided.
729 */

--- 181 unchanged lines hidden ---
744/**
745 * uverbs_attr_get_uobjs_arr() - Provides array's properties for attribute for
746 * UVERBS_ATTR_TYPE_IDRS_ARRAY.
747 * @arr: Returned pointer to array of pointers for uobjects or NULL if
748 * the attribute isn't provided.
749 *
750 * Return: The array length or 0 if no attribute was provided.
751 */

--- 181 unchanged lines hidden ---