From patchwork Sat Jan 21 07:41:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asahi Lina X-Patchwork-Id: 46784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp622809wrn; Sat, 21 Jan 2023 00:06:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8Nt29D8bDTm6g5Fjwfg6JxRT6k94ZnS4Wj8su3wOM2tnVNijGFUVeMmUEO891ZpLoxMw/ X-Received: by 2002:a05:6402:3226:b0:498:1ca:80d0 with SMTP id g38-20020a056402322600b0049801ca80d0mr22279924eda.28.1674288401373; Sat, 21 Jan 2023 00:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674288401; cv=none; d=google.com; s=arc-20160816; b=fFTKDgSpJg8PDE3/Y4qsgOK+MVEiXILxuNB4e1/dkmnrjJSk7Y7YdtXyjR3+487kHZ 0Vp+SGhNvHJleSCppx9Cj67WKRJwfUx7TX25LERmnR2sYr96nyGMV4s4l5Ce3zG+jp3J Tx8F7p1gl2mlCt5zLDFEwAKsNEkCJukgdk+ge42n3fclAn+OG/5rUawn6VNlrju9MwX/ /R8lOTC8/RwFWdTXmIaHJ8INFAxXoZag5JnYVLx0K4PlKQJxYX9niKcTgJmAYhgmc017 U5TzKUS4trBGm9MMohQ69mv7pIqN4IZfMZxKZ9rupErO6LoLL2T5TO6vblJ+WPhk/sAb 9QTw== 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 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.06.14; Sat, 21 Jan 2023 00:06:41 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755618634698516429?= X-GMAIL-MSGID: =?utf-8?q?1755618634698516429?= 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 Reviewed-by: Sven Peter Signed-off-by: Eric Curtin Reviewed-by: Eric Curtin --- 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.