Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5153444rwb; Sun, 22 Jan 2023 04:21:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXuN6f3D+tgb2LCWbn4uJi5m5w9LzNhXX3T84gampweqHN5RzmT+LjaFSqt0zSZjAohfZBk+ X-Received: by 2002:a17:907:8b92:b0:877:6a03:9aa4 with SMTP id tb18-20020a1709078b9200b008776a039aa4mr16409843ejc.72.1674390100512; Sun, 22 Jan 2023 04:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674390100; cv=none; d=google.com; s=arc-20160816; b=LgiPhMv9pwuASVrS0dpiLOZH0IANm8WnnWIQL/6I9tJSDfGEKiB+jTDZ63QCrPi1lR 731gzR7TO2VxQ7zr1SQiy/LiR6s+rF2BIeYiD/j/rt1jvA39iloGsrDTuaGoccf3F93s h+mOq6YefDYkKzAO49LpUZjDN5MaGAi5MruzY0eNIq3OuIbcub6pWf9rKjCrkXo+Y1QI DzTXijFr+E4qll428c+vadn89kJjy1JSR53Rytzs7Izp7ylP1jKAHI6PRkxS+gSIVnvk hESCVRLMtjRfVlDQCxlHR54HDBtJMouQOfEqJTvG6lOTQ5CP5qhcw9Nd649MsvGVe3R2 0Lvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=brAkpxNNFoW2Z58ovept6ujrU4B664Hnu1EZEFyhAcY=; b=CYRSevLVJj1Zrfw+4fv872jp44YwKVfWseRGWSBjRevhsHNmU6f1MLrTUFo4zQrwRD lWoOVM3dg9Po2kf8HcJzV2t98UwVwQVZXVKupTaw6H+C2+wpFugawWHK7Thj0z5KJ8es l4a9NSq/U9ITPolAMhYEB1D7WdKkN18nCUZXCu56SFvnyBSFMwLNGrIsI9uP8sq5S/G8 Ab5g7Is4pBC2RlGSwB7k4cgYvAQ2eM0Kns9ZwroMaEbke/+vwfW7Iybub5wGk0W0qaGH jYhxkpcJOKFJ3Qe2ws8gCVjszPnqqCyCMoqHcBLJzvut3X8ILEsz1PaMkTrTR/xFgZgN M2EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Soq2/WbM"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji7-20020a170907980700b0084d33d87c45si49602188ejc.751.2023.01.22.04.21.25; Sun, 22 Jan 2023 04:21:40 -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=@redhat.com header.s=mimecast20190719 header.b="Soq2/WbM"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230026AbjAVMRb (ORCPT + 50 others); Sun, 22 Jan 2023 07:17:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbjAVMRa (ORCPT ); Sun, 22 Jan 2023 07:17:30 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0840D1ABCF for ; Sun, 22 Jan 2023 04:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674389808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=brAkpxNNFoW2Z58ovept6ujrU4B664Hnu1EZEFyhAcY=; b=Soq2/WbMyJZMut+or/OzP/n8PGRkB7azsT5D1wAXiPc9qxGK6q4TxExuRnKRm6CzsDbIrn iR0+iKhi/DVL8XGQVgWYksnuOyTIiWcDtHtXrWTP9Qk1kci4cb9f/ZwmdWpDiLUBI5xH6j JBDC+MnB+ba+GKmpDMHzVF+8o3khWRE= Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-370-8mhxJcJxPmyFO5ZwZYb3Xg-1; Sun, 22 Jan 2023 07:16:44 -0500 X-MC-Unique: 8mhxJcJxPmyFO5ZwZYb3Xg-1 Received: by mail-vk1-f198.google.com with SMTP id i34-20020a0561220c6200b003e20c1ea31bso2334715vkr.8 for ; Sun, 22 Jan 2023 04:16:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=brAkpxNNFoW2Z58ovept6ujrU4B664Hnu1EZEFyhAcY=; b=6QgtmUVGBkgI0SgxyCO/d3JMfYWvjFozVyaZKJnokr8xb3ISpOtVCL/p/8illxSnso VdbYgccFv99RNhPxW63l0JKCD9mki/t8uiAOSvBuBQKzqD/55pJDwdZrjenTTgMJrWAK KjqgucOYg1W+JJ0oyR1UsESA1SpE75MnAQETiz5WcDwrzJbAd1k5CCSjz5aRp3N1g9zS ImjhBsCVL2mBBtf/gxq1+B9uw89EUSkszxuT9iFMm6bCNrUFUtshydhNI+S01Ve1OlFQ n+N7YtD9GoYPA8fLmo7jlJ1nm6+adj5pycpTq4eZRntc6mrpIpEzoA21JpljE4sn35x7 UraQ== X-Gm-Message-State: AFqh2korGoz1rEarAyfWgSGb9LmiDhv1ubCwT1eXKBjI1NE8GgcyHJBP QXhZ47D+4npZXCjWnhmf80XvwZfWU4NpiLZdr5iUR/tITTt15Q7ZZHUW+Ed1GF4U2bIJ0+HetoU h6mYNBMojIFBzARZNWxeXbo3xWZvcQpnzj00jl5up X-Received: by 2002:a67:ea04:0:b0:3d3:ec78:1d72 with SMTP id g4-20020a67ea04000000b003d3ec781d72mr3367181vso.13.1674389803898; Sun, 22 Jan 2023 04:16:43 -0800 (PST) X-Received: by 2002:a67:ea04:0:b0:3d3:ec78:1d72 with SMTP id g4-20020a67ea04000000b003d3ec781d72mr3367179vso.13.1674389803666; Sun, 22 Jan 2023 04:16:43 -0800 (PST) MIME-Version: 1.0 References: <20230121074135.8629-1-lina@asahilina.net> In-Reply-To: <20230121074135.8629-1-lina@asahilina.net> From: Eric Curtin Date: Sun, 22 Jan 2023 12:16:28 +0000 Message-ID: Subject: Re: [PATCH] soc: apple: rtkit: Export non-devm init/free functions To: Asahi Lina Cc: Hector Martin , Sven Peter , Alyssa Rosenzweig , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On Sat, 21 Jan 2023 at 07:48, Asahi Lina wrote: > > 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 > --- Signed-off-by: Eric Curtin Is mise le meas/Regards, 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. > -- > 2.35.1 > >