staging: r8188eu: Remove wrappers for atomic operations
[linux-2.6-microblaze.git] / drivers / staging / r8188eu / include / usb_ops.h
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2011 Realtek Corporation. */
3
4 #ifndef __USB_OPS_H_
5 #define __USB_OPS_H_
6
7 #include "osdep_service.h"
8 #include "drv_types.h"
9 #include "osdep_intf.h"
10
11 #define REALTEK_USB_VENQT_READ          0xC0
12 #define REALTEK_USB_VENQT_WRITE         0x40
13 #define REALTEK_USB_VENQT_CMD_REQ       0x05
14 #define REALTEK_USB_VENQT_CMD_IDX       0x00
15
16 enum {
17         VENDOR_WRITE = 0x00,
18         VENDOR_READ = 0x01,
19 };
20 #define ALIGNMENT_UNIT                  16
21 #define MAX_VENDOR_REQ_CMD_SIZE 254     /* 8188cu SIE Support */
22 #define MAX_USB_IO_CTL_SIZE     (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
23
24 #include "usb_ops_linux.h"
25
26 void rtl8188eu_set_hw_type(struct adapter *padapter);
27 #define hal_set_hw_type rtl8188eu_set_hw_type
28 void rtl8188eu_set_intf_ops(struct _io_ops *pops);
29 #define usb_set_intf_ops rtl8188eu_set_intf_ops
30
31 /*
32  * Increase and check if the continual_urb_error of this @param dvobjprivei
33  * is larger than MAX_CONTINUAL_URB_ERR
34  * @return true:
35  * @return false:
36  */
37 static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
38 {
39         int ret = false;
40         int value;
41         value = atomic_inc_return(&dvobj->continual_urb_error);
42         if (value > MAX_CONTINUAL_URB_ERR) {
43                 DBG_88E("[dvobj:%p][ERROR] continual_urb_error:%d > %d\n",
44                         dvobj, value, MAX_CONTINUAL_URB_ERR);
45                 ret = true;
46         }
47         return ret;
48 }
49
50 /*
51 * Set the continual_urb_error of this @param dvobjprive to 0
52 */
53 static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj)
54 {
55         atomic_set(&dvobj->continual_urb_error, 0);
56 }
57
58 #define USB_HIGH_SPEED_BULK_SIZE        512
59 #define USB_FULL_SPEED_BULK_SIZE        64
60
61 static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter,
62                                             int buf_len)
63 {
64         u8 rst = true;
65         struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
66
67         if (pdvobjpriv->ishighspeed)
68                 rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ?
69                       true : false;
70         else
71                 rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ?
72                       true : false;
73         return rst;
74 }
75
76 #endif /* __USB_OPS_H_ */