From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8541028DB69 for ; Mon, 7 Jul 2025 09:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751881772; cv=none; b=g23uA8fThoHMK9+3m3JyQdSck4Kjpax1bMNuwOFh2C8/bd9RSRvcZY5ggkUX7jqjUtCUF4FqG5m9atnHG48fAp5wMDJfUIgrmZtFWbLToBsTLlU44bmYIH6Wu7QVUROwZbnRmPq5vxkNi+kc92lVu3cJKbqtG2WsqXRtNeEOqCU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751881772; c=relaxed/simple; bh=X2KTQj3sYrBODlaBUh5907GvBSYo7zkOz4ctatRTbww=; h=From:Date:Subject:MIME-Version:Message-Id:In-Reply-To:To:Cc: Content-Type:References; b=A84wpbGiCev962cWRoIuJiXqgf5fm0ctbiLkVTAx5y7aE2flsbSwuLHeD0nqrwfSR6fAr+RMaKcuaQu+fP8o/p49ZV53ybicE8s2ubS3bY72ph/FtPBHfNYZt0jlul156LKaqbGNp9fofYAJFphQvCG78c51G79RNF0r2DvvUPw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=C2/hVxWs; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="C2/hVxWs" Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20250707094928euoutp020e7820ef53c02cce66207f00710d74ef~P7y-Am3U61709817098euoutp02i for ; Mon, 7 Jul 2025 09:49:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20250707094928euoutp020e7820ef53c02cce66207f00710d74ef~P7y-Am3U61709817098euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1751881768; bh=v184H/+hjF+g7LMn8OCQL3GzK+GQt5a9rJlf+wIu6Rs=; h=From:Date:Subject:In-Reply-To:To:Cc:References:From; b=C2/hVxWstxbxgta80C5Ph98Wnyw6+Oxm+ufwF584REQNd5gtjD1vleKcGwgiKTSeu 8BpIUMKmFDtBRIshTnTFGWm9Qk/oA0ud8HewRF5X5nJr37k0XlYmvJz/e8ITw9v33k tlI8ObBlv7E7B6lTBTYN6PK0+QawZVbdx5yIyWt0= Received: from eusmtip1.samsung.com (unknown [203.254.199.221]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20250707094927eucas1p2be0302112d89f0ea39e4eeb21c771234~P7y_UFxDO1730317303eucas1p2t; Mon, 7 Jul 2025 09:49:27 +0000 (GMT) Received: from AMDC4942.eu.corp.samsungelectronics.net (unknown [106.210.136.40]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250707094926eusmtip1f0ccbebd2086190de86602af194461dc~P7y9MVE5l0369203692eusmtip1X; Mon, 7 Jul 2025 09:49:26 +0000 (GMT) From: Michal Wilczynski Date: Mon, 07 Jul 2025 11:48:29 +0200 Subject: [PATCH v10 1/7] pwm: Export `pwmchip_release` for external use Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-Id: <20250707-rust-next-pwm-working-fan-for-sending-v10-1-d0c5cf342004@samsung.com> In-Reply-To: <20250707-rust-next-pwm-working-fan-for-sending-v10-0-d0c5cf342004@samsung.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Michal Wilczynski , Guo Ren , Fu Wei , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Marek Szyprowski , Benno Lossin , Michael Turquette , Drew Fustini , Benno Lossin , Drew Fustini Cc: linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.15-dev X-CMS-MailID: 20250707094927eucas1p2be0302112d89f0ea39e4eeb21c771234 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20250707094927eucas1p2be0302112d89f0ea39e4eeb21c771234 X-EPHeader: CA X-CMS-RootMailID: 20250707094927eucas1p2be0302112d89f0ea39e4eeb21c771234 References: <20250707-rust-next-pwm-working-fan-for-sending-v10-0-d0c5cf342004@samsung.com> The upcoming Rust abstraction layer for the PWM subsystem uses a custom `dev->release` handler to safely manage the lifetime of its driver data. To prevent leaking the memory of the `struct pwm_chip` (allocated by `pwmchip_alloc`), this custom handler must also call the original `pwmchip_release` function to complete the cleanup. Make `pwmchip_release` a global, exported function so that it can be called from the Rust FFI bridge. This involves removing the `static` keyword, adding a prototype to the public header, and exporting the symbol. Signed-off-by: Michal Wilczynski --- drivers/pwm/core.c | 2 +- include/linux/pwm.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index c1e8ab1a0945889d92dada003060b8b109f2a138..1d33438cd2cf0b5ca53dd22786ed5b5a9f5def8d 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -1600,7 +1600,7 @@ void pwmchip_put(struct pwm_chip *chip) } EXPORT_SYMBOL_GPL(pwmchip_put); -static void pwmchip_release(struct device *pwmchip_dev) +void pwmchip_release(struct device *pwmchip_dev) { struct pwm_chip *chip = pwmchip_from_dev(pwmchip_dev); diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 8cafc483db53addf95591d1ac74287532c0fa0ee..8f0698c09e62b893d63fc258da3c34781183056f 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -478,6 +478,7 @@ static inline bool pwm_might_sleep(struct pwm_device *pwm) /* PWM provider APIs */ void pwmchip_put(struct pwm_chip *chip); +void pwmchip_release(struct device *dev); struct pwm_chip *pwmchip_alloc(struct device *parent, unsigned int npwm, size_t sizeof_priv); struct pwm_chip *devm_pwmchip_alloc(struct device *parent, unsigned int npwm, size_t sizeof_priv); @@ -551,6 +552,10 @@ static inline void pwmchip_put(struct pwm_chip *chip) { } +static inline void pwmchip_release(struct device *dev) +{ +} + static inline struct pwm_chip *pwmchip_alloc(struct device *parent, unsigned int npwm, size_t sizeof_priv) -- 2.34.1