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

mei: use the same bus msg for connect and disconnect request

structs hbm_client_connect_request and hbm_client_disconnect_request
have the same layout so we can drop the later

Add kdoc for the request and response structure so it is clear
they can be used for both purposes

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Tomas Winkler and committed by
Greg Kroah-Hartman
aeba4a06 ff8b2f4e

+34 -27
+16 -6
drivers/misc/mei/hw.h
··· 293 293 struct mei_client_properties client_properties; 294 294 } __packed; 295 295 296 + /** 297 + * struct hbm_client_connect_request - connect/disconnect request 298 + * 299 + * @hbm_cmd - bus message command header 300 + * @me_addr - address of the client in ME 301 + * @host_addr - address of the client in the driver 302 + * @reserved 303 + */ 296 304 struct hbm_client_connect_request { 297 305 u8 hbm_cmd; 298 306 u8 me_addr; ··· 308 300 u8 reserved; 309 301 } __packed; 310 302 303 + /** 304 + * struct hbm_client_connect_response - connect/disconnect response 305 + * 306 + * @hbm_cmd - bus message command header 307 + * @me_addr - address of the client in ME 308 + * @host_addr - address of the client in the driver 309 + * @status - status of the request 310 + */ 311 311 struct hbm_client_connect_response { 312 312 u8 hbm_cmd; 313 313 u8 me_addr; ··· 323 307 u8 status; 324 308 } __packed; 325 309 326 - struct hbm_client_disconnect_request { 327 - u8 hbm_cmd; 328 - u8 me_addr; 329 - u8 host_addr; 330 - u8 reserved[1]; 331 - } __packed; 332 310 333 311 #define MEI_FC_MESSAGE_RESERVED_LENGTH 5 334 312
+10 -12
drivers/misc/mei/interface.c
··· 352 352 int mei_disconnect(struct mei_device *dev, struct mei_cl *cl) 353 353 { 354 354 struct mei_msg_hdr *mei_hdr; 355 - struct hbm_client_disconnect_request *mei_cli_disconnect; 355 + struct hbm_client_connect_request *req; 356 356 357 357 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; 358 358 mei_hdr->host_addr = 0; 359 359 mei_hdr->me_addr = 0; 360 - mei_hdr->length = sizeof(struct hbm_client_disconnect_request); 360 + mei_hdr->length = sizeof(struct hbm_client_connect_request); 361 361 mei_hdr->msg_complete = 1; 362 362 mei_hdr->reserved = 0; 363 363 364 - mei_cli_disconnect = 365 - (struct hbm_client_disconnect_request *) &dev->wr_msg_buf[1]; 366 - memset(mei_cli_disconnect, 0, sizeof(*mei_cli_disconnect)); 367 - mei_cli_disconnect->host_addr = cl->host_client_id; 368 - mei_cli_disconnect->me_addr = cl->me_client_id; 369 - mei_cli_disconnect->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD; 370 - mei_cli_disconnect->reserved[0] = 0; 364 + req = (struct hbm_client_connect_request *)&dev->wr_msg_buf[1]; 365 + memset(req, 0, sizeof(*req)); 366 + req->host_addr = cl->host_client_id; 367 + req->me_addr = cl->me_client_id; 368 + req->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD; 369 + req->reserved = 0; 371 370 372 - return mei_write_message(dev, mei_hdr, 373 - (unsigned char *) mei_cli_disconnect, 374 - sizeof(struct hbm_client_disconnect_request)); 371 + return mei_write_message(dev, mei_hdr, (unsigned char *)req, 372 + sizeof(struct hbm_client_connect_request)); 375 373 } 376 374 377 375 /**
+8 -9
drivers/misc/mei/interrupt.c
··· 174 174 struct mei_cl_cb *cmpl_list) 175 175 { 176 176 if ((*slots * sizeof(u32)) < (sizeof(struct mei_msg_hdr) + 177 - sizeof(struct hbm_client_disconnect_request))) 177 + sizeof(struct hbm_client_connect_request))) 178 178 return -EBADMSG; 179 179 180 - *slots -= mei_data2slots(sizeof(struct hbm_client_disconnect_request)); 180 + *slots -= mei_data2slots(sizeof(struct hbm_client_connect_request)); 181 181 182 182 if (mei_disconnect(dev, cl)) { 183 183 cl->status = 0; ··· 414 414 * returns !=0, same; 0,not. 415 415 */ 416 416 static int same_disconn_addr(struct mei_cl *cl, 417 - struct hbm_client_disconnect_request *disconn) 417 + struct hbm_client_connect_request *req) 418 418 { 419 - return (cl->host_client_id == disconn->host_addr && 420 - cl->me_client_id == disconn->me_addr); 419 + return (cl->host_client_id == req->host_addr && 420 + cl->me_client_id == req->me_addr); 421 421 } 422 422 423 423 /** ··· 427 427 * @disconnect_req: disconnect request bus message. 428 428 */ 429 429 static void mei_client_disconnect_request(struct mei_device *dev, 430 - struct hbm_client_disconnect_request *disconnect_req) 430 + struct hbm_client_connect_request *disconnect_req) 431 431 { 432 432 struct mei_msg_hdr *mei_hdr; 433 433 struct hbm_client_connect_response *disconnect_res; ··· 484 484 struct hbm_host_version_response *version_res; 485 485 struct hbm_client_connect_response *connect_res; 486 486 struct hbm_client_connect_response *disconnect_res; 487 + struct hbm_client_connect_request *disconnect_req; 487 488 struct hbm_flow_control *flow_control; 488 489 struct hbm_props_response *props_res; 489 490 struct hbm_host_enum_response *enum_res; 490 - struct hbm_client_disconnect_request *disconnect_req; 491 491 struct hbm_host_stop_request *host_stop_req; 492 492 int res; 493 493 ··· 653 653 654 654 case CLIENT_DISCONNECT_REQ_CMD: 655 655 /* search for client */ 656 - disconnect_req = 657 - (struct hbm_client_disconnect_request *) mei_msg; 656 + disconnect_req = (struct hbm_client_connect_request *)mei_msg; 658 657 mei_client_disconnect_request(dev, disconnect_req); 659 658 break; 660 659