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:

{0xf0,0x3},
{0x00,0xa5a5ffc0},
{0x04,0x00000000},
{0x08,0xe810c4e1},
{0x0c,0xd3dd7f4d},
{0x10,0xd7c56634},
{0x14,0xe3505a2a},
{0x18,0x514d494f},
{0x1c,0xf7c3bbe8},
{0x20,0x00000000},
{0x24,0x00000000},
{0x28,0x00000000},
{0x2c,0x00000000},
{0x30,0x00001000},
{0x34,0x00000000},
{0x38,0x00000000},
{0x3c,0x00000000},
{0x40,0x00000001},
{0x44,0x00000000},
{0x48,0x00000000},
{0x4c,0x00000000},
{0x50,0x00000000},
{0x54,0x01020304},
{0x58,0x05060708},
{0x5c,0x090a0b0c},
{0x60,0x0d0e0e0f},
{0x64,0x10111213},
{0x68,0x14151617},
{0x6c,0x18191a1b},
{0x70,0x1b1c1e1f},
{0x74,0x00000000},
{0x78,0x00010000},
{0x7c,0x8c846af3},
{0xf0,0x4},
{0x00,0x00000000},
{0x04,0x00000000},
{0x08,0x00000000},
{0x0c,0x00000000},
{0x10,0xfffffe70},
{0x14,0x00000000},
{0x18,0x00000000},
{0x1c,0x00000000},
{0x20,0x00000000},
{0x24,0x00000000},
{0x28,0x00000000},
{0x2c,0x00000000},

etc..

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.

Thanks
fsebentley


Source: linux

Leave a Reply

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