aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoria Geantă <horia.geanta@nxp.com>2017-04-28 10:38:58 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-28 11:51:54 -0400
commit11270059e8d0b6f80801fac910c4ef751ca05c4c (patch)
tree55a5fda68baa3a01a976be1ea642724ff4ef61b8
parentec4d9227d79a6f0d1cedbbb8f023c92779c16551 (diff)
staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd
While dpaa2_fd.simple structure fields are marked __leXX, corresponding cpu_to_leXX / leXX_to_cpu conversions are missing. While here, fix dpaa2_fd_{get,set}_bpid such that BMT, IVP bits sharing the 16-bit field with BPID are not affected. Fixes: d3269bdc7ebc ("bus: fsl-mc: dpio: add frame descriptor and scatter/gather APIs") Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/fsl-mc/include/dpaa2-fd.h45
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/staging/fsl-mc/include/dpaa2-fd.h b/drivers/staging/fsl-mc/include/dpaa2-fd.h
index 9500123cc7f9..cf7857f00a5c 100644
--- a/drivers/staging/fsl-mc/include/dpaa2-fd.h
+++ b/drivers/staging/fsl-mc/include/dpaa2-fd.h
@@ -81,6 +81,7 @@ struct dpaa2_fd {
81#define FD_OFFSET_MASK 0x0FFF 81#define FD_OFFSET_MASK 0x0FFF
82#define FD_FORMAT_MASK 0x3 82#define FD_FORMAT_MASK 0x3
83#define FD_FORMAT_SHIFT 12 83#define FD_FORMAT_SHIFT 12
84#define FD_BPID_MASK 0x3FFF
84#define SG_SHORT_LEN_FLAG_MASK 0x1 85#define SG_SHORT_LEN_FLAG_MASK 0x1
85#define SG_SHORT_LEN_FLAG_SHIFT 14 86#define SG_SHORT_LEN_FLAG_SHIFT 14
86#define SG_SHORT_LEN_MASK 0x1FFFF 87#define SG_SHORT_LEN_MASK 0x1FFFF
@@ -105,7 +106,7 @@ enum dpaa2_fd_format {
105 */ 106 */
106static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd) 107static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
107{ 108{
108 return (dma_addr_t)fd->simple.addr; 109 return (dma_addr_t)le64_to_cpu(fd->simple.addr);
109} 110}
110 111
111/** 112/**
@@ -115,7 +116,7 @@ static inline dma_addr_t dpaa2_fd_get_addr(const struct dpaa2_fd *fd)
115 */ 116 */
116static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr) 117static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
117{ 118{
118 fd->simple.addr = addr; 119 fd->simple.addr = cpu_to_le64(addr);
119} 120}
120 121
121/** 122/**
@@ -126,7 +127,7 @@ static inline void dpaa2_fd_set_addr(struct dpaa2_fd *fd, dma_addr_t addr)
126 */ 127 */
127static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd) 128static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
128{ 129{
129 return fd->simple.frc; 130 return le32_to_cpu(fd->simple.frc);
130} 131}
131 132
132/** 133/**
@@ -136,7 +137,7 @@ static inline u32 dpaa2_fd_get_frc(const struct dpaa2_fd *fd)
136 */ 137 */
137static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc) 138static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
138{ 139{
139 fd->simple.frc = frc; 140 fd->simple.frc = cpu_to_le32(frc);
140} 141}
141 142
142/** 143/**
@@ -147,7 +148,7 @@ static inline void dpaa2_fd_set_frc(struct dpaa2_fd *fd, u32 frc)
147 */ 148 */
148static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd) 149static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
149{ 150{
150 return fd->simple.ctrl; 151 return le32_to_cpu(fd->simple.ctrl);
151} 152}
152 153
153/** 154/**
@@ -157,7 +158,7 @@ static inline u32 dpaa2_fd_get_ctrl(const struct dpaa2_fd *fd)
157 */ 158 */
158static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl) 159static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
159{ 160{
160 fd->simple.ctrl = ctrl; 161 fd->simple.ctrl = cpu_to_le32(ctrl);
161} 162}
162 163
163/** 164/**
@@ -168,7 +169,7 @@ static inline void dpaa2_fd_set_ctrl(struct dpaa2_fd *fd, u32 ctrl)
168 */ 169 */
169static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd) 170static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
170{ 171{
171 return (dma_addr_t)fd->simple.flc; 172 return (dma_addr_t)le64_to_cpu(fd->simple.flc);
172} 173}
173 174
174/** 175/**
@@ -178,13 +179,13 @@ static inline dma_addr_t dpaa2_fd_get_flc(const struct dpaa2_fd *fd)
178 */ 179 */
179static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd, dma_addr_t flc_addr) 180static inline void dpaa2_fd_set_flc(struct dpaa2_fd *fd, dma_addr_t flc_addr)
180{ 181{
181 fd->simple.flc = flc_addr; 182 fd->simple.flc = cpu_to_le64(flc_addr);
182} 183}
183 184
184static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd) 185static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
185{ 186{
186 return !!((fd->simple.format_offset >> FD_SHORT_LEN_FLAG_SHIFT) 187 return !!((le16_to_cpu(fd->simple.format_offset) >>
187 & FD_SHORT_LEN_FLAG_MASK); 188 FD_SHORT_LEN_FLAG_SHIFT) & FD_SHORT_LEN_FLAG_MASK);
188} 189}
189 190
190/** 191/**
@@ -196,9 +197,9 @@ static inline bool dpaa2_fd_short_len(const struct dpaa2_fd *fd)
196static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd) 197static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
197{ 198{
198 if (dpaa2_fd_short_len(fd)) 199 if (dpaa2_fd_short_len(fd))
199 return fd->simple.len & FD_SHORT_LEN_MASK; 200 return le32_to_cpu(fd->simple.len) & FD_SHORT_LEN_MASK;
200 201
201 return fd->simple.len; 202 return le32_to_cpu(fd->simple.len);
202} 203}
203 204
204/** 205/**
@@ -208,7 +209,7 @@ static inline u32 dpaa2_fd_get_len(const struct dpaa2_fd *fd)
208 */ 209 */
209static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len) 210static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
210{ 211{
211 fd->simple.len = len; 212 fd->simple.len = cpu_to_le32(len);
212} 213}
213 214
214/** 215/**
@@ -219,7 +220,7 @@ static inline void dpaa2_fd_set_len(struct dpaa2_fd *fd, u32 len)
219 */ 220 */
220static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd) 221static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
221{ 222{
222 return fd->simple.format_offset & FD_OFFSET_MASK; 223 return le16_to_cpu(fd->simple.format_offset) & FD_OFFSET_MASK;
223} 224}
224 225
225/** 226/**
@@ -229,8 +230,8 @@ static inline uint16_t dpaa2_fd_get_offset(const struct dpaa2_fd *fd)
229 */ 230 */
230static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset) 231static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
231{ 232{
232 fd->simple.format_offset &= ~FD_OFFSET_MASK; 233 fd->simple.format_offset &= cpu_to_le16(~FD_OFFSET_MASK);
233 fd->simple.format_offset |= offset; 234 fd->simple.format_offset |= cpu_to_le16(offset);
234} 235}
235 236
236/** 237/**
@@ -242,7 +243,7 @@ static inline void dpaa2_fd_set_offset(struct dpaa2_fd *fd, uint16_t offset)
242static inline enum dpaa2_fd_format dpaa2_fd_get_format( 243static inline enum dpaa2_fd_format dpaa2_fd_get_format(
243 const struct dpaa2_fd *fd) 244 const struct dpaa2_fd *fd)
244{ 245{
245 return (enum dpaa2_fd_format)((fd->simple.format_offset 246 return (enum dpaa2_fd_format)((le16_to_cpu(fd->simple.format_offset)
246 >> FD_FORMAT_SHIFT) & FD_FORMAT_MASK); 247 >> FD_FORMAT_SHIFT) & FD_FORMAT_MASK);
247} 248}
248 249
@@ -254,8 +255,9 @@ static inline enum dpaa2_fd_format dpaa2_fd_get_format(
254static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd, 255static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
255 enum dpaa2_fd_format format) 256 enum dpaa2_fd_format format)
256{ 257{
257 fd->simple.format_offset &= ~(FD_FORMAT_MASK << FD_FORMAT_SHIFT); 258 fd->simple.format_offset &=
258 fd->simple.format_offset |= format << FD_FORMAT_SHIFT; 259 cpu_to_le16(~(FD_FORMAT_MASK << FD_FORMAT_SHIFT));
260 fd->simple.format_offset |= cpu_to_le16(format << FD_FORMAT_SHIFT);
259} 261}
260 262
261/** 263/**
@@ -266,7 +268,7 @@ static inline void dpaa2_fd_set_format(struct dpaa2_fd *fd,
266 */ 268 */
267static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd) 269static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
268{ 270{
269 return fd->simple.bpid; 271 return le16_to_cpu(fd->simple.bpid) & FD_BPID_MASK;
270} 272}
271 273
272/** 274/**
@@ -276,7 +278,8 @@ static inline uint16_t dpaa2_fd_get_bpid(const struct dpaa2_fd *fd)
276 */ 278 */
277static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid) 279static inline void dpaa2_fd_set_bpid(struct dpaa2_fd *fd, uint16_t bpid)
278{ 280{
279 fd->simple.bpid = bpid; 281 fd->simple.bpid &= cpu_to_le16(~(FD_BPID_MASK));
282 fd->simple.bpid |= cpu_to_le16(bpid);
280} 283}
281 284
282/** 285/**