summaryrefslogtreecommitdiffstats
path: root/tools/iio
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-05-31 08:40:16 -0400
committerJonathan Cameron <jic23@kernel.org>2015-06-01 03:33:17 -0400
commit5dc65d791ddafc9f6d944391e379708b6056fc48 (patch)
tree6433521c1c8fec6b38ba5651364dc439f662e654 /tools/iio
parentacf50b3586f8d8a7530b905e111dda41876d38f4 (diff)
tools:iio:iio_utils: add missing documentation
Fully document public functions and elements. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio')
-rw-r--r--tools/iio/iio_utils.c85
-rw-r--r--tools/iio/iio_utils.h5
2 files changed, 83 insertions, 7 deletions
diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
index e1828d0d8a38..5d5831d7dfd0 100644
--- a/tools/iio/iio_utils.c
+++ b/tools/iio/iio_utils.c
@@ -29,6 +29,8 @@ static char * const iio_direction[] = {
29 * iioutils_break_up_name() - extract generic name from full channel name 29 * iioutils_break_up_name() - extract generic name from full channel name
30 * @full_name: the full channel name 30 * @full_name: the full channel name
31 * @generic_name: the output generic channel name 31 * @generic_name: the output generic channel name
32 *
33 * Returns 0 on success, or a negative error code if string extraction failed.
32 **/ 34 **/
33int iioutils_break_up_name(const char *full_name, 35int iioutils_break_up_name(const char *full_name,
34 char **generic_name) 36 char **generic_name)
@@ -76,11 +78,15 @@ int iioutils_break_up_name(const char *full_name,
76 * iioutils_get_type() - find and process _type attribute data 78 * iioutils_get_type() - find and process _type attribute data
77 * @is_signed: output whether channel is signed 79 * @is_signed: output whether channel is signed
78 * @bytes: output how many bytes the channel storage occupies 80 * @bytes: output how many bytes the channel storage occupies
81 * @bits_used: output number of valid bits of data
82 * @shift: output amount of bits to shift right data before applying bit mask
79 * @mask: output a bit mask for the raw data 83 * @mask: output a bit mask for the raw data
80 * @be: big endian 84 * @be: output if data in big endian
81 * @device_dir: the iio device directory 85 * @device_dir: the IIO device directory
82 * @name: the channel name 86 * @name: the channel name
83 * @generic_name: the channel type name 87 * @generic_name: the channel type name
88 *
89 * Returns a value >= 0 on success, otherwise a negative error code.
84 **/ 90 **/
85int iioutils_get_type(unsigned *is_signed, 91int iioutils_get_type(unsigned *is_signed,
86 unsigned *bytes, 92 unsigned *bytes,
@@ -200,6 +206,16 @@ error_ret:
200 return ret; 206 return ret;
201} 207}
202 208
209/**
210 * iioutils_get_param_float() - read a float value from a channel parameter
211 * @output: output the float value
212 * @param_name: the parameter name to read
213 * @device_dir: the IIO device directory in sysfs
214 * @name: the channel name
215 * @generic_name: the channel type name
216 *
217 * Returns a value >= 0 on success, otherwise a negative error code.
218 **/
203int iioutils_get_param_float(float *output, 219int iioutils_get_param_float(float *output,
204 const char *param_name, 220 const char *param_name,
205 const char *device_dir, 221 const char *device_dir,
@@ -266,8 +282,9 @@ error_ret:
266} 282}
267 283
268/** 284/**
269 * bsort_channel_array_by_index() - reorder so that the array is in index order 285 * bsort_channel_array_by_index() - sort the array in index order
270 * 286 * @ci_array: the iio_channel_info array to be sorted
287 * @cnt: the amount of array elements
271 **/ 288 **/
272 289
273void bsort_channel_array_by_index(struct iio_channel_info **ci_array, 290void bsort_channel_array_by_index(struct iio_channel_info **ci_array,
@@ -289,7 +306,10 @@ void bsort_channel_array_by_index(struct iio_channel_info **ci_array,
289/** 306/**
290 * build_channel_array() - function to figure out what channels are present 307 * build_channel_array() - function to figure out what channels are present
291 * @device_dir: the IIO device directory in sysfs 308 * @device_dir: the IIO device directory in sysfs
292 * @ 309 * @ci_array: output the resulting array of iio_channel_info
310 * @counter: output the amount of array elements
311 *
312 * Returns 0 on success, otherwise a negative error code.
293 **/ 313 **/
294int build_channel_array(const char *device_dir, 314int build_channel_array(const char *device_dir,
295 struct iio_channel_info **ci_array, 315 struct iio_channel_info **ci_array,
@@ -525,8 +545,10 @@ int calc_digits(int num)
525/** 545/**
526 * find_type_by_name() - function to match top level types by name 546 * find_type_by_name() - function to match top level types by name
527 * @name: top level type instance name 547 * @name: top level type instance name
528 * @type: the type of top level instance being sort 548 * @type: the type of top level instance being searched
529 * 549 *
550 * Returns the device number of a matched IIO device on success, otherwise a
551 * negative error code.
530 * Typical types this is used for are device and trigger. 552 * Typical types this is used for are device and trigger.
531 **/ 553 **/
532int find_type_by_name(const char *name, const char *type) 554int find_type_by_name(const char *name, const char *type)
@@ -684,11 +706,28 @@ error_free:
684 return ret; 706 return ret;
685} 707}
686 708
709/**
710 * write_sysfs_int() - write an integer value to a sysfs file
711 * @filename: name of the file to write to
712 * @basedir: the sysfs directory in which the file is to be found
713 * @val: integer value to write to file
714 *
715 * Returns a value >= 0 on success, otherwise a negative error code.
716 **/
687int write_sysfs_int(char *filename, char *basedir, int val) 717int write_sysfs_int(char *filename, char *basedir, int val)
688{ 718{
689 return _write_sysfs_int(filename, basedir, val, 0); 719 return _write_sysfs_int(filename, basedir, val, 0);
690} 720}
691 721
722/**
723 * write_sysfs_int_and_verify() - write an integer value to a sysfs file
724 * and verify
725 * @filename: name of the file to write to
726 * @basedir: the sysfs directory in which the file is to be found
727 * @val: integer value to write to file
728 *
729 * Returns a value >= 0 on success, otherwise a negative error code.
730 **/
692int write_sysfs_int_and_verify(char *filename, char *basedir, int val) 731int write_sysfs_int_and_verify(char *filename, char *basedir, int val)
693{ 732{
694 return _write_sysfs_int(filename, basedir, val, 1); 733 return _write_sysfs_int(filename, basedir, val, 1);
@@ -770,17 +809,35 @@ error_free:
770 * @filename: name of file to write to 809 * @filename: name of file to write to
771 * @basedir: the sysfs directory in which the file is to be found 810 * @basedir: the sysfs directory in which the file is to be found
772 * @val: the string to write 811 * @val: the string to write
812 *
813 * Returns a value >= 0 on success, otherwise a negative error code.
773 **/ 814 **/
774int write_sysfs_string_and_verify(char *filename, char *basedir, char *val) 815int write_sysfs_string_and_verify(char *filename, char *basedir, char *val)
775{ 816{
776 return _write_sysfs_string(filename, basedir, val, 1); 817 return _write_sysfs_string(filename, basedir, val, 1);
777} 818}
778 819
820/**
821 * write_sysfs_string() - write string to a sysfs file
822 * @filename: name of file to write to
823 * @basedir: the sysfs directory in which the file is to be found
824 * @val: the string to write
825 *
826 * Returns a value >= 0 on success, otherwise a negative error code.
827 **/
779int write_sysfs_string(char *filename, char *basedir, char *val) 828int write_sysfs_string(char *filename, char *basedir, char *val)
780{ 829{
781 return _write_sysfs_string(filename, basedir, val, 0); 830 return _write_sysfs_string(filename, basedir, val, 0);
782} 831}
783 832
833/**
834 * read_sysfs_posint() - read an integer value from file
835 * @filename: name of file to read from
836 * @basedir: the sysfs directory in which the file is to be found
837 *
838 * Returns the read integer value >= 0 on success, otherwise a negative error
839 * code.
840 **/
784int read_sysfs_posint(char *filename, char *basedir) 841int read_sysfs_posint(char *filename, char *basedir)
785{ 842{
786 int ret; 843 int ret;
@@ -817,6 +874,14 @@ error_free:
817 return ret; 874 return ret;
818} 875}
819 876
877/**
878 * read_sysfs_float() - read a float value from file
879 * @filename: name of file to read from
880 * @basedir: the sysfs directory in which the file is to be found
881 * @val: output the read float value
882 *
883 * Returns a value >= 0 on success, otherwise a negative error code.
884 **/
820int read_sysfs_float(char *filename, char *basedir, float *val) 885int read_sysfs_float(char *filename, char *basedir, float *val)
821{ 886{
822 int ret = 0; 887 int ret = 0;
@@ -853,6 +918,14 @@ error_free:
853 return ret; 918 return ret;
854} 919}
855 920
921/**
922 * read_sysfs_string() - read a string from file
923 * @filename: name of file to read from
924 * @basedir: the sysfs directory in which the file is to be found
925 * @str: output the read string
926 *
927 * Returns a value >= 0 on success, otherwise a negative error code.
928 **/
856int read_sysfs_string(const char *filename, const char *basedir, char *str) 929int read_sysfs_string(const char *filename, const char *basedir, char *str)
857{ 930{
858 int ret = 0; 931 int ret = 0;
diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h
index 1bc837b2d769..e5eb46ade0a3 100644
--- a/tools/iio/iio_utils.h
+++ b/tools/iio/iio_utils.h
@@ -28,9 +28,12 @@ extern const char *iio_dir;
28 * @offset: offset to be applied for conversion to si units 28 * @offset: offset to be applied for conversion to si units
29 * @index: the channel index in the buffer output 29 * @index: the channel index in the buffer output
30 * @bytes: number of bytes occupied in buffer output 30 * @bytes: number of bytes occupied in buffer output
31 * @bits_used: number of valid bits of data
32 * @shift: amount of bits to shift right data before applying bit mask
31 * @mask: a bit mask for the raw output 33 * @mask: a bit mask for the raw output
34 * @be: flag if data is big endian
32 * @is_signed: is the raw value stored signed 35 * @is_signed: is the raw value stored signed
33 * @enabled: is this channel enabled 36 * @location: data offset for this channel inside the buffer (in bytes)
34 **/ 37 **/
35struct iio_channel_info { 38struct iio_channel_info {
36 char *name; 39 char *name;