flinklib
flinklib: flink C library for Linux
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
info.c
Go to the documentation of this file.
1 /*******************************************************************
2  * _________ _____ _____ ____ _____ ___ ____ *
3  * |_ ___ | |_ _| |_ _| |_ \|_ _| |_ ||_ _| *
4  * | |_ \_| | | | | | \ | | | |_/ / *
5  * | _| | | _ | | | |\ \| | | __'. *
6  * _| |_ _| |__/ | _| |_ _| |_\ |_ _| | \ \_ *
7  * |_____| |________| |_____| |_____|\____| |____||____| *
8  * *
9  *******************************************************************
10  * *
11  * flink userspace library, subdevice function "info" *
12  * *
13  *******************************************************************/
14 
24 #include "flinklib.h"
25 #include "types.h"
26 #include "error.h"
27 #include "log.h"
28 
29 #include <stdint.h>
30 
37 int flink_info_get_description(flink_subdev* subdev, char* desc) {
38  uint32_t offset;
39  int i;
40 
41  dbg_print("Reading description from info subdevice with id %d\n", subdev->id);
42 
44  for(i = 0; i < INFO_DESC_SIZE; i += 4, offset += 4, desc += 4) {
45  if(flink_read(subdev, offset, 4, desc) != REGISTER_WITH) {
46  libc_error();
47  return EXIT_ERROR;
48  }
49  dbg_print("\t 0x%x\n", be16toh(*(uint32_t*)desc));
50  }
51  return EXIT_SUCCESS;
52 }
Data structures for flink devices and subdevices.
#define EXIT_ERROR
Definition: flinklib.h:118
ssize_t flink_read(flink_subdev *subdev, uint32_t offset, uint8_t size, void *rdata)
Read from a flink subdevice.
Definition: lowlevel.c:71
Error handling.
#define REGISTER_WITH
Definition: flinklib.h:48
int flink_info_get_description(flink_subdev *subdev, char *desc)
Reads the description field of an info subdevice.
Definition: info.c:37
#define HEADER_SIZE
Definition: flinklib.h:49
#define EXIT_SUCCESS
Definition: flinklib.h:117
#define SUBHEADER_SIZE
Definition: flinklib.h:50
void libc_error(void)
Definition: error.c:56
#define INFO_DESC_SIZE
Definition: flinklib.h:53
Debug utilities.
#define dbg_print(fmt,...)
Definition: log.h:29