@@ -105,12 +105,14 @@ static int pdsfc_identify(struct pdsfc_dev *pdsfc)
105105static void pdsfc_free_endpoints (struct pdsfc_dev * pdsfc )
106106{
107107 struct device * dev = & pdsfc -> fwctl .dev ;
108+ u32 num_endpoints ;
108109 int i ;
109110
110111 if (!pdsfc -> endpoints )
111112 return ;
112113
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 ++ )
114116 mutex_destroy (& pdsfc -> endpoint_info [i ].lock );
115117 vfree (pdsfc -> endpoint_info );
116118 pdsfc -> endpoint_info = NULL ;
@@ -199,7 +201,7 @@ static int pdsfc_init_endpoints(struct pdsfc_dev *pdsfc)
199201 ep_entry = (struct pds_fwctl_query_data_endpoint * )pdsfc -> endpoints -> entries ;
200202 for (i = 0 ; i < num_endpoints ; i ++ ) {
201203 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 ) ;
203205 }
204206
205207 return 0 ;
@@ -214,6 +216,7 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
214216 struct pds_fwctl_query_data * data ;
215217 union pds_core_adminq_cmd cmd ;
216218 dma_addr_t data_pa ;
219+ u32 num_entries ;
217220 int err ;
218221 int i ;
219222
@@ -246,8 +249,9 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
246249 * pa = data_pa ;
247250
248251 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 ++ ) {
251255
252256 /* Translate FW command attribute to fwctl scope */
253257 switch (entries [i ].scope ) {
@@ -267,7 +271,7 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
267271 break ;
268272 }
269273 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 );
271275 }
272276
273277 return data ;
@@ -280,24 +284,26 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
280284 struct pds_fwctl_query_data_operation * op_entry ;
281285 struct pdsfc_rpc_endpoint_info * ep_info = NULL ;
282286 struct device * dev = & pdsfc -> fwctl .dev ;
287+ u32 num_entries ;
283288 int i ;
284289
285290 /* validate rpc in_len & out_len based
286291 * on ident.max_req_sz & max_resp_sz
287292 */
288- if (rpc -> in .len > pdsfc -> ident .max_req_sz ) {
293+ if (rpc -> in .len > le32_to_cpu ( pdsfc -> ident .max_req_sz ) ) {
289294 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 ) );
291296 return - EINVAL ;
292297 }
293298
294- if (rpc -> out .len > pdsfc -> ident .max_resp_sz ) {
299+ if (rpc -> out .len > le32_to_cpu ( pdsfc -> ident .max_resp_sz ) ) {
295300 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 ) );
297302 return - EINVAL ;
298303 }
299304
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 ++ ) {
301307 if (pdsfc -> endpoint_info [i ].endpoint == rpc -> in .ep ) {
302308 ep_info = & pdsfc -> endpoint_info [i ];
303309 break ;
@@ -326,8 +332,9 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
326332
327333 /* reject unsupported and/or out of scope commands */
328334 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 ))) {
331338 if (scope < op_entry [i ].scope )
332339 return - EPERM ;
333340 return 0 ;
@@ -402,7 +409,7 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
402409 cmd = (union pds_core_adminq_cmd ) {
403410 .fwctl_rpc = {
404411 .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 ) ,
406413 .ep = cpu_to_le32 (rpc -> in .ep ),
407414 .op = cpu_to_le32 (rpc -> in .op ),
408415 .req_pa = cpu_to_le64 (in_payload_dma_addr ),
0 commit comments