rtkit.c (40eaa8c0cbba4a27668c7e01373ccd5b38381e2f) | rtkit.c (b3892860f50920ea46342d32bf51323877365082) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only OR MIT 2/* 3 * Apple RTKit IPC library 4 * Copyright (C) The Asahi Linux Contributors 5 */ 6 7#include "rtkit-internal.h" 8 --- 685 unchanged lines hidden (view full) --- 694 rtk->mbox_chan = 695 mbox_request_channel(&rtk->mbox_cl, rtk->mbox_idx); 696 697 if (IS_ERR(rtk->mbox_chan)) 698 return PTR_ERR(rtk->mbox_chan); 699 return 0; 700} 701 | 1// SPDX-License-Identifier: GPL-2.0-only OR MIT 2/* 3 * Apple RTKit IPC library 4 * Copyright (C) The Asahi Linux Contributors 5 */ 6 7#include "rtkit-internal.h" 8 --- 685 unchanged lines hidden (view full) --- 694 rtk->mbox_chan = 695 mbox_request_channel(&rtk->mbox_cl, rtk->mbox_idx); 696 697 if (IS_ERR(rtk->mbox_chan)) 698 return PTR_ERR(rtk->mbox_chan); 699 return 0; 700} 701 |
702static struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, | 702struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, |
703 const char *mbox_name, int mbox_idx, 704 const struct apple_rtkit_ops *ops) 705{ 706 struct apple_rtkit *rtk; 707 int ret; 708 709 if (!ops) 710 return ERR_PTR(-EINVAL); --- 35 unchanged lines hidden (view full) --- 746 return rtk; 747 748destroy_wq: 749 destroy_workqueue(rtk->wq); 750free_rtk: 751 kfree(rtk); 752 return ERR_PTR(ret); 753} | 703 const char *mbox_name, int mbox_idx, 704 const struct apple_rtkit_ops *ops) 705{ 706 struct apple_rtkit *rtk; 707 int ret; 708 709 if (!ops) 710 return ERR_PTR(-EINVAL); --- 35 unchanged lines hidden (view full) --- 746 return rtk; 747 748destroy_wq: 749 destroy_workqueue(rtk->wq); 750free_rtk: 751 kfree(rtk); 752 return ERR_PTR(ret); 753} |
754EXPORT_SYMBOL_GPL(apple_rtkit_init); |
|
754 755static int apple_rtkit_wait_for_completion(struct completion *c) 756{ 757 long t; 758 759 t = wait_for_completion_interruptible_timeout(c, 760 msecs_to_jiffies(1000)); 761 if (t < 0) --- 180 unchanged lines hidden (view full) --- 942 msg = FIELD_PREP(APPLE_RTKIT_MGMT_PWR_STATE, APPLE_RTKIT_PWR_STATE_ON); 943 apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE, 944 msg); 945 946 return apple_rtkit_boot(rtk); 947} 948EXPORT_SYMBOL_GPL(apple_rtkit_wake); 949 | 755 756static int apple_rtkit_wait_for_completion(struct completion *c) 757{ 758 long t; 759 760 t = wait_for_completion_interruptible_timeout(c, 761 msecs_to_jiffies(1000)); 762 if (t < 0) --- 180 unchanged lines hidden (view full) --- 943 msg = FIELD_PREP(APPLE_RTKIT_MGMT_PWR_STATE, APPLE_RTKIT_PWR_STATE_ON); 944 apple_rtkit_management_send(rtk, APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE, 945 msg); 946 947 return apple_rtkit_boot(rtk); 948} 949EXPORT_SYMBOL_GPL(apple_rtkit_wake); 950 |
950static void apple_rtkit_free(void *data) | 951void apple_rtkit_free(struct apple_rtkit *rtk) |
951{ | 952{ |
952 struct apple_rtkit *rtk = data; 953 | |
954 mbox_free_channel(rtk->mbox_chan); 955 destroy_workqueue(rtk->wq); 956 957 apple_rtkit_free_buffer(rtk, &rtk->ioreport_buffer); 958 apple_rtkit_free_buffer(rtk, &rtk->crashlog_buffer); 959 apple_rtkit_free_buffer(rtk, &rtk->syslog_buffer); 960 961 kfree(rtk->syslog_msg_buffer); 962 kfree(rtk); 963} | 953 mbox_free_channel(rtk->mbox_chan); 954 destroy_workqueue(rtk->wq); 955 956 apple_rtkit_free_buffer(rtk, &rtk->ioreport_buffer); 957 apple_rtkit_free_buffer(rtk, &rtk->crashlog_buffer); 958 apple_rtkit_free_buffer(rtk, &rtk->syslog_buffer); 959 960 kfree(rtk->syslog_msg_buffer); 961 kfree(rtk); 962} |
963EXPORT_SYMBOL_GPL(apple_rtkit_free); |
|
964 | 964 |
965static void apple_rtkit_free_wrapper(void *data) 966{ 967 apple_rtkit_free(data); 968} 969 |
|
965struct apple_rtkit *devm_apple_rtkit_init(struct device *dev, void *cookie, 966 const char *mbox_name, int mbox_idx, 967 const struct apple_rtkit_ops *ops) 968{ 969 struct apple_rtkit *rtk; 970 int ret; 971 972 rtk = apple_rtkit_init(dev, cookie, mbox_name, mbox_idx, ops); 973 if (IS_ERR(rtk)) 974 return rtk; 975 | 970struct apple_rtkit *devm_apple_rtkit_init(struct device *dev, void *cookie, 971 const char *mbox_name, int mbox_idx, 972 const struct apple_rtkit_ops *ops) 973{ 974 struct apple_rtkit *rtk; 975 int ret; 976 977 rtk = apple_rtkit_init(dev, cookie, mbox_name, mbox_idx, ops); 978 if (IS_ERR(rtk)) 979 return rtk; 980 |
976 ret = devm_add_action_or_reset(dev, apple_rtkit_free, rtk); | 981 ret = devm_add_action_or_reset(dev, apple_rtkit_free_wrapper, rtk); |
977 if (ret) 978 return ERR_PTR(ret); 979 980 return rtk; 981} 982EXPORT_SYMBOL_GPL(devm_apple_rtkit_init); 983 984MODULE_LICENSE("Dual MIT/GPL"); 985MODULE_AUTHOR("Sven Peter <sven@svenpeter.dev>"); 986MODULE_DESCRIPTION("Apple RTKit driver"); | 982 if (ret) 983 return ERR_PTR(ret); 984 985 return rtk; 986} 987EXPORT_SYMBOL_GPL(devm_apple_rtkit_init); 988 989MODULE_LICENSE("Dual MIT/GPL"); 990MODULE_AUTHOR("Sven Peter <sven@svenpeter.dev>"); 991MODULE_DESCRIPTION("Apple RTKit driver"); |