rtl8188eu: Fix checkpatch errors in os_dep/osdep_service.c

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
Larry Finger 2013-08-10 12:57:27 -05:00
parent 5a7c47efff
commit 394828ff89

View file

@ -31,17 +31,12 @@
* Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE
* @return: one of RTW_STATUS_CODE * @return: one of RTW_STATUS_CODE
*/ */
inline int RTW_STATUS_CODE(int error_code){ inline int RTW_STATUS_CODE(int error_code)
{
if (error_code >= 0) if (error_code >= 0)
return _SUCCESS; return _SUCCESS;
switch (error_code) {
//case -ETIMEDOUT:
// return RTW_STATUS_TIMEDOUT;
default:
return _FAIL; return _FAIL;
} }
}
u32 rtw_atoi(u8 *s) u32 rtw_atoi(u8 *s)
{ {
@ -55,11 +50,9 @@ u32 rtw_atoi(u8* s)
else else
break; break;
} }
if (flag == 1) if (flag == 1)
num = num * -1; num = num * -1;
return num;
return(num);
} }
inline u8 *_rtw_vmalloc(u32 sz) inline u8 *_rtw_vmalloc(u32 sz)
@ -133,7 +126,8 @@ void _rtw_memcpy(void* dst, void* src, u32 sz)
int _rtw_memcmp(void *dst, void *src, u32 sz) int _rtw_memcmp(void *dst, void *src, u32 sz)
{ {
//under Linux/GNU/GLibc, the return value of memcmp for two same mem. chunk is 0 /* under Linux/GNU/GLibc, the return value of memcmp for two same
* mem. chunk is 0 */
if (!(memcmp(dst, src, sz))) if (!(memcmp(dst, src, sz)))
return true; return true;
else else
@ -258,7 +252,8 @@ inline u32 rtw_ms_to_systime(u32 ms)
return ms * HZ / 1000; return ms * HZ / 1000;
} }
// the input parameter start use the same unit as returned by rtw_get_current_time /* the input parameter start use the same unit as returned by
* rtw_get_current_time */
inline s32 rtw_get_passing_time_ms(u32 start) inline s32 rtw_get_passing_time_ms(u32 start)
{ {
return rtw_systime_to_ms(jiffies-start); return rtw_systime_to_ms(jiffies-start);
@ -273,15 +268,13 @@ void rtw_sleep_schedulable(int ms)
{ {
u32 delta; u32 delta;
delta = (ms * HZ)/1000;//(ms) delta = (ms * HZ)/1000;/* ms) */
if (delta == 0) { if (delta == 0)
delta = 1;// 1 ms delta = 1;/* 1 ms */
}
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
if (schedule_timeout(delta) != 0) { if (schedule_timeout(delta) != 0)
return; return;
} }
}
void rtw_msleep_os(int ms) void rtw_msleep_os(int ms)
{ {
@ -333,7 +326,7 @@ inline void rtw_unlock_suspend(void)
inline void rtw_lock_suspend_timeout(long timeout) inline void rtw_lock_suspend_timeout(long timeout)
{ {
} }
#endif //CONFIG_WOWLAN #endif /* CONFIG_WOWLAN */
inline void ATOMIC_SET(ATOMIC_T *v, int i) inline void ATOMIC_SET(ATOMIC_T *v, int i)
{ {
@ -385,15 +378,14 @@ inline int ATOMIC_DEC_RETURN(ATOMIC_T *v)
return atomic_dec_return(v); return atomic_dec_return(v);
} }
/* /* Open a file with the specific @param path, @param flag, @param mode
* Open a file with the specific @param path, @param flag, @param mode
* @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success * @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success
* @param path the path of the file to open * @param path the path of the file to open
* @param flag file operation flags, please refer to linux document * @param flag file operation flags, please refer to linux document
* @param mode please refer to linux document * @param mode please refer to linux document
* @return Linux specific error code * @return Linux specific error code
*/ */
static int openFile(struct file **fpp, char *path, int flag, int mode) static int openfile(struct file **fpp, char *path, int flag, int mode)
{ {
struct file *fp; struct file *fp;
@ -401,25 +393,23 @@ static int openFile(struct file **fpp, char *path, int flag, int mode)
if (IS_ERR(fp)) { if (IS_ERR(fp)) {
*fpp = NULL; *fpp = NULL;
return PTR_ERR(fp); return PTR_ERR(fp);
} } else {
else {
*fpp = fp; *fpp = fp;
return 0; return 0;
} }
} }
/* /* Close the file with the specific @param fp
* Close the file with the specific @param fp
* @param fp the pointer of struct file to close * @param fp the pointer of struct file to close
* @return always 0 * @return always 0
*/ */
static int closeFile(struct file *fp) static int closefile(struct file *fp)
{ {
filp_close(fp, NULL); filp_close(fp, NULL);
return 0; return 0;
} }
static int readFile(struct file *fp,char __user *buf,int len) static int readfile(struct file *fp, char __user *buf, int len)
{ {
int rlen = 0, sum = 0; int rlen = 0, sum = 0;
@ -435,12 +425,10 @@ static int readFile(struct file *fp,char __user *buf,int len)
else else
break; break;
} }
return sum; return sum;
} }
static int writeFile(struct file *fp, char __user *buf, int len) static int writefile(struct file *fp, char __user *buf, int len)
{ {
int wlen = 0, sum = 0; int wlen = 0, sum = 0;
@ -456,17 +444,14 @@ static int writeFile(struct file *fp, char __user *buf, int len)
else else
break; break;
} }
return sum; return sum;
} }
/* /* Test if the specifi @param path is a file and readable
* Test if the specifi @param path is a file and readable
* @param path the path of the file to test * @param path the path of the file to test
* @return Linux specific error code * @return Linux specific error code
*/ */
static int isFileReadable(char *path) static int isfilereadable(char *path)
{ {
struct file *fp; struct file *fp;
int ret = 0; int ret = 0;
@ -476,11 +461,10 @@ static int isFileReadable(char *path)
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 {
oldfs = get_fs(); set_fs(get_ds()); oldfs = get_fs(); set_fs(get_ds());
if (1!=readFile(fp, &buf, 1)) if (1 != readfile(fp, &buf, 1))
ret = PTR_ERR(fp); ret = PTR_ERR(fp);
set_fs(oldfs); set_fs(oldfs);
@ -489,32 +473,35 @@ static int isFileReadable(char *path)
return ret; return ret;
} }
/* /* Open the file with @param path and retrive the file content into
* Open the file with @param path and retrive the file content into memory starting from @param buf for @param sz at most * memory starting from @param buf for @param sz at most
* @param path the path of the file to open and read * @param path the path of the file to open and read
* @param buf the starting address of the buffer to store file content * @param buf the starting address of the buffer to store file content
* @param sz how many bytes to read at most * @param sz how many bytes to read at most
* @return the byte we've read, or Linux specific error code * @return the byte we've read, or Linux specific error code
*/ */
static int retriveFromFile(char *path, u8 __user *buf, u32 sz) static int retrievefromfile(char *path, u8 __user *buf, u32 sz)
{ {
int ret = -1; int ret = -1;
mm_segment_t oldfs; mm_segment_t oldfs;
struct file *fp; struct file *fp;
if (path && buf) { if (path && buf) {
if ( 0 == (ret=openFile(&fp,path, O_RDONLY, 0)) ){ ret = openfile(&fp, path, O_RDONLY, 0);
DBG_88E("%s openFile path:%s fp=%p\n",__func__, path ,fp); if (0 == ret) {
DBG_88E("%s openfile path:%s fp =%p\n", __func__,
path, fp);
oldfs = get_fs(); set_fs(get_ds()); oldfs = get_fs(); set_fs(get_ds());
ret=readFile(fp, buf, sz); ret = readfile(fp, buf, sz);
set_fs(oldfs); set_fs(oldfs);
closeFile(fp); closefile(fp);
DBG_88E("%s readFile, ret:%d\n",__func__, ret); DBG_88E("%s readfile, ret:%d\n", __func__, ret);
} else { } else {
DBG_88E("%s openFile path:%s Fail, ret:%d\n",__func__, path, ret); DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__,
path, ret);
} }
} else { } else {
DBG_88E("%s NULL pointer\n", __func__); DBG_88E("%s NULL pointer\n", __func__);
@ -530,25 +517,26 @@ static int retriveFromFile(char *path, u8 __user *buf, u32 sz)
* @param sz how many bytes to write at most * @param sz how many bytes to write at most
* @return the byte we've written, or Linux specific error code * @return the byte we've written, or Linux specific error code
*/ */
static int storeToFile(char *path, u8 __user *buf, u32 sz) static int storetofile(char *path, u8 __user *buf, u32 sz)
{ {
int ret = 0; int ret = 0;
mm_segment_t oldfs; mm_segment_t oldfs;
struct file *fp; struct file *fp;
if (path && buf) { if (path && buf) {
if ( 0 == (ret=openFile(&fp, path, O_CREAT|O_WRONLY, 0666)) ) { ret = openfile(&fp, path, O_CREAT|O_WRONLY, 0666);
DBG_88E("%s openFile path:%s fp=%p\n",__func__, path ,fp); if (0 == ret) {
DBG_88E("%s openfile path:%s fp =%p\n", __func__, path, fp);
oldfs = get_fs(); set_fs(get_ds()); oldfs = get_fs(); set_fs(get_ds());
ret=writeFile(fp, buf, sz); ret = writefile(fp, buf, sz);
set_fs(oldfs); set_fs(oldfs);
closeFile(fp); closefile(fp);
DBG_88E("%s writeFile, ret:%d\n",__func__, ret); DBG_88E("%s writefile, ret:%d\n", __func__, ret);
} else { } else {
DBG_88E("%s openFile path:%s Fail, ret:%d\n",__func__, path, ret); DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__, path, ret);
} }
} else { } else {
DBG_88E("%s NULL pointer\n", __func__); DBG_88E("%s NULL pointer\n", __func__);
@ -564,7 +552,7 @@ static int storeToFile(char *path, u8 __user *buf, u32 sz)
*/ */
int rtw_is_file_readable(char *path) int rtw_is_file_readable(char *path)
{ {
if (isFileReadable(path) == 0) if (isfilereadable(path) == 0)
return true; return true;
else else
return false; return false;
@ -579,12 +567,14 @@ int rtw_is_file_readable(char *path)
*/ */
int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz) int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz)
{ {
int ret =retriveFromFile(path, buf, sz); int ret = retrievefromfile(path, buf, sz);
return ret >= 0 ? ret : 0; return ret >= 0 ? ret : 0;
} }
/* /*
* Open the file with @param path and wirte @param sz byte of data starting from @param buf into the file * Open the file with @param path and wirte @param sz byte of data
* starting from @param buf into the file
* @param path the path of the file to open and write * @param path the path of the file to open and write
* @param buf the starting address of the data to write into file * @param buf the starting address of the data to write into file
* @param sz how many bytes to write at most * @param sz how many bytes to write at most
@ -592,17 +582,19 @@ int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz)
*/ */
int rtw_store_to_file(char *path, u8 __user *buf, u32 sz) int rtw_store_to_file(char *path, u8 __user *buf, u32 sz)
{ {
int ret =storeToFile(path, buf, sz); int ret = storetofile(path, buf, sz);
return ret >= 0 ? ret : 0; return ret >= 0 ? ret : 0;
} }
struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv) struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv,
void *old_priv)
{ {
struct net_device *pnetdev; struct net_device *pnetdev;
struct rtw_netdev_priv_indicator *pnpi; struct rtw_netdev_priv_indicator *pnpi;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator),
4);
#else #else
pnetdev = alloc_etherdev(sizeof(struct rtw_netdev_priv_indicator)); pnetdev = alloc_etherdev(sizeof(struct rtw_netdev_priv_indicator));
#endif #endif
@ -623,7 +615,8 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv)
struct rtw_netdev_priv_indicator *pnpi; struct rtw_netdev_priv_indicator *pnpi;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator),
4);
#else #else
pnetdev = alloc_etherdev(sizeof(struct rtw_netdev_priv_indicator)); pnetdev = alloc_etherdev(sizeof(struct rtw_netdev_priv_indicator));
#endif #endif
@ -664,7 +657,7 @@ RETURN:
} }
/* /*
* Jeff: this function should be called under ioctl (rtnl_lock is accquired) while * this function should be called under ioctl (rtnl_lock is accquired) while
* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) * LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
*/ */
int rtw_change_ifname(struct adapter *padapter, const char *ifname) int rtw_change_ifname(struct adapter *padapter, const char *ifname)
@ -679,7 +672,7 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname)
rereg_priv = &padapter->rereg_nd_name_priv; rereg_priv = &padapter->rereg_nd_name_priv;
//free the old_pnetdev /* free the old_pnetdev */
if (rereg_priv->old_pnetdev) { if (rereg_priv->old_pnetdev) {
free_netdev(rereg_priv->old_pnetdev); free_netdev(rereg_priv->old_pnetdev);
rereg_priv->old_pnetdev = NULL; rereg_priv->old_pnetdev = NULL;
@ -714,20 +707,15 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname)
else else
#endif #endif
ret = register_netdevice(pnetdev); ret = register_netdevice(pnetdev);
if (ret != 0) { if (ret != 0) {
RT_TRACE(_module_hci_intfs_c_,_drv_err_,("register_netdev() failed\n")); RT_TRACE(_module_hci_intfs_c_, _drv_err_,
("register_netdev() failed\n"));
goto error; goto error;
} }
rtw_proc_init_one(pnetdev); rtw_proc_init_one(pnetdev);
return 0; return 0;
error: error:
return -1; return -1;
} }
u64 rtw_modular64(u64 x, u64 y) u64 rtw_modular64(u64 x, u64 y)
@ -861,13 +849,14 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size)
{ {
struct rtw_cbuf *cbuf; struct rtw_cbuf *cbuf;
cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + sizeof(void*)*size); cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) +
sizeof(void *)*size);
if (cbuf) { if (cbuf) {
cbuf->write = cbuf->read = 0; cbuf->write = 0;
cbuf->read = 0;
cbuf->size = size; cbuf->size = size;
} }
return cbuf; return cbuf;
} }