From nobody Sun Oct 5 10:47:11 2025 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 BD25521A428 for ; Wed, 6 Aug 2025 07:42:55 +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=1754466177; cv=none; b=n4fwvozGRR4haaOI5l6PXDz9nee6RoWj4tYeXXVOOZqIUQ95ulDx7QngN0qjDjGnKYCJBbFA3bkCc0iGTI31RbEoFVK8uHUtXRj9Kiqi1bYpm+vVGx82rQozEJDWLPOlvSSrvjd7zMeNngwBRCUUuKEUG4qD9pKTDHC023UD/70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754466177; c=relaxed/simple; bh=278j51yge04XOJmKtiSj3zXumTS//6Z3tuLMY8BE6iM=; h=From:Date:Subject:MIME-Version:Message-Id:In-Reply-To:To:Cc: Content-Type:References; b=gSvgCyz396VzZwKUmVPgFEu8i35egJ2EyLwQuml4Qr9KmJm0dDctAVJndNi2uH+/YnNVzd9EggHdy+spNMETVnMfub1D2BsDPK+AP+c5373fWeSOWox4yYVITycL9HVluHF1UjgJf6rR7FgECnLGoqJcmC0m7PCKUQoBNC7Pz8g= 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=ar8cr/ry; 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="ar8cr/ry" Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20250806074254euoutp02b87895cd29df151c2cb19332988de219~ZHbCg1Ysh1207212072euoutp027 for ; Wed, 6 Aug 2025 07:42:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20250806074254euoutp02b87895cd29df151c2cb19332988de219~ZHbCg1Ysh1207212072euoutp027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1754466174; bh=6iiEvUCRFtFK7DqM8g315/TTGl9FgUVC8GFQ/o9G3Hk=; h=From:Date:Subject:In-Reply-To:To:Cc:References:From; b=ar8cr/ryAdurcdxe7nvbuPeW92CsIbJEqFR4wRrG/Tg57IBvlQ+7DlwEbn7XqOGhR kto4iQVQUXiT4xSYj/yZ1dkH4JBJvR9BtjNxe8XouwYz0E2kv0drq+PzWp76Saqd2X HbCgoJPjI8KZXdJeIwgg3KYVgFf99eV1cGowTgq4= Received: from eusmtip2.samsung.com (unknown [203.254.199.222]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20250806074253eucas1p2d523f76d1e7498c029aaa0869a1b948f~ZHbB3w0m90236602366eucas1p2K; Wed, 6 Aug 2025 07:42:53 +0000 (GMT) Received: from AMDC4942.eu.corp.samsungelectronics.net (unknown [106.210.136.40]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20250806074252eusmtip2f6db0a256d15e7e753d7b354671b343c~ZHbAy6PjR1936819368eusmtip2W; Wed, 6 Aug 2025 07:42:52 +0000 (GMT) From: Michal Wilczynski Date: Wed, 06 Aug 2025 09:42:46 +0200 Subject: [PATCH v13 1/7] pwm: Export `pwmchip_release` for external use Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <20250806-rust-next-pwm-working-fan-for-sending-v13-1-690b669295b6@samsung.com> In-Reply-To: <20250806-rust-next-pwm-working-fan-for-sending-v13-0-690b669295b6@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: 20250806074253eucas1p2d523f76d1e7498c029aaa0869a1b948f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20250806074253eucas1p2d523f76d1e7498c029aaa0869a1b948f X-EPHeader: CA X-CMS-RootMailID: 20250806074253eucas1p2d523f76d1e7498c029aaa0869a1b948f References: <20250806-rust-next-pwm-working-fan-for-sending-v13-0-690b669295b6@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 | 3 ++- include/linux/pwm.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 0d66376a83ec350e0c3718959f4d794efd71595a..a33da3dff608fdff91251e5fd07= b0dbd295be022 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -1600,12 +1600,13 @@ void pwmchip_put(struct pwm_chip *chip) } EXPORT_SYMBOL_GPL(pwmchip_put); =20 -static void pwmchip_release(struct device *pwmchip_dev) +void pwmchip_release(struct device *pwmchip_dev) { struct pwm_chip *chip =3D pwmchip_from_dev(pwmchip_dev); =20 kfree(chip); } +EXPORT_SYMBOL_GPL(pwmchip_release); =20 struct pwm_chip *pwmchip_alloc(struct device *parent, unsigned int npwm, s= ize_t sizeof_priv) { diff --git a/include/linux/pwm.h b/include/linux/pwm.h index 8cafc483db53addf95591d1ac74287532c0fa0ee..d86061024b52172edf3845bf925= 2a966f120e365 100644 --- a/include/linux/pwm.h +++ b/include/linux/pwm.h @@ -485,6 +485,12 @@ int __pwmchip_add(struct pwm_chip *chip, struct module= *owner); #define pwmchip_add(chip) __pwmchip_add(chip, THIS_MODULE) void pwmchip_remove(struct pwm_chip *chip); =20 +/* + * For FFI wrapper use only: + * The Rust PWM abstraction needs this to properly free the pwm_chip. + */ +void pwmchip_release(struct device *dev); + int __devm_pwmchip_add(struct device *dev, struct pwm_chip *chip, struct m= odule *owner); #define devm_pwmchip_add(dev, chip) __devm_pwmchip_add(dev, chip, THIS_MOD= ULE) =20 --=20 2.34.1