Fix Kernel compilation 5.10-rc1

Adapt code due set_fs() removal
See f56e65dff6
This commit is contained in:
Carlos
2020-10-30 22:28:50 +00:00
parent 1628c748ce
commit 8ba6813bfd
4 changed files with 44 additions and 3 deletions

View File

@@ -2193,16 +2193,19 @@ static int isFileReadable(const char *path, u32 *sz)
{
struct file *fp;
int ret = 0;
#ifdef set_fs
mm_segment_t oldfs;
#endif
char buf;
fp = filp_open(path, O_RDONLY, 0);
if (IS_ERR(fp))
ret = PTR_ERR(fp);
else {
#ifdef set_fs
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
if (1 != readFile(fp, &buf, 1))
ret = PTR_ERR(fp);
@@ -2214,7 +2217,9 @@ static int isFileReadable(const char *path, u32 *sz)
#endif
}
#ifdef set_fs
set_fs(oldfs);
#endif
filp_close(fp, NULL);
}
return ret;
@@ -2230,7 +2235,9 @@ static int isFileReadable(const char *path, u32 *sz)
static int retriveFromFile(const char *path, u8 *buf, u32 sz)
{
int ret = -1;
#ifdef set_fs
mm_segment_t oldfs;
#endif
struct file *fp;
if (path && buf) {
@@ -2238,10 +2245,14 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#ifdef set_fs
oldfs = get_fs();
set_fs(KERNEL_DS);
ret = readFile(fp, buf, sz);
set_fs(oldfs);
#else
ret = readFile(fp, buf, sz);
#endif
closeFile(fp);
RTW_INFO("%s readFile, ret:%d\n", __FUNCTION__, ret);
@@ -2265,7 +2276,9 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
static int storeToFile(const char *path, u8 *buf, u32 sz)
{
int ret = 0;
#ifdef set_fs
mm_segment_t oldfs;
#endif
struct file *fp;
if (path && buf) {
@@ -2273,12 +2286,15 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#ifdef set_fs
oldfs = get_fs();
set_fs(KERNEL_DS);
ret = writeFile(fp, buf, sz);
set_fs(oldfs);
#else
ret = writeFile(fp, buf, sz);
#endif
closeFile(fp);
RTW_INFO("%s writeFile, ret:%d\n", __FUNCTION__, ret);
} else