Changeset 48bcf49 in mainline for kernel/generic/src/ipc/ipc.c
- Timestamp:
- 2017-09-28T22:08:15Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6636fb19
- Parents:
- dd20cbb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ipc.c
rdd20cbb r48bcf49 154 154 /** Connect a phone to an answerbox. 155 155 * 156 * @param phone Initialized phone structure. 157 * @param box Initialized answerbox structure. 158 * @return True if the phone was connected, false otherwise. 156 * This function must be passed a reference to phone->kobject. 157 * 158 * @param phone Initialized phone structure. 159 * @param box Initialized answerbox structure. 160 * @return True if the phone was connected, false otherwise. 159 161 */ 160 162 bool ipc_phone_connect(phone_t *phone, answerbox_t *box) … … 169 171 phone->state = IPC_PHONE_CONNECTED; 170 172 phone->callee = box; 173 /* Pass phone->kobject reference to box->connected_phones */ 171 174 list_append(&phone->link, &box->connected_phones); 172 175 } … … 174 177 irq_spinlock_unlock(&box->lock, true); 175 178 mutex_unlock(&phone->lock); 179 180 if (!active) { 181 /* We still have phone->kobject's reference; drop it */ 182 kobject_put(phone->kobject); 183 } 176 184 177 185 return active; … … 191 199 phone->state = IPC_PHONE_FREE; 192 200 atomic_set(&phone->active_calls, 0); 201 phone->kobject = NULL; 193 202 } 194 203 … … 456 465 list_remove(&phone->link); 457 466 irq_spinlock_unlock(&box->lock, true); 467 468 /* Drop the answerbox reference */ 469 kobject_put(phone->kobject); 458 470 459 471 call_t *call = ipc_call_alloc(0); … … 658 670 659 671 task_release(phone->caller); 672 673 kobject_put(phone->kobject); 660 674 661 675 /* Must start again */ … … 664 678 665 679 mutex_unlock(&phone->lock); 680 kobject_put(phone->kobject); 666 681 } 667 682 … … 734 749 static bool phone_cap_wait_cb(cap_t *cap, void *arg) 735 750 { 736 phone_t *phone = (phone_t *) cap->kobject;751 phone_t *phone = cap->kobject->phone; 737 752 bool *restart = (bool *) arg; 738 753 … … 790 805 */ 791 806 restart = false; 792 if (caps_apply_to_ type(TASK, CAP_TYPE_PHONE, phone_cap_wait_cb,793 &restart)) {807 if (caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_PHONE, 808 phone_cap_wait_cb, &restart)) { 794 809 /* Got into cleanup */ 795 810 return; … … 810 825 static bool phone_cap_cleanup_cb(cap_t *cap, void *arg) 811 826 { 812 phone_t *phone = (phone_t *) cap->kobject; 813 ipc_phone_hangup(phone); 827 ipc_phone_hangup(cap->kobject->phone); 814 828 return true; 815 829 } … … 840 854 841 855 /* Disconnect all our phones ('ipc_phone_hangup') */ 842 caps_apply_to_type(TASK, CAP_TYPE_PHONE, phone_cap_cleanup_cb, NULL); 856 caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_PHONE, 857 phone_cap_cleanup_cb, NULL); 843 858 844 859 /* Unsubscribe from any event notifications. */ … … 846 861 847 862 /* Disconnect all connected IRQs */ 848 caps_apply_to_type(TASK, CAP_TYPE_IRQ, irq_cap_cleanup_cb, NULL); 863 caps_apply_to_kobject_type(TASK, KOBJECT_TYPE_IRQ, irq_cap_cleanup_cb, 864 NULL); 849 865 850 866 /* Disconnect all phones connected to our regular answerbox */ … … 912 928 static bool print_task_phone_cb(cap_t *cap, void *arg) 913 929 { 914 phone_t *phone = (phone_t *) cap->kobject;930 phone_t *phone = cap->kobject->phone; 915 931 916 932 mutex_lock(&phone->lock); … … 963 979 printf("[phone cap] [calls] [state\n"); 964 980 965 caps_apply_to_type(task, CAP_TYPE_PHONE, print_task_phone_cb, NULL); 981 caps_apply_to_kobject_type(task, KOBJECT_TYPE_PHONE, 982 print_task_phone_cb, NULL); 966 983 967 984 irq_spinlock_lock(&task->lock, true);
Note:
See TracChangeset
for help on using the changeset viewer.