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

mei: move hbm responses from interrupt.c to hbm.c

1. Add common prefix mei_hbm_ to all handlers
and made them static
2. Drop now useless function same_flow_addr

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
6bbda15f 8120e720

+186 -220
+186 -3
drivers/misc/mei/hbm.c
··· 59 59 60 60 61 61 /** 62 + * is_treat_specially_client - checks if the message belongs 63 + * to the file private data. 64 + * 65 + * @cl: private data of the file object 66 + * @rs: connect response bus message 67 + * 68 + */ 69 + static bool is_treat_specially_client(struct mei_cl *cl, 70 + struct hbm_client_connect_response *rs) 71 + { 72 + if (mei_hbm_cl_addr_equal(cl, rs)) { 73 + if (!rs->status) { 74 + cl->state = MEI_FILE_CONNECTED; 75 + cl->status = 0; 76 + 77 + } else { 78 + cl->state = MEI_FILE_DISCONNECTED; 79 + cl->status = -ENODEV; 80 + } 81 + cl->timer_count = 0; 82 + 83 + return true; 84 + } 85 + return false; 86 + } 87 + 88 + /** 62 89 * mei_hbm_start_req - sends start request message. 63 90 * 64 91 * @dev: the device structure ··· 245 218 } 246 219 247 220 /** 221 + * add_single_flow_creds - adds single buffer credentials. 222 + * 223 + * @file: private data ot the file object. 224 + * @flow: flow control. 225 + */ 226 + static void mei_hbm_add_single_flow_creds(struct mei_device *dev, 227 + struct hbm_flow_control *flow) 228 + { 229 + struct mei_me_client *client; 230 + int i; 231 + 232 + for (i = 0; i < dev->me_clients_num; i++) { 233 + client = &dev->me_clients[i]; 234 + if (client && flow->me_addr == client->client_id) { 235 + if (client->props.single_recv_buf) { 236 + client->mei_flow_ctrl_creds++; 237 + dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n", 238 + flow->me_addr); 239 + dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n", 240 + client->mei_flow_ctrl_creds); 241 + } else { 242 + BUG(); /* error in flow control */ 243 + } 244 + } 245 + } 246 + } 247 + 248 + /** 249 + * mei_hbm_cl_flow_control_res - flow control response from me 250 + * 251 + * @dev: the device structure 252 + * @flow_control: flow control response bus message 253 + */ 254 + static void mei_hbm_cl_flow_control_res(struct mei_device *dev, 255 + struct hbm_flow_control *flow_control) 256 + { 257 + struct mei_cl *cl = NULL; 258 + struct mei_cl *next = NULL; 259 + 260 + if (!flow_control->host_addr) { 261 + /* single receive buffer */ 262 + mei_hbm_add_single_flow_creds(dev, flow_control); 263 + return; 264 + } 265 + 266 + /* normal connection */ 267 + list_for_each_entry_safe(cl, next, &dev->file_list, link) { 268 + if (mei_hbm_cl_addr_equal(cl, flow_control)) { 269 + cl->mei_flow_ctrl_creds++; 270 + dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n", 271 + flow_control->host_addr, flow_control->me_addr); 272 + dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n", 273 + cl->mei_flow_ctrl_creds); 274 + break; 275 + } 276 + } 277 + } 278 + 279 + 280 + /** 248 281 * mei_hbm_cl_disconnect_req - sends disconnect message to fw. 249 282 * 250 283 * @dev: the device structure ··· 321 234 mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, dev->wr_msg.data, len); 322 235 323 236 return mei_write_message(dev, mei_hdr, dev->wr_msg.data); 237 + } 238 + 239 + /** 240 + * mei_hbm_cl_disconnect_res - disconnect response from ME 241 + * 242 + * @dev: the device structure 243 + * @rs: disconnect response bus message 244 + */ 245 + static void mei_hbm_cl_disconnect_res(struct mei_device *dev, 246 + struct hbm_client_connect_response *rs) 247 + { 248 + struct mei_cl *cl; 249 + struct mei_cl_cb *pos = NULL, *next = NULL; 250 + 251 + dev_dbg(&dev->pdev->dev, 252 + "disconnect_response:\n" 253 + "ME Client = %d\n" 254 + "Host Client = %d\n" 255 + "Status = %d\n", 256 + rs->me_addr, 257 + rs->host_addr, 258 + rs->status); 259 + 260 + list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) { 261 + cl = pos->cl; 262 + 263 + if (!cl) { 264 + list_del(&pos->list); 265 + return; 266 + } 267 + 268 + dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n"); 269 + if (mei_hbm_cl_addr_equal(cl, rs)) { 270 + list_del(&pos->list); 271 + if (!rs->status) 272 + cl->state = MEI_FILE_DISCONNECTED; 273 + 274 + cl->status = 0; 275 + cl->timer_count = 0; 276 + break; 277 + } 278 + } 324 279 } 325 280 326 281 /** ··· 383 254 384 255 return mei_write_message(dev, mei_hdr, dev->wr_msg.data); 385 256 } 257 + 258 + /** 259 + * mei_hbm_cl_connect_res - connect resposne from the ME 260 + * 261 + * @dev: the device structure 262 + * @rs: connect response bus message 263 + */ 264 + static void mei_hbm_cl_connect_res(struct mei_device *dev, 265 + struct hbm_client_connect_response *rs) 266 + { 267 + 268 + struct mei_cl *cl; 269 + struct mei_cl_cb *pos = NULL, *next = NULL; 270 + 271 + dev_dbg(&dev->pdev->dev, 272 + "connect_response:\n" 273 + "ME Client = %d\n" 274 + "Host Client = %d\n" 275 + "Status = %d\n", 276 + rs->me_addr, 277 + rs->host_addr, 278 + rs->status); 279 + 280 + /* if WD or iamthif client treat specially */ 281 + 282 + if (is_treat_specially_client(&dev->wd_cl, rs)) { 283 + dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n"); 284 + mei_watchdog_register(dev); 285 + 286 + return; 287 + } 288 + 289 + if (is_treat_specially_client(&dev->iamthif_cl, rs)) { 290 + dev->iamthif_state = MEI_IAMTHIF_IDLE; 291 + return; 292 + } 293 + list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) { 294 + 295 + cl = pos->cl; 296 + if (!cl) { 297 + list_del(&pos->list); 298 + return; 299 + } 300 + if (pos->fop_type == MEI_FOP_IOCTL) { 301 + if (is_treat_specially_client(cl, rs)) { 302 + list_del(&pos->list); 303 + cl->status = 0; 304 + cl->timer_count = 0; 305 + break; 306 + } 307 + } 308 + } 309 + } 310 + 386 311 387 312 /** 388 313 * mei_client_disconnect_request - disconnect request initiated by me ··· 530 347 531 348 case CLIENT_CONNECT_RES_CMD: 532 349 connect_res = (struct hbm_client_connect_response *) mei_msg; 533 - mei_client_connect_response(dev, connect_res); 350 + mei_hbm_cl_connect_res(dev, connect_res); 534 351 dev_dbg(&dev->pdev->dev, "client connect response message received.\n"); 535 352 wake_up(&dev->wait_recvd_msg); 536 353 break; 537 354 538 355 case CLIENT_DISCONNECT_RES_CMD: 539 356 disconnect_res = (struct hbm_client_connect_response *) mei_msg; 540 - mei_client_disconnect_response(dev, disconnect_res); 357 + mei_hbm_cl_disconnect_res(dev, disconnect_res); 541 358 dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n"); 542 359 wake_up(&dev->wait_recvd_msg); 543 360 break; 544 361 545 362 case MEI_FLOW_CONTROL_CMD: 546 363 flow_control = (struct hbm_flow_control *) mei_msg; 547 - mei_client_flow_control_response(dev, flow_control); 364 + mei_hbm_cl_flow_control_res(dev, flow_control); 548 365 dev_dbg(&dev->pdev->dev, "client flow control response message received.\n"); 549 366 break; 550 367
-208
drivers/misc/mei/interrupt.c
··· 173 173 return 0; 174 174 } 175 175 176 - /** 177 - * is_treat_specially_client - checks if the message belongs 178 - * to the file private data. 179 - * 180 - * @cl: private data of the file object 181 - * @rs: connect response bus message 182 - * 183 - */ 184 - static bool is_treat_specially_client(struct mei_cl *cl, 185 - struct hbm_client_connect_response *rs) 186 - { 187 - 188 - if (cl->host_client_id == rs->host_addr && 189 - cl->me_client_id == rs->me_addr) { 190 - if (!rs->status) { 191 - cl->state = MEI_FILE_CONNECTED; 192 - cl->status = 0; 193 - 194 - } else { 195 - cl->state = MEI_FILE_DISCONNECTED; 196 - cl->status = -ENODEV; 197 - } 198 - cl->timer_count = 0; 199 - 200 - return true; 201 - } 202 - return false; 203 - } 204 - 205 - /** 206 - * mei_client_connect_response - connects to response irq routine 207 - * 208 - * @dev: the device structure 209 - * @rs: connect response bus message 210 - */ 211 - void mei_client_connect_response(struct mei_device *dev, 212 - struct hbm_client_connect_response *rs) 213 - { 214 - 215 - struct mei_cl *cl; 216 - struct mei_cl_cb *pos = NULL, *next = NULL; 217 - 218 - dev_dbg(&dev->pdev->dev, 219 - "connect_response:\n" 220 - "ME Client = %d\n" 221 - "Host Client = %d\n" 222 - "Status = %d\n", 223 - rs->me_addr, 224 - rs->host_addr, 225 - rs->status); 226 - 227 - /* if WD or iamthif client treat specially */ 228 - 229 - if (is_treat_specially_client(&(dev->wd_cl), rs)) { 230 - dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n"); 231 - mei_watchdog_register(dev); 232 - 233 - return; 234 - } 235 - 236 - if (is_treat_specially_client(&(dev->iamthif_cl), rs)) { 237 - dev->iamthif_state = MEI_IAMTHIF_IDLE; 238 - return; 239 - } 240 - list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) { 241 - 242 - cl = pos->cl; 243 - if (!cl) { 244 - list_del(&pos->list); 245 - return; 246 - } 247 - if (pos->fop_type == MEI_FOP_IOCTL) { 248 - if (is_treat_specially_client(cl, rs)) { 249 - list_del(&pos->list); 250 - cl->status = 0; 251 - cl->timer_count = 0; 252 - break; 253 - } 254 - } 255 - } 256 - } 257 - 258 - /** 259 - * mei_client_disconnect_response - disconnects from response irq routine 260 - * 261 - * @dev: the device structure 262 - * @rs: disconnect response bus message 263 - */ 264 - void mei_client_disconnect_response(struct mei_device *dev, 265 - struct hbm_client_connect_response *rs) 266 - { 267 - struct mei_cl *cl; 268 - struct mei_cl_cb *pos = NULL, *next = NULL; 269 - 270 - dev_dbg(&dev->pdev->dev, 271 - "disconnect_response:\n" 272 - "ME Client = %d\n" 273 - "Host Client = %d\n" 274 - "Status = %d\n", 275 - rs->me_addr, 276 - rs->host_addr, 277 - rs->status); 278 - 279 - list_for_each_entry_safe(pos, next, &dev->ctrl_rd_list.list, list) { 280 - cl = pos->cl; 281 - 282 - if (!cl) { 283 - list_del(&pos->list); 284 - return; 285 - } 286 - 287 - dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n"); 288 - if (cl->host_client_id == rs->host_addr && 289 - cl->me_client_id == rs->me_addr) { 290 - 291 - list_del(&pos->list); 292 - if (!rs->status) 293 - cl->state = MEI_FILE_DISCONNECTED; 294 - 295 - cl->status = 0; 296 - cl->timer_count = 0; 297 - break; 298 - } 299 - } 300 - } 301 - 302 - /** 303 - * same_flow_addr - tells if they have the same address. 304 - * 305 - * @file: private data of the file object. 306 - * @flow: flow control. 307 - * 308 - * returns !=0, same; 0,not. 309 - */ 310 - static int same_flow_addr(struct mei_cl *cl, struct hbm_flow_control *flow) 311 - { 312 - return (cl->host_client_id == flow->host_addr && 313 - cl->me_client_id == flow->me_addr); 314 - } 315 - 316 - /** 317 - * add_single_flow_creds - adds single buffer credentials. 318 - * 319 - * @file: private data ot the file object. 320 - * @flow: flow control. 321 - */ 322 - static void add_single_flow_creds(struct mei_device *dev, 323 - struct hbm_flow_control *flow) 324 - { 325 - struct mei_me_client *client; 326 - int i; 327 - 328 - for (i = 0; i < dev->me_clients_num; i++) { 329 - client = &dev->me_clients[i]; 330 - if (client && flow->me_addr == client->client_id) { 331 - if (client->props.single_recv_buf) { 332 - client->mei_flow_ctrl_creds++; 333 - dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n", 334 - flow->me_addr); 335 - dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n", 336 - client->mei_flow_ctrl_creds); 337 - } else { 338 - BUG(); /* error in flow control */ 339 - } 340 - } 341 - } 342 - } 343 - 344 - /** 345 - * mei_client_flow_control_response - flow control response irq routine 346 - * 347 - * @dev: the device structure 348 - * @flow_control: flow control response bus message 349 - */ 350 - void mei_client_flow_control_response(struct mei_device *dev, 351 - struct hbm_flow_control *flow_control) 352 - { 353 - struct mei_cl *cl_pos = NULL; 354 - struct mei_cl *cl_next = NULL; 355 - 356 - if (!flow_control->host_addr) { 357 - /* single receive buffer */ 358 - add_single_flow_creds(dev, flow_control); 359 - } else { 360 - /* normal connection */ 361 - list_for_each_entry_safe(cl_pos, cl_next, 362 - &dev->file_list, link) { 363 - dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in file_list\n"); 364 - 365 - dev_dbg(&dev->pdev->dev, "cl of host client %d ME client %d.\n", 366 - cl_pos->host_client_id, 367 - cl_pos->me_client_id); 368 - dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n", 369 - flow_control->host_addr, 370 - flow_control->me_addr); 371 - if (same_flow_addr(cl_pos, flow_control)) { 372 - dev_dbg(&dev->pdev->dev, "recv ctrl msg for host %d ME %d.\n", 373 - flow_control->host_addr, 374 - flow_control->me_addr); 375 - cl_pos->mei_flow_ctrl_creds++; 376 - dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n", 377 - cl_pos->mei_flow_ctrl_creds); 378 - break; 379 - } 380 - } 381 - } 382 - } 383 - 384 176 385 177 /** 386 178 * _mei_hb_read - processes read related operation.
-9
drivers/misc/mei/mei_dev.h
··· 398 398 399 399 int mei_start_read(struct mei_device *dev, struct mei_cl *cl); 400 400 401 - 402 - void mei_client_disconnect_response(struct mei_device *dev, 403 - struct hbm_client_connect_response *rs); 404 - 405 - void mei_client_connect_response(struct mei_device *dev, 406 - struct hbm_client_connect_response *rs); 407 - 408 - void mei_client_flow_control_response(struct mei_device *dev, 409 - struct hbm_flow_control *flow_control); 410 401 /* 411 402 * AMTHIF - AMT Host Interface Functions 412 403 */