~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/iio/iio_utils.h

Version: ~ [ linux-5.5-rc6 ] ~ [ linux-5.4.11 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.95 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.164 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.209 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.209 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _IIO_UTILS_H_
  2 #define _IIO_UTILS_H_
  3 
  4 /* IIO - useful set of util functionality
  5  *
  6  * Copyright (c) 2008 Jonathan Cameron
  7  *
  8  * This program is free software; you can redistribute it and/or modify it
  9  * under the terms of the GNU General Public License version 2 as published by
 10  * the Free Software Foundation.
 11  */
 12 
 13 #include <stdint.h>
 14 
 15 /* Made up value to limit allocation sizes */
 16 #define IIO_MAX_NAME_LENGTH 64
 17 
 18 #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
 19 #define FORMAT_TYPE_FILE "%s_type"
 20 
 21 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
 22 
 23 extern const char *iio_dir;
 24 
 25 /**
 26  * struct iio_channel_info - information about a given channel
 27  * @name: channel name
 28  * @generic_name: general name for channel type
 29  * @scale: scale factor to be applied for conversion to si units
 30  * @offset: offset to be applied for conversion to si units
 31  * @index: the channel index in the buffer output
 32  * @bytes: number of bytes occupied in buffer output
 33  * @bits_used: number of valid bits of data
 34  * @shift: amount of bits to shift right data before applying bit mask
 35  * @mask: a bit mask for the raw output
 36  * @be: flag if data is big endian
 37  * @is_signed: is the raw value stored signed
 38  * @location: data offset for this channel inside the buffer (in bytes)
 39  **/
 40 struct iio_channel_info {
 41         char *name;
 42         char *generic_name;
 43         float scale;
 44         float offset;
 45         unsigned index;
 46         unsigned bytes;
 47         unsigned bits_used;
 48         unsigned shift;
 49         uint64_t mask;
 50         unsigned be;
 51         unsigned is_signed;
 52         unsigned location;
 53 };
 54 
 55 static inline int iioutils_check_suffix(const char *str, const char *suffix)
 56 {
 57         return strlen(str) >= strlen(suffix) &&
 58                 strncmp(str+strlen(str)-strlen(suffix),
 59                         suffix, strlen(suffix)) == 0;
 60 }
 61 
 62 int iioutils_break_up_name(const char *full_name, char **generic_name);
 63 int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
 64                       unsigned *shift, uint64_t *mask, unsigned *be,
 65                       const char *device_dir, const char *name,
 66                       const char *generic_name);
 67 int iioutils_get_param_float(float *output, const char *param_name,
 68                              const char *device_dir, const char *name,
 69                              const char *generic_name);
 70 void bsort_channel_array_by_index(struct iio_channel_info *ci_array, int cnt);
 71 int build_channel_array(const char *device_dir,
 72                         struct iio_channel_info **ci_array, int *counter);
 73 int find_type_by_name(const char *name, const char *type);
 74 int write_sysfs_int(const char *filename, const char *basedir, int val);
 75 int write_sysfs_int_and_verify(const char *filename, const char *basedir,
 76                                int val);
 77 int write_sysfs_string_and_verify(const char *filename, const char *basedir,
 78                                   const char *val);
 79 int write_sysfs_string(const char *filename, const char *basedir,
 80                        const char *val);
 81 int read_sysfs_posint(const char *filename, const char *basedir);
 82 int read_sysfs_float(const char *filename, const char *basedir, float *val);
 83 int read_sysfs_string(const char *filename, const char *basedir, char *str);
 84 
 85 #endif /* _IIO_UTILS_H_ */
 86 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp