* Append a description preceded by a ':' to the name of the specified * interrupt handler. */
| 648 | * interrupt handler. |
| 649 | */ |
| 650 | int |
| 651 | intr_event_describe_handler(struct intr_event *ie, void *cookie, |
| 652 | const char *descr) |
| 653 | { |
| 654 | struct intr_handler *ih; |
| 655 | size_t space; |
| 656 | char *start; |
| 657 | |
| 658 | mtx_lock(&ie->ie_lock); |
| 659 | #ifdef INVARIANTS |
| 660 | CK_SLIST_FOREACH(ih, &ie->ie_handlers, ih_next) { |
| 661 | if (ih == cookie) |
| 662 | break; |
| 663 | } |
| 664 | if (ih == NULL) { |
| 665 | mtx_unlock(&ie->ie_lock); |
| 666 | panic("handler %p not found in interrupt event %p", cookie, ie); |
| 667 | } |
| 668 | #endif |
| 669 | ih = cookie; |
| 670 | |
| 671 | /* |
| 672 | * Look for an existing description by checking for an |
| 673 | * existing ":". This assumes device names do not include |
| 674 | * colons. If one is found, prepare to insert the new |
| 675 | * description at that point. If one is not found, find the |
| 676 | * end of the name to use as the insertion point. |
| 677 | */ |
| 678 | start = strchr(ih->ih_name, ':'); |
| 679 | if (start == NULL) |
| 680 | start = strchr(ih->ih_name, 0); |
| 681 | |
| 682 | /* |
| 683 | * See if there is enough remaining room in the string for the |
| 684 | * description + ":". The "- 1" leaves room for the trailing |
| 685 | * '\0'. The "+ 1" accounts for the colon. |
| 686 | */ |
| 687 | space = sizeof(ih->ih_name) - (start - ih->ih_name) - 1; |
| 688 | if (strlen(descr) + 1 > space) { |
| 689 | mtx_unlock(&ie->ie_lock); |
| 690 | return (ENOSPC); |
| 691 | } |
| 692 | |
| 693 | /* Append a colon followed by the description. */ |
| 694 | *start = ':'; |
| 695 | strcpy(start + 1, descr); |
| 696 | intr_event_update(ie); |
| 697 | mtx_unlock(&ie->ie_lock); |
| 698 | return (0); |
| 699 | } |
| 700 | |
| 701 | /* |
| 702 | * Return the ie_source field from the intr_event an intr_handler is |
no test coverage detected