Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3795163rwb; Sat, 21 Jan 2023 00:07:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXui/YU1svHRsAZqMlVFCuVwFykcd3Rxjv6ySLLwJitb2FTII4Wr6IDfavqdrNWpUsVAzcF/ X-Received: by 2002:a05:6402:360d:b0:46c:2c94:d30b with SMTP id el13-20020a056402360d00b0046c2c94d30bmr20948887edb.33.1674288463608; Sat, 21 Jan 2023 00:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674288463; cv=none; d=google.com; s=arc-20160816; b=EG3GBIsidtYxtyTr8fZdtdre2inAQSBpBBkh0hzmlxZW9INOl0dB64KDa++BiX1XXx 6ApBKsvEpAU9Nvvp4l6chEaodoiRc9M48zugkL5yLNu0twV6hFSdDN+iwIDsXS47Kbm5 tAHyJhL4+ELKpNJ5mtNep6v9XX2PkBpt7fSlMtdlHDvUwOrlwibQLuOg3Sih9g7Y9y9w 1DPGhaoq3xyOH4uF3hFxYoDct9Sw/OtaUqtBLqw1W4Vo6eiWLD2AtC192CDTOENwsluU tngAZiaQntKakO2Kxs3KlfsuBabkP7r8V1wArLK5XT0KW6ZC/Fa6GQKoDvkEzUpH7ngZ ddng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=M+EdYdHifrTvGeyt7bs1858YNsQ+jUCsi6LqON9QRkA=; b=NF9Fvn0GiHvgnrK3Phoytne3xa+rfnu4zHE9XctuCGDnSNRXYvTYUb0KQUWol6Y7Z9 PBWuC59Sjo/PQIZatnh3+52rorifaj3lIoMo0OZ4SQcXDFhUKam7q725RuJv74C6yUy2 I/TohnMtKjiswIculzruASc9EViGqA+SWLFFxtFR1L3ZjGB1Hn3Cgu1wqsLS0jJqnjq1 /Y2jayAoaj6eOhNeMv2Zs6eZOBAD8CPCWoyWN8W+jlmu2ZiP8WLTSbT/2gAzmuQ3/9kJ NSKaBay+7cUvgQl4Jvpe76eVGHK4qbuXY0fLbvmHfAKV+qjpWOILWvcdJ021mh/IXALe tAmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=tOJqR1AC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c89-20020a509fe2000000b0046b3055748csi30233697edf.75.2023.01.21.00.07.30; Sat, 21 Jan 2023 00:07:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=tOJqR1AC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbjAUHmK (ORCPT + 50 others); Sat, 21 Jan 2023 02:42:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjAUHmJ (ORCPT ); Sat, 21 Jan 2023 02:42:09 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34EAE6E0FF for ; Fri, 20 Jan 2023 23:42:08 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: linasend@asahilina.net) by mail.marcansoft.com (Postfix) with ESMTPSA id B129841EF0; Sat, 21 Jan 2023 07:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1674286926; bh=aAAVm6ArULz2Uf8upWSlauZ9L+95sXBTHjoML9CoM6g=; h=From:To:Cc:Subject:Date; b=tOJqR1ACgXep0gtiM+Gfnl6LNMnZ/bUrUH9S2cbqnrFEiYjU5hy2E1v1TJPOpobNB 5jFGtE0qrq/XG+bhfVF4H/ejwz4sMuxYKWI3CeY2frjzw/tUFDoh+fuNahV5MiGxQS Cgah1hXQIcJ21WLu9lwf3GY3HicuI+l+nDmaVLPiT+O+xKn9XWnhGxhsiBoKMTzbyn IcsMJxbcdndvvPL5h/2houLwRflBKD76bVKvwIcHFp3MNCWkjg90YluNvgCwd/1p60 MC67vHcr8Lh8ZykXjmZSj/pP6ykkFaOCF7gLb/uKk0FsBLWsia8lwTBRWwrosQ8UqJ oNTi/CX8XqjTQ== From: Asahi Lina To: Hector Martin , Sven Peter Cc: Alyssa Rosenzweig , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Asahi Lina Subject: [PATCH] soc: apple: rtkit: Export non-devm init/free functions Date: Sat, 21 Jan 2023 16:41:35 +0900 Message-Id: <20230121074135.8629-1-lina@asahilina.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/soc/apple/rtkit.c | 15 ++++++++++----- include/linux/soc/apple/rtkit.h | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index fa3cda831d2b..bb33f3cd4efd 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -686,7 +686,7 @@ static int apple_rtkit_request_mbox_chan(struct apple_rtkit *rtk) return mbox_start_channel(rtk->mbox_chan); } -static struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, +struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops) { @@ -739,6 +739,7 @@ static struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, kfree(rtk); return ERR_PTR(ret); } +EXPORT_SYMBOL_GPL(apple_rtkit_init); static int apple_rtkit_wait_for_completion(struct completion *c) { @@ -922,10 +923,8 @@ int apple_rtkit_wake(struct apple_rtkit *rtk) } EXPORT_SYMBOL_GPL(apple_rtkit_wake); -static void apple_rtkit_free(void *data) +void apple_rtkit_free(struct apple_rtkit *rtk) { - struct apple_rtkit *rtk = data; - mbox_free_channel(rtk->mbox_chan); destroy_workqueue(rtk->wq); @@ -936,6 +935,12 @@ static void apple_rtkit_free(void *data) kfree(rtk->syslog_msg_buffer); kfree(rtk); } +EXPORT_SYMBOL_GPL(apple_rtkit_free); + +static void apple_rtkit_free_wrapper(void *data) +{ + apple_rtkit_free(data); +} struct apple_rtkit *devm_apple_rtkit_init(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, @@ -948,7 +953,7 @@ struct apple_rtkit *devm_apple_rtkit_init(struct device *dev, void *cookie, if (IS_ERR(rtk)) return rtk; - ret = devm_add_action_or_reset(dev, apple_rtkit_free, rtk); + ret = devm_add_action_or_reset(dev, apple_rtkit_free_wrapper, rtk); if (ret) return ERR_PTR(ret); diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h index 2d837aa7b91f..62bfa37b5adb 100644 --- a/include/linux/soc/apple/rtkit.h +++ b/include/linux/soc/apple/rtkit.h @@ -77,6 +77,25 @@ struct apple_rtkit *devm_apple_rtkit_init(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops); +/* + * Non-devm version of devm_apple_rtkit_init. Must be freed with + * apple_rtkit_free. + * + * @dev: Pointer to the device node this coprocessor is assocated with + * @cookie: opaque cookie passed to all functions defined in rtkit_ops + * @mbox_name: mailbox name used to communicate with the co-processor + * @mbox_idx: mailbox index to be used if mbox_name is NULL + * @ops: pointer to rtkit_ops to be used for this co-processor + */ +struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, + const char *mbox_name, int mbox_idx, + const struct apple_rtkit_ops *ops); + +/* + * Free an instance of apple_rtkit. + */ +void apple_rtkit_free(struct apple_rtkit *rtk); + /* * Reinitialize internal structures. Must only be called with the co-processor * is held in reset. -- 2.35.1