flinklib
flinklib: flink C library for Linux
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, k;
40  uint32_t data;
41 
42  dbg_print("Reading description from info subdevice with id %d\n", subdev->id);
43 
45  for(i = 0; i < INFO_DESC_SIZE; i += 4, offset += 4) {
46  if(flink_read(subdev, offset, 4, &data) != REGISTER_WITH) {
47  libc_error();
48  return EXIT_ERROR;
49  }
50  for (k = REGISTER_WITH - 1; k >= 0; k--) {
51  *((uint8_t *)desc) = (uint8_t)(data >> (k * 8));
52  desc++;
53  }
54  dbg_print("\t 0x%x\n", data);
55  }
56  return EXIT_SUCCESS;
57 }
Data structures for flink devices and subdevices.
#define EXIT_ERROR
Definition: flinklib.h:129
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:50
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:51
#define EXIT_SUCCESS
Definition: flinklib.h:128
#define SUBHEADER_SIZE
Definition: flinklib.h:52
void libc_error(void)
Definition: error.c:56
#define INFO_DESC_SIZE
Definition: flinklib.h:55
Debug utilities.
#define dbg_print(fmt,...)
Definition: log.h:29