in Linux kernel module how can I read a file into this ? static const struct fw_data GSL1680_FW[] = {filecontent}

I attempting to modify an existing Linux Kernel module to load firmware
data from a file on the filesystem. I have examined many ways of doing
this in other Module code all would require major modification to the existing
code. I would like to use a .h file to contain the modifications and retain
the driver file itself as is so that the modified driver can be more portable.

The way the driver is written it already calls a .h file to obtain the needed
values, however those are pre-set in the .h file what I would like to do is
have the .h file obtain the data from a configuration file on disk (flash as
this driver is for android) . I have searched extensively for a comparable
method of reading the data from a file but none store the data in the form needed by the module. Here is what is to hold the data :

struct fw_data;

static const struct fw_data GSL1680_FW[] = { File Contents }

Here is a sample of the data to be stored in the structure:



The values are a register location and the hex data for that location.

There are examples of Modules that I have found that load the data directly into the chip from the file accomplishing similar functionality, however those that I have found make some extensive changes to the Main module in order to accomplish this, and as I said I would like to retain the Main module as close to its existing form as possible so that the functionality can be implemented in differing versions of the module and more portable from one SOC model to the next with minimal modification to the Main Module between them.

I have tried to read the data into GSLX680[] using filp_read in several ways however I have not had much success.

I am far from an expert in C programming and have Never attempted to make this much of a modification to a module before, and have never had to deal with reading data from a file in kernel space before. I am simply a Hobbyist attempting to add functionality to a driver in order to have it solve many of the issues with differences in configuration on chinese made Android devices using the same SOC. Any help is Greatly appreciated.


Source: linux

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.