tools: iio: privatize globals and functions in iio_generic_buffer.c file

Mostly a tidy-up.
But also helps to understand the limits of scope of these functions and
globals.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-24-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Alexandru Ardelean 2021-02-15 12:40:42 +02:00 committed by Jonathan Cameron
parent a605c8f4e7
commit ebe5112535

View file

@ -49,7 +49,7 @@ enum autochan {
* Has the side effect of filling the channels[i].location values used * Has the side effect of filling the channels[i].location values used
* in processing the buffer output. * in processing the buffer output.
**/ **/
int size_from_channelarray(struct iio_channel_info *channels, int num_channels) static int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
{ {
int bytes = 0; int bytes = 0;
int i = 0; int i = 0;
@ -68,7 +68,7 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
return bytes; return bytes;
} }
void print1byte(uint8_t input, struct iio_channel_info *info) static void print1byte(uint8_t input, struct iio_channel_info *info)
{ {
/* /*
* Shift before conversion to avoid sign extension * Shift before conversion to avoid sign extension
@ -85,7 +85,7 @@ void print1byte(uint8_t input, struct iio_channel_info *info)
} }
} }
void print2byte(uint16_t input, struct iio_channel_info *info) static void print2byte(uint16_t input, struct iio_channel_info *info)
{ {
/* First swap if incorrect endian */ /* First swap if incorrect endian */
if (info->be) if (info->be)
@ -108,7 +108,7 @@ void print2byte(uint16_t input, struct iio_channel_info *info)
} }
} }
void print4byte(uint32_t input, struct iio_channel_info *info) static void print4byte(uint32_t input, struct iio_channel_info *info)
{ {
/* First swap if incorrect endian */ /* First swap if incorrect endian */
if (info->be) if (info->be)
@ -131,7 +131,7 @@ void print4byte(uint32_t input, struct iio_channel_info *info)
} }
} }
void print8byte(uint64_t input, struct iio_channel_info *info) static void print8byte(uint64_t input, struct iio_channel_info *info)
{ {
/* First swap if incorrect endian */ /* First swap if incorrect endian */
if (info->be) if (info->be)
@ -167,9 +167,8 @@ void print8byte(uint64_t input, struct iio_channel_info *info)
* to fill the location offsets. * to fill the location offsets.
* @num_channels: number of channels * @num_channels: number of channels
**/ **/
void process_scan(char *data, static void process_scan(char *data, struct iio_channel_info *channels,
struct iio_channel_info *channels, int num_channels)
int num_channels)
{ {
int k; int k;
@ -238,7 +237,7 @@ static int enable_disable_all_channels(char *dev_dir_name, int enable)
return 0; return 0;
} }
void print_usage(void) static void print_usage(void)
{ {
fprintf(stderr, "Usage: generic_buffer [options]...\n" fprintf(stderr, "Usage: generic_buffer [options]...\n"
"Capture, convert and output data from IIO device buffer\n" "Capture, convert and output data from IIO device buffer\n"
@ -257,12 +256,12 @@ void print_usage(void)
" -w <n> Set delay between reads in us (event-less mode)\n"); " -w <n> Set delay between reads in us (event-less mode)\n");
} }
enum autochan autochannels = AUTOCHANNELS_DISABLED; static enum autochan autochannels = AUTOCHANNELS_DISABLED;
char *dev_dir_name = NULL; static char *dev_dir_name = NULL;
char *buf_dir_name = NULL; static char *buf_dir_name = NULL;
bool current_trigger_set = false; static bool current_trigger_set = false;
void cleanup(void) static void cleanup(void)
{ {
int ret; int ret;
@ -294,14 +293,14 @@ void cleanup(void)
} }
} }
void sig_handler(int signum) static void sig_handler(int signum)
{ {
fprintf(stderr, "Caught signal %d\n", signum); fprintf(stderr, "Caught signal %d\n", signum);
cleanup(); cleanup();
exit(-signum); exit(-signum);
} }
void register_cleanup(void) static void register_cleanup(void)
{ {
struct sigaction sa = { .sa_handler = sig_handler }; struct sigaction sa = { .sa_handler = sig_handler };
const int signums[] = { SIGINT, SIGTERM, SIGABRT }; const int signums[] = { SIGINT, SIGTERM, SIGABRT };