@@ -105,12 +105,14 @@ static int pdsfc_identify(struct pdsfc_dev *pdsfc)
105
105
static void pdsfc_free_endpoints (struct pdsfc_dev * pdsfc )
106
106
{
107
107
struct device * dev = & pdsfc -> fwctl .dev ;
108
+ u32 num_endpoints ;
108
109
int i ;
109
110
110
111
if (!pdsfc -> endpoints )
111
112
return ;
112
113
113
- for (i = 0 ; pdsfc -> endpoint_info && i < pdsfc -> endpoints -> num_entries ; i ++ )
114
+ num_endpoints = le32_to_cpu (pdsfc -> endpoints -> num_entries );
115
+ for (i = 0 ; pdsfc -> endpoint_info && i < num_endpoints ; i ++ )
114
116
mutex_destroy (& pdsfc -> endpoint_info [i ].lock );
115
117
vfree (pdsfc -> endpoint_info );
116
118
pdsfc -> endpoint_info = NULL ;
@@ -199,7 +201,7 @@ static int pdsfc_init_endpoints(struct pdsfc_dev *pdsfc)
199
201
ep_entry = (struct pds_fwctl_query_data_endpoint * )pdsfc -> endpoints -> entries ;
200
202
for (i = 0 ; i < num_endpoints ; i ++ ) {
201
203
mutex_init (& pdsfc -> endpoint_info [i ].lock );
202
- pdsfc -> endpoint_info [i ].endpoint = ep_entry [i ].id ;
204
+ pdsfc -> endpoint_info [i ].endpoint = le32_to_cpu ( ep_entry [i ].id ) ;
203
205
}
204
206
205
207
return 0 ;
@@ -214,6 +216,7 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
214
216
struct pds_fwctl_query_data * data ;
215
217
union pds_core_adminq_cmd cmd ;
216
218
dma_addr_t data_pa ;
219
+ u32 num_entries ;
217
220
int err ;
218
221
int i ;
219
222
@@ -246,8 +249,9 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
246
249
* pa = data_pa ;
247
250
248
251
entries = (struct pds_fwctl_query_data_operation * )data -> entries ;
249
- dev_dbg (dev , "num_entries %d\n" , data -> num_entries );
250
- for (i = 0 ; i < data -> num_entries ; i ++ ) {
252
+ num_entries = le32_to_cpu (data -> num_entries );
253
+ dev_dbg (dev , "num_entries %d\n" , num_entries );
254
+ for (i = 0 ; i < num_entries ; i ++ ) {
251
255
252
256
/* Translate FW command attribute to fwctl scope */
253
257
switch (entries [i ].scope ) {
@@ -267,7 +271,7 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
267
271
break ;
268
272
}
269
273
dev_dbg (dev , "endpoint %d operation: id %x scope %d\n" ,
270
- ep , entries [i ].id , entries [i ].scope );
274
+ ep , le32_to_cpu ( entries [i ].id ) , entries [i ].scope );
271
275
}
272
276
273
277
return data ;
@@ -280,24 +284,26 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
280
284
struct pds_fwctl_query_data_operation * op_entry ;
281
285
struct pdsfc_rpc_endpoint_info * ep_info = NULL ;
282
286
struct device * dev = & pdsfc -> fwctl .dev ;
287
+ u32 num_entries ;
283
288
int i ;
284
289
285
290
/* validate rpc in_len & out_len based
286
291
* on ident.max_req_sz & max_resp_sz
287
292
*/
288
- if (rpc -> in .len > pdsfc -> ident .max_req_sz ) {
293
+ if (rpc -> in .len > le32_to_cpu ( pdsfc -> ident .max_req_sz ) ) {
289
294
dev_dbg (dev , "Invalid request size %u, max %u\n" ,
290
- rpc -> in .len , pdsfc -> ident .max_req_sz );
295
+ rpc -> in .len , le32_to_cpu ( pdsfc -> ident .max_req_sz ) );
291
296
return - EINVAL ;
292
297
}
293
298
294
- if (rpc -> out .len > pdsfc -> ident .max_resp_sz ) {
299
+ if (rpc -> out .len > le32_to_cpu ( pdsfc -> ident .max_resp_sz ) ) {
295
300
dev_dbg (dev , "Invalid response size %u, max %u\n" ,
296
- rpc -> out .len , pdsfc -> ident .max_resp_sz );
301
+ rpc -> out .len , le32_to_cpu ( pdsfc -> ident .max_resp_sz ) );
297
302
return - EINVAL ;
298
303
}
299
304
300
- for (i = 0 ; i < pdsfc -> endpoints -> num_entries ; i ++ ) {
305
+ num_entries = le32_to_cpu (pdsfc -> endpoints -> num_entries );
306
+ for (i = 0 ; i < num_entries ; i ++ ) {
301
307
if (pdsfc -> endpoint_info [i ].endpoint == rpc -> in .ep ) {
302
308
ep_info = & pdsfc -> endpoint_info [i ];
303
309
break ;
@@ -326,8 +332,9 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
326
332
327
333
/* reject unsupported and/or out of scope commands */
328
334
op_entry = (struct pds_fwctl_query_data_operation * )ep_info -> operations -> entries ;
329
- for (i = 0 ; i < ep_info -> operations -> num_entries ; i ++ ) {
330
- if (PDS_FWCTL_RPC_OPCODE_CMP (rpc -> in .op , op_entry [i ].id )) {
335
+ num_entries = le32_to_cpu (ep_info -> operations -> num_entries );
336
+ for (i = 0 ; i < num_entries ; i ++ ) {
337
+ if (PDS_FWCTL_RPC_OPCODE_CMP (rpc -> in .op , le32_to_cpu (op_entry [i ].id ))) {
331
338
if (scope < op_entry [i ].scope )
332
339
return - EPERM ;
333
340
return 0 ;
@@ -402,7 +409,7 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
402
409
cmd = (union pds_core_adminq_cmd ) {
403
410
.fwctl_rpc = {
404
411
.opcode = PDS_FWCTL_CMD_RPC ,
405
- .flags = PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP ,
412
+ .flags = cpu_to_le16 ( PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP ) ,
406
413
.ep = cpu_to_le32 (rpc -> in .ep ),
407
414
.op = cpu_to_le32 (rpc -> in .op ),
408
415
.req_pa = cpu_to_le64 (in_payload_dma_addr ),
0 commit comments