OSDN Git Service

msm: camera: Remove useless NULL checks in msm_flash_i2c_release
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / lib / qmi_encdec_priv.h
1 /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  */
12
13 #ifndef _QMI_ENCDEC_PRIV_H_
14 #define _QMI_ENCDEC_PRIV_H_
15
16 #include <linux/types.h>
17 #include <linux/errno.h>
18 #include <linux/mm.h>
19 #include <linux/list.h>
20 #include <linux/socket.h>
21 #include <linux/gfp.h>
22 #include <linux/qmi_encdec.h>
23
24 #define QMI_ENCDEC_ENCODE_TLV(type, length, p_dst) do { \
25         *p_dst++ = type; \
26         *p_dst++ = ((uint8_t)((length) & 0xFF)); \
27         *p_dst++ = ((uint8_t)(((length) >> 8) & 0xFF)); \
28 } while (0)
29
30 #define QMI_ENCDEC_DECODE_TLV(p_type, p_length, p_src) do { \
31         *p_type = (uint8_t)*p_src++; \
32         *p_length = (uint8_t)*p_src++; \
33         *p_length |= ((uint8_t)*p_src) << 8; \
34 } while (0)
35
36 #define QMI_ENCDEC_ENCODE_N_BYTES(p_dst, p_src, size) \
37 do { \
38         memcpy(p_dst, p_src, size); \
39         p_dst = (uint8_t *)p_dst + size; \
40         p_src = (uint8_t *)p_src + size; \
41 } while (0)
42
43 #define QMI_ENCDEC_DECODE_N_BYTES(p_dst, p_src, size) \
44 do { \
45         memcpy(p_dst, p_src, size); \
46         p_dst = (uint8_t *)p_dst + size; \
47         p_src = (uint8_t *)p_src + size; \
48 } while (0)
49
50 #define UPDATE_ENCODE_VARIABLES(temp_si, buf_dst, \
51                                 encoded_bytes, tlv_len, encode_tlv, rc) \
52 do { \
53         buf_dst = (uint8_t *)buf_dst + rc; \
54         encoded_bytes += rc; \
55         tlv_len += rc; \
56         temp_si = temp_si + 1; \
57         encode_tlv = 1; \
58 } while (0)
59
60 #define UPDATE_DECODE_VARIABLES(buf_src, decoded_bytes, rc) \
61 do { \
62         buf_src = (uint8_t *)buf_src + rc; \
63         decoded_bytes += rc; \
64 } while (0)
65
66 #endif