xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/core/rtw_io.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2019 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 /*
16 
17 The purpose of rtw_io.c
18 
19 a. provides the API
20 
21 b. provides the protocol engine
22 
23 c. provides the software interface between caller and the hardware interface
24 
25 
26 Compiler Flag Option:
27 
28 1. CONFIG_SDIO_HCI:
29     a. USE_SYNC_IRP:  Only sync operations are provided.
30     b. USE_ASYNC_IRP:Both sync/async operations are provided.
31 
32 2. CONFIG_USB_HCI:
33    a. USE_ASYNC_IRP: Both sync/async operations are provided.
34 
35 3. CONFIG_CFIO_HCI:
36    b. USE_SYNC_IRP: Only sync operations are provided.
37 
38 
39 Only sync read/rtw_write_mem operations are provided.
40 
41 jackson@realtek.com.tw
42 
43 */
44 
45 #define _RTW_IO_C_
46 
47 #include <drv_types.h>
48 
49 /*
50 * Increase and check if the continual_io_error of this @param dvobjprive is larger than MAX_CONTINUAL_IO_ERR
51 * @return _TRUE:
52 * @return _FALSE:
53 */
rtw_inc_and_chk_continual_io_error(struct dvobj_priv * dvobj)54 int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj)
55 {
56 	int ret = _FALSE;
57 	int value;
58 
59 	value = ATOMIC_INC_RETURN(&dvobj->continual_io_error);
60 	if (value > MAX_CONTINUAL_IO_ERR) {
61 		RTW_INFO("[dvobj:%p][ERROR] continual_io_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_IO_ERR);
62 		ret = _TRUE;
63 	} else {
64 		/* RTW_INFO("[dvobj:%p] continual_io_error:%d\n", dvobj, value); */
65 	}
66 	return ret;
67 }
68 
69 /*
70 * Set the continual_io_error of this @param dvobjprive to 0
71 */
rtw_reset_continual_io_error(struct dvobj_priv * dvobj)72 void rtw_reset_continual_io_error(struct dvobj_priv *dvobj)
73 {
74 	ATOMIC_SET(&dvobj->continual_io_error, 0);
75 }
76