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

soc: apple: rtkit: Export non-devm init/free functions

While we normally encourage devm usage by drivers, some consumers (and
in particular the upcoming Rust abstractions) might want to manually
manage memory. Export the raw functions to make this possible.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Reviewed-by: Eric Curtin <ecurtin@redhat.com>
Signed-off-by: Hector Martin <marcan@marcan.st>

authored by

Asahi Lina and committed by
Hector Martin
b3892860 4435d63f

+29 -5
+10 -5
drivers/soc/apple/rtkit.c
··· 699 699 return 0; 700 700 } 701 701 702 - static struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, 702 + struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, 703 703 const char *mbox_name, int mbox_idx, 704 704 const struct apple_rtkit_ops *ops) 705 705 { ··· 751 751 kfree(rtk); 752 752 return ERR_PTR(ret); 753 753 } 754 + EXPORT_SYMBOL_GPL(apple_rtkit_init); 754 755 755 756 static int apple_rtkit_wait_for_completion(struct completion *c) 756 757 { ··· 948 947 } 949 948 EXPORT_SYMBOL_GPL(apple_rtkit_wake); 950 949 951 - static void apple_rtkit_free(void *data) 950 + void apple_rtkit_free(struct apple_rtkit *rtk) 952 951 { 953 - struct apple_rtkit *rtk = data; 954 - 955 952 mbox_free_channel(rtk->mbox_chan); 956 953 destroy_workqueue(rtk->wq); 957 954 ··· 959 960 960 961 kfree(rtk->syslog_msg_buffer); 961 962 kfree(rtk); 963 + } 964 + EXPORT_SYMBOL_GPL(apple_rtkit_free); 965 + 966 + static void apple_rtkit_free_wrapper(void *data) 967 + { 968 + apple_rtkit_free(data); 962 969 } 963 970 964 971 struct apple_rtkit *devm_apple_rtkit_init(struct device *dev, void *cookie, ··· 978 973 if (IS_ERR(rtk)) 979 974 return rtk; 980 975 981 - ret = devm_add_action_or_reset(dev, apple_rtkit_free, rtk); 976 + ret = devm_add_action_or_reset(dev, apple_rtkit_free_wrapper, rtk); 982 977 if (ret) 983 978 return ERR_PTR(ret); 984 979
+19
include/linux/soc/apple/rtkit.h
··· 80 80 const struct apple_rtkit_ops *ops); 81 81 82 82 /* 83 + * Non-devm version of devm_apple_rtkit_init. Must be freed with 84 + * apple_rtkit_free. 85 + * 86 + * @dev: Pointer to the device node this coprocessor is assocated with 87 + * @cookie: opaque cookie passed to all functions defined in rtkit_ops 88 + * @mbox_name: mailbox name used to communicate with the co-processor 89 + * @mbox_idx: mailbox index to be used if mbox_name is NULL 90 + * @ops: pointer to rtkit_ops to be used for this co-processor 91 + */ 92 + struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, 93 + const char *mbox_name, int mbox_idx, 94 + const struct apple_rtkit_ops *ops); 95 + 96 + /* 97 + * Free an instance of apple_rtkit. 98 + */ 99 + void apple_rtkit_free(struct apple_rtkit *rtk); 100 + 101 + /* 83 102 * Reinitialize internal structures. Must only be called with the co-processor 84 103 * is held in reset. 85 104 */