diff options
author | Finn Thain <fthain@telegraphics.com.au> | 2017-04-08 19:51:15 -0400 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2017-04-20 03:54:24 -0400 |
commit | af2325024fe2dcbb9722d1b4c253a377076b1eed (patch) | |
tree | 153f44d426f6ff88bc7fa53a6415f8350b12fa41 | |
parent | a9373f40ac3a5aac4b9a199a15331708616e8947 (diff) |
m68k/mac: Clarify IOP message alloc/free confusion
The alloc/free metaphor used for IOP messages is misleading and can
cause mistakes like the pointless msg2 temporary variable. Use a more
meaningful name to help simplify the code.
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
-rw-r--r-- | arch/m68k/mac/iop.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c index 1746cfc758a0..4c1e606e7d03 100644 --- a/arch/m68k/mac/iop.c +++ b/arch/m68k/mac/iop.c | |||
@@ -210,7 +210,7 @@ static int iop_alive(volatile struct mac_iop *iop) | |||
210 | return retval; | 210 | return retval; |
211 | } | 211 | } |
212 | 212 | ||
213 | static struct iop_msg *iop_alloc_msg(void) | 213 | static struct iop_msg *iop_get_unused_msg(void) |
214 | { | 214 | { |
215 | int i; | 215 | int i; |
216 | unsigned long flags; | 216 | unsigned long flags; |
@@ -229,11 +229,6 @@ static struct iop_msg *iop_alloc_msg(void) | |||
229 | return NULL; | 229 | return NULL; |
230 | } | 230 | } |
231 | 231 | ||
232 | static void iop_free_msg(struct iop_msg *msg) | ||
233 | { | ||
234 | msg->status = IOP_MSGSTATUS_UNUSED; | ||
235 | } | ||
236 | |||
237 | /* | 232 | /* |
238 | * This is called by the startup code before anything else. Its purpose | 233 | * This is called by the startup code before anything else. Its purpose |
239 | * is to find and initialize the IOPs early in the boot sequence, so that | 234 | * is to find and initialize the IOPs early in the boot sequence, so that |
@@ -372,7 +367,7 @@ void iop_complete_message(struct iop_msg *msg) | |||
372 | IOP_ADDR_RECV_STATE + chan, IOP_MSG_COMPLETE); | 367 | IOP_ADDR_RECV_STATE + chan, IOP_MSG_COMPLETE); |
373 | iop_interrupt(iop_base[msg->iop_num]); | 368 | iop_interrupt(iop_base[msg->iop_num]); |
374 | 369 | ||
375 | iop_free_msg(msg); | 370 | msg->status = IOP_MSGSTATUS_UNUSED; |
376 | } | 371 | } |
377 | 372 | ||
378 | /* | 373 | /* |
@@ -403,7 +398,7 @@ static void iop_do_send(struct iop_msg *msg) | |||
403 | static void iop_handle_send(uint iop_num, uint chan) | 398 | static void iop_handle_send(uint iop_num, uint chan) |
404 | { | 399 | { |
405 | volatile struct mac_iop *iop = iop_base[iop_num]; | 400 | volatile struct mac_iop *iop = iop_base[iop_num]; |
406 | struct iop_msg *msg,*msg2; | 401 | struct iop_msg *msg; |
407 | int i,offset; | 402 | int i,offset; |
408 | 403 | ||
409 | iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); | 404 | iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); |
@@ -418,10 +413,8 @@ static void iop_handle_send(uint iop_num, uint chan) | |||
418 | msg->reply[i] = iop_readb(iop, offset); | 413 | msg->reply[i] = iop_readb(iop, offset); |
419 | } | 414 | } |
420 | if (msg->handler) (*msg->handler)(msg); | 415 | if (msg->handler) (*msg->handler)(msg); |
421 | msg2 = msg; | 416 | msg->status = IOP_MSGSTATUS_UNUSED; |
422 | msg = msg->next; | 417 | msg = msg->next; |
423 | iop_free_msg(msg2); | ||
424 | |||
425 | iop_send_queue[iop_num][chan] = msg; | 418 | iop_send_queue[iop_num][chan] = msg; |
426 | if (msg) iop_do_send(msg); | 419 | if (msg) iop_do_send(msg); |
427 | } | 420 | } |
@@ -439,7 +432,7 @@ static void iop_handle_recv(uint iop_num, uint chan) | |||
439 | 432 | ||
440 | iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); | 433 | iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); |
441 | 434 | ||
442 | msg = iop_alloc_msg(); | 435 | msg = iop_get_unused_msg(); |
443 | msg->iop_num = iop_num; | 436 | msg->iop_num = iop_num; |
444 | msg->channel = chan; | 437 | msg->channel = chan; |
445 | msg->status = IOP_MSGSTATUS_UNSOL; | 438 | msg->status = IOP_MSGSTATUS_UNSOL; |
@@ -484,7 +477,7 @@ int iop_send_message(uint iop_num, uint chan, void *privdata, | |||
484 | if (chan >= NUM_IOP_CHAN) return -EINVAL; | 477 | if (chan >= NUM_IOP_CHAN) return -EINVAL; |
485 | if (msg_len > IOP_MSG_LEN) return -EINVAL; | 478 | if (msg_len > IOP_MSG_LEN) return -EINVAL; |
486 | 479 | ||
487 | msg = iop_alloc_msg(); | 480 | msg = iop_get_unused_msg(); |
488 | if (!msg) return -ENOMEM; | 481 | if (!msg) return -ENOMEM; |
489 | 482 | ||
490 | msg->next = NULL; | 483 | msg->next = NULL; |