How drivers maintains Device state information
I am writing a driver for a device which acts as both mouse and joy stick based on the bits set in the status registers and uses spi and twi protocols . My application sends ioctl to change device mode and bus mode whenever it needs to change. I also have to load patch file into the device when the driver is initalising. My application also queries about the device state information whenever it requires through ioctl.
My question is how can a driver maintains all these information because my application don't need to know maintains this informations. So my driver has to maintain this information i.e device mode whether it is mouse or joystick and bus modes whether it is spi or twi and patch file location to load into the device. And also when the system reboots the device has to be in the previous state what ever it is before shutdown. Can any one help me in this case.
I try to store the information in a file through structure which contains device mode ,busmode and patch file location and peform file operations through driver whenever any one of the structure element changes but it is not working because we are not supposed to do file operations in a kernel module . Please help whether there is any way to do this. I also want to know how normal driver in linux are maintaining the device configuration files i.e how display driver maintains the screen height and width i.e at any time i can change the screen size and resolution when the system reboots also the screen will be in same height and resolution which i was set before shutdown. How this is maintained by the drivers whether the driver or maintaining or someelse is maintaining this information.