Linux 5.10 compat: remove set_fs()

This commit is contained in:
Rin Cat 2020-11-19 19:56:00 -05:00
parent 61a2ab6ce4
commit 64d833c13d
No known key found for this signature in database
GPG Key ID: 7E93675C2BDBB222
4 changed files with 44 additions and 0 deletions

View File

@ -1468,7 +1468,9 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for
{ {
u8 error; u8 error;
struct msghdr udpmsg; struct msghdr udpmsg;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs; mm_segment_t oldfs;
#endif
struct iovec iov; struct iovec iov;
struct bt_coex_info *pcoex_info = &padapter->coex_info; struct bt_coex_info *pcoex_info = &padapter->coex_info;
@ -1498,15 +1500,19 @@ u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool for
udpmsg.msg_control = NULL; udpmsg.msg_control = NULL;
udpmsg.msg_controllen = 0; udpmsg.msg_controllen = 0;
udpmsg.msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL; udpmsg.msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
error = sock_sendmsg(pcoex_info->udpsock, &udpmsg); error = sock_sendmsg(pcoex_info->udpsock, &udpmsg);
#else #else
error = sock_sendmsg(pcoex_info->udpsock, &udpmsg, msg_size); error = sock_sendmsg(pcoex_info->udpsock, &udpmsg, msg_size);
#endif #endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs); set_fs(oldfs);
#endif
if (error < 0) { if (error < 0) {
RTW_INFO("Error when sendimg msg, error:%d\n", error); RTW_INFO("Error when sendimg msg, error:%d\n", error);
return _FAIL; return _FAIL;

View File

@ -4799,7 +4799,9 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
int i = 0; int i = 0;
struct file *fp; struct file *fp;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t fs; mm_segment_t fs;
#endif
loff_t pos = 0; loff_t pos = 0;
u8 *source = NULL; u8 *source = NULL;
long len = 0; long len = 0;
@ -4836,8 +4838,10 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
return 0; return 0;
} }
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
fs = get_fs(); fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#endif
source = rtw_zmalloc(2048); source = rtw_zmalloc(2048);
@ -4847,7 +4851,9 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t *ssid,
rtw_mfree(source, 2048); rtw_mfree(source, 2048);
} }
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(fs); set_fs(fs);
#endif
filp_close(fp, NULL); filp_close(fp, NULL);
RTW_INFO("-%s-\n", __func__); RTW_INFO("-%s-\n", __func__);

View File

@ -4250,7 +4250,9 @@ static int route_dump(u32 *gw_addr , int *gw_index)
struct msghdr msg; struct msghdr msg;
struct iovec iov; struct iovec iov;
struct sockaddr_nl nladdr; struct sockaddr_nl nladdr;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs; mm_segment_t oldfs;
#endif
char *pg; char *pg;
int size = 0; int size = 0;
@ -4289,14 +4291,18 @@ static int route_dump(u32 *gw_addr , int *gw_index)
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT; msg.msg_flags = MSG_DONTWAIT;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
err = sock_sendmsg(sock, &msg); err = sock_sendmsg(sock, &msg);
#else #else
err = sock_sendmsg(sock, &msg, sizeof(req)); err = sock_sendmsg(sock, &msg, sizeof(req));
#endif #endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs); set_fs(oldfs);
#endif
if (err < 0) if (err < 0)
goto out_sock; goto out_sock;
@ -4321,14 +4327,18 @@ restart:
iov_iter_init(&msg.msg_iter, READ, &iov, 1, PAGE_SIZE); iov_iter_init(&msg.msg_iter, READ, &iov, 1, PAGE_SIZE);
#endif #endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
err = sock_recvmsg(sock, &msg, MSG_DONTWAIT); err = sock_recvmsg(sock, &msg, MSG_DONTWAIT);
#else #else
err = sock_recvmsg(sock, &msg, PAGE_SIZE, MSG_DONTWAIT); err = sock_recvmsg(sock, &msg, PAGE_SIZE, MSG_DONTWAIT);
#endif #endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs); set_fs(oldfs);
#endif
if (err < 0) if (err < 0)
goto out_sock_pg; goto out_sock_pg;
@ -4399,14 +4409,18 @@ done:
msg.msg_controllen = 0; msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT; msg.msg_flags = MSG_DONTWAIT;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
err = sock_sendmsg(sock, &msg); err = sock_sendmsg(sock, &msg);
#else #else
err = sock_sendmsg(sock, &msg, sizeof(req)); err = sock_sendmsg(sock, &msg, sizeof(req));
#endif #endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs); set_fs(oldfs);
#endif
if (err > 0) if (err > 0)
goto restart; goto restart;

View File

@ -2221,19 +2221,23 @@ static int isFileReadable(const char *path, u32 *sz)
{ {
struct file *fp; struct file *fp;
int ret = 0; int ret = 0;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs; mm_segment_t oldfs;
#endif
char buf; char buf;
fp = filp_open(path, O_RDONLY, 0); fp = filp_open(path, O_RDONLY, 0);
if (IS_ERR(fp)) if (IS_ERR(fp))
ret = PTR_ERR(fp); ret = PTR_ERR(fp);
else { else {
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs(); oldfs = get_fs();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#else #else
set_fs(get_ds()); set_fs(get_ds());
#endif #endif
#endif
if (1 != readFile(fp, &buf, 1)) if (1 != readFile(fp, &buf, 1))
ret = PTR_ERR(fp); ret = PTR_ERR(fp);
@ -2246,7 +2250,9 @@ static int isFileReadable(const char *path, u32 *sz)
#endif #endif
} }
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs); set_fs(oldfs);
#endif
filp_close(fp, NULL); filp_close(fp, NULL);
} }
return ret; return ret;
@ -2262,7 +2268,9 @@ static int isFileReadable(const char *path, u32 *sz)
static int retriveFromFile(const char *path, u8 *buf, u32 sz) static int retriveFromFile(const char *path, u8 *buf, u32 sz)
{ {
int ret = -1; int ret = -1;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs; mm_segment_t oldfs;
#endif
struct file *fp; struct file *fp;
if (path && buf) { if (path && buf) {
@ -2270,14 +2278,18 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) { if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp); RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs(); oldfs = get_fs();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#else #else
set_fs(get_ds()); set_fs(get_ds());
#endif #endif
#endif
ret = readFile(fp, buf, sz); ret = readFile(fp, buf, sz);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs); set_fs(oldfs);
#endif
closeFile(fp); closeFile(fp);
RTW_INFO("%s readFile, ret:%d\n", __FUNCTION__, ret); RTW_INFO("%s readFile, ret:%d\n", __FUNCTION__, ret);
@ -2301,7 +2313,9 @@ static int retriveFromFile(const char *path, u8 *buf, u32 sz)
static int storeToFile(const char *path, u8 *buf, u32 sz) static int storeToFile(const char *path, u8 *buf, u32 sz)
{ {
int ret = 0; int ret = 0;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs; mm_segment_t oldfs;
#endif
struct file *fp; struct file *fp;
if (path && buf) { if (path && buf) {
@ -2309,14 +2323,18 @@ static int storeToFile(const char *path, u8 *buf, u32 sz)
if (0 == ret) { if (0 == ret) {
RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp); RTW_INFO("%s openFile path:%s fp=%p\n", __FUNCTION__, path , fp);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs(); oldfs = get_fs();
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0))
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
#else #else
set_fs(get_ds()); set_fs(get_ds());
#endif #endif
#endif
ret = writeFile(fp, buf, sz); ret = writeFile(fp, buf, sz);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs); set_fs(oldfs);
#endif
closeFile(fp); closeFile(fp);
RTW_INFO("%s writeFile, ret:%d\n", __FUNCTION__, ret); RTW_INFO("%s writeFile, ret:%d\n", __FUNCTION__, ret);