I would like to develop a device-driver on linux(written in C) and a user-space library wrapping all functions provided by my device-driver (also written in C). Just to make it more clear, my library wil provide the following methods:
int myOpen();void myClose();mySetConf(MyconfStruct conf)- etc.
The function will use the file associated to my device-driver, in particular:
myOpenwill call theopen()of my device-drivermyClosewill call theclose()of my device-drivermySetConfwill call theioctl()of my device driver and pass themyConfStructas a parameter to configure the device-driver usingioctl().
assume myConfStruct is a simple structure containing something like this:
typedef struct { uint16_t var1; uint8_t var2;} myConfStruct;I would like the myConfStruct to be a structure shared between both my user-application (library) and my kernel-driver using a single header.Are there any best-practice while doing this?I would like to have the structure defined into only one file, having it defined in multiple files seems to be quite error-prone if i plan on changing it in the future, but I understood that I should not include <linux/types.h> inside my user files and I shouldn't use <stdint.h> inside my device-driver.So another question is also, how can I define the interface between a module and the user-application so that who is implementing the application is not forced to include any linux header?