Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pds_fwctl: Fix type and endian complaints

Fix a number of type and endian complaints from the sparse checker.

Link: https://patch.msgid.link/r/20250402165630.24288-1-shannon.nelson@amd.com
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504020246.Dfbhxoo9-lkp@intel.com/
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Shannon Nelson and committed by
Jason Gunthorpe
fd292c1f 7bdd8f75

+20 -13
+20 -13
drivers/fwctl/pds/main.c
··· 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; ··· 201 199 ep_entry = (struct pds_fwctl_query_data_endpoint *)pdsfc->endpoints->entries; 202 200 for (i = 0; i < num_endpoints; i++) { 203 201 mutex_init(&pdsfc->endpoint_info[i].lock); 204 - pdsfc->endpoint_info[i].endpoint = ep_entry[i].id; 202 + pdsfc->endpoint_info[i].endpoint = le32_to_cpu(ep_entry[i].id); 205 203 } 206 204 207 205 return 0; ··· 216 214 struct pds_fwctl_query_data *data; 217 215 union pds_core_adminq_cmd cmd; 218 216 dma_addr_t data_pa; 217 + u32 num_entries; 219 218 int err; 220 219 int i; 221 220 ··· 249 246 *pa = data_pa; 250 247 251 248 entries = (struct pds_fwctl_query_data_operation *)data->entries; 252 - dev_dbg(dev, "num_entries %d\n", data->num_entries); 253 - for (i = 0; i < data->num_entries; i++) { 249 + num_entries = le32_to_cpu(data->num_entries); 250 + dev_dbg(dev, "num_entries %d\n", num_entries); 251 + for (i = 0; i < num_entries; i++) { 254 252 255 253 /* Translate FW command attribute to fwctl scope */ 256 254 switch (entries[i].scope) { ··· 271 267 break; 272 268 } 273 269 dev_dbg(dev, "endpoint %d operation: id %x scope %d\n", 274 - ep, entries[i].id, entries[i].scope); 270 + ep, le32_to_cpu(entries[i].id), entries[i].scope); 275 271 } 276 272 277 273 return data; ··· 284 280 struct pds_fwctl_query_data_operation *op_entry; 285 281 struct pdsfc_rpc_endpoint_info *ep_info = NULL; 286 282 struct device *dev = &pdsfc->fwctl.dev; 283 + u32 num_entries; 287 284 int i; 288 285 289 286 /* validate rpc in_len & out_len based 290 287 * on ident.max_req_sz & max_resp_sz 291 288 */ 292 - if (rpc->in.len > pdsfc->ident.max_req_sz) { 289 + if (rpc->in.len > le32_to_cpu(pdsfc->ident.max_req_sz)) { 293 290 dev_dbg(dev, "Invalid request size %u, max %u\n", 294 - rpc->in.len, pdsfc->ident.max_req_sz); 291 + rpc->in.len, le32_to_cpu(pdsfc->ident.max_req_sz)); 295 292 return -EINVAL; 296 293 } 297 294 298 - if (rpc->out.len > pdsfc->ident.max_resp_sz) { 295 + if (rpc->out.len > le32_to_cpu(pdsfc->ident.max_resp_sz)) { 299 296 dev_dbg(dev, "Invalid response size %u, max %u\n", 300 - rpc->out.len, pdsfc->ident.max_resp_sz); 297 + rpc->out.len, le32_to_cpu(pdsfc->ident.max_resp_sz)); 301 298 return -EINVAL; 302 299 } 303 300 304 - for (i = 0; i < pdsfc->endpoints->num_entries; i++) { 301 + num_entries = le32_to_cpu(pdsfc->endpoints->num_entries); 302 + for (i = 0; i < num_entries; i++) { 305 303 if (pdsfc->endpoint_info[i].endpoint == rpc->in.ep) { 306 304 ep_info = &pdsfc->endpoint_info[i]; 307 305 break; ··· 332 326 333 327 /* reject unsupported and/or out of scope commands */ 334 328 op_entry = (struct pds_fwctl_query_data_operation *)ep_info->operations->entries; 335 - for (i = 0; i < ep_info->operations->num_entries; i++) { 336 - if (PDS_FWCTL_RPC_OPCODE_CMP(rpc->in.op, op_entry[i].id)) { 329 + num_entries = le32_to_cpu(ep_info->operations->num_entries); 330 + for (i = 0; i < num_entries; i++) { 331 + if (PDS_FWCTL_RPC_OPCODE_CMP(rpc->in.op, le32_to_cpu(op_entry[i].id))) { 337 332 if (scope < op_entry[i].scope) 338 333 return -EPERM; 339 334 return 0; ··· 409 402 cmd = (union pds_core_adminq_cmd) { 410 403 .fwctl_rpc = { 411 404 .opcode = PDS_FWCTL_CMD_RPC, 412 - .flags = PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP, 405 + .flags = cpu_to_le16(PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP), 413 406 .ep = cpu_to_le32(rpc->in.ep), 414 407 .op = cpu_to_le32(rpc->in.op), 415 408 .req_pa = cpu_to_le64(in_payload_dma_addr),