From nobody Sat Feb 7 13:45:32 2026 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4129C2D249E for ; Fri, 2 Jan 2026 07:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767340331; cv=none; b=n5XLHzA7FzRLc4GtRLiS4XNBbH0bQJ3d7KrCmctTko5geF2m9rpvn62AnedS80WfolqP0QPFpJs/VP8Vy1Nh2LT16Js/GP4fhV42DcUOFy2/ySHDH5n6RvyrQhGtco3YSUdRDPILU4UcCto/lk7EndweGS5Hv5snr4T3WoQZtb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767340331; c=relaxed/simple; bh=PYqFtCJKewiwotOHkWKODCOViU3vbaITARfsgFWgfPk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K++QkZ3LbVGCt1XHmC+sVVoE1qIN4WPH7MTBV+66kKBsPv6z+AwEIJA1r0vw9PBIPFReSIDdLdZKvjzZfCjWYbWfKlAhnjmWE11ghdSxib9MaDYFkx2/tTOKpeylrlBataovVhvvLhKFGLLOFcVdnyj+H+WI5WTSCrfK3LArxPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ETdCK1Mo; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ETdCK1Mo" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-594285c6509so13026372e87.0 for ; Thu, 01 Jan 2026 23:52:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767340327; x=1767945127; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1GrDXAONfhMHnF8PgdBj6M4DUOiVSl4risTQaplS4W0=; b=ETdCK1MoFyeVcTxBTTKYbnMmfcHInxvKFDIbLfRDFMseCeSX9qF3BSoR4dSMgqWCM7 gcAJ3L/7fvHK4syoJBl8ZlhNhvhNOvZlTTpgAGQRA5sTgTqJ3eTAVAksHt9s68ZtINBC onhefNY64mJAbfNFbFkA42XL1+GkYTRYqcplte+PeLMGSauoVRu4HFAWWt+UcyQZAfq5 auibF6ne0A6AGwBS1bwdgD2xoZgDPEdoZtHlq68mKvNVJrXiiTpfPoGJq+gS8SmAMXQc JzAkLChcxF5gm5s1hShnGA/gOywLNrBeC2squIAPc7hgj2wB93tBycJNnVv9ApyL6Cbj mvRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767340327; x=1767945127; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1GrDXAONfhMHnF8PgdBj6M4DUOiVSl4risTQaplS4W0=; b=NOb5gxGMLuccAQD+Ry1mG8SdcfdFrN3rEciXA+C+bOeIKLu8CZlU7ZXsAnW0Jef6Je nbL3j3LupI8MgTiazdP1MsIg7eiuplcWJAaTr8U5oSRfkFja+9Ycf1jzfu3XS4dT7BRq RVaOFU5Myz5uwL9eSVerWuxsUdbfBT53OoxazUGTxfr2/Kke0mledWgwg4RPeWXTrlOI u8syGkIEaeFBh1X6hFIcUwlLAKl6sCO/+EZ4/nQ6c5hDu+/RkbaDWOYK4a8SeT6C2mKJ aGQwmcP7vu8fzgZI77ZpznvwDNZ3xS5Urw4desCsRPktH+7PxpSKGSySggBbXVQyNsfv 19Cw== X-Forwarded-Encrypted: i=1; AJvYcCW6+8LI7u7M7WL0nI1z3GawqyCgIR7QoAGAa4lCJ0tOUrZu6VGy+BIltQ8laeSVwtU5ZHVgZjF1Xet2KT0=@vger.kernel.org X-Gm-Message-State: AOJu0YyULVZl3lwVu5mxuRyWQERdXdYF3uuvm6oVic5vEj3XAuDAD2ua C8rmIJNB+zYQRZXzXLkrG/hG6O6rMbIFaxmoG7YtnE6SlZ0ENQUZ07pa X-Gm-Gg: AY/fxX7QI9Q8SLUjA1bxh1rKSIWIMT+1x1W5CG/BQfliGXNFypRlNR5YzMKcgE04UJT Lu4wVxF/tuU/oveYODwSztxGDhRWd9Ao0JdM0CzjgHVFTzz454L+eM3hYePpM7+z+qBEwbC+K77 tSjcg+md/0jKWYvv18H6wYvruKAFD2XVFV3dSh/IfnpBnUWa2nXQfDdYatVaZumv6/RaQrrUF/q e5XN2fswx3Itu5GqRGPZQf1E83fKes5x1cCvA3RDV5NuzZIoXFpSN8X62RNZhskUYAUSIHShPy4 kd4qQOXuA+c36KapqQYkbV94a/HPd8f/rRsPGioNx4ShWXCS1OWMq8cw8E5iUi+P/N8ICrwGsqa 04jLqxXYQbcAbz/FY3TBui/Wq2HZgb7BldtTRbFocV2wHX3WnrkRD/Tg/YWnJTldKJ1HFUp83hR IbHd2lt8sGQ21JvHJXnhQZDNGJAaCyLPFNo4Dax8Rzg+VcGwz9baxzKyk= X-Google-Smtp-Source: AGHT+IHZBBGt5sKspmgCfNLehnDSWf+0n62iK2Sq8KrVSTfY8+ZnEykfoNZ0znpWjPtd8Ie+jPvN8A== X-Received: by 2002:a05:651c:c8a:b0:378:e097:e16e with SMTP id 38308e7fff4ca-3812167c644mr123565041fa.36.1767340326940; Thu, 01 Jan 2026 23:52:06 -0800 (PST) Received: from LT-5CG5341NQ4.nordic.imtech.com ([83.245.248.13]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-381224de35bsm107688061fa.7.2026.01.01.23.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jan 2026 23:52:05 -0800 (PST) From: Kari Argillander Date: Fri, 02 Jan 2026 09:51:41 +0200 Subject: [PATCH v2 1/2] rust: pwm: Fix potential memory leak on init error Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260102-pwm-rust-v2-1-2702ce57d571@gmail.com> References: <20260102-pwm-rust-v2-0-2702ce57d571@gmail.com> In-Reply-To: <20260102-pwm-rust-v2-0-2702ce57d571@gmail.com> To: Michal Wilczynski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich Cc: linux-pwm@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Kari Argillander X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1767340323; l=1349; i=kari.argillander@gmail.com; s=20251219; h=from:subject:message-id; bh=PYqFtCJKewiwotOHkWKODCOViU3vbaITARfsgFWgfPk=; b=89gkDf+zZZ6JvqrUEtN9svv3pRzZGZqV8d1YP6ws29DFXx5WFdB/t4HAng0JNcH5B2TDaXUmu ki/e0mshDXDCcXPSOYqwQprgpqFr4BYKGEpCkPdJqDen4a9Rbhzk70W X-Developer-Key: i=kari.argillander@gmail.com; a=ed25519; pk=RwSxyhTpE3z4sywdDbIkC3q33ZQLNyhYWxT44iTY6r4= When initializing a PWM chip using pwmchip_alloc(), the allocated device owns an initial reference that must be released on all error paths. If __pinned_init() were to fail, the allocated pwm_chip would currently leak because the error path returns without calling pwmchip_put(). Fixes: 7b3dce814a15 ("rust: pwm: Add Kconfig and basic data structures") Signed-off-by: Kari Argillander Acked-by: Michal Wilczynski --- rust/kernel/pwm.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs index 2dd72a39acb5..4f683158fc08 100644 --- a/rust/kernel/pwm.rs +++ b/rust/kernel/pwm.rs @@ -607,7 +607,11 @@ pub fn new<'a>( let drvdata_ptr =3D unsafe { bindings::pwmchip_get_drvdata(c_chip_= ptr) }; =20 // SAFETY: We construct the `T` object in-place in the allocated p= rivate memory. - unsafe { data.__pinned_init(drvdata_ptr.cast())? }; + unsafe { data.__pinned_init(drvdata_ptr.cast()) }.inspect_err(|_| { + // SAFETY: It is safe to call `pwmchip_put()` with a valid poi= nter obtained + // from `pwmchip_alloc()`. We will not use pointer after this. + unsafe { bindings::pwmchip_put(c_chip_ptr) } + })?; =20 // SAFETY: `c_chip_ptr` points to a valid chip. unsafe { --=20 2.43.0 From nobody Sat Feb 7 13:45:32 2026 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76E112D47F3 for ; Fri, 2 Jan 2026 07:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767340334; cv=none; b=PxBJ0EpOEmaa7Du0F3uV2RqSip7VPJ5Uz8wf5rLHukdjuo04LfV1WVKqzZ/6tr/TFuEtrYiJz3c2J+La4/XjxYQ0fnTELeNpwP0epM8Yzc6WF3350Fo0N4bbonz2wIsr24+1gO1q0iiJu7g9JhLpDF8miSQETDTivj/xHxXGIdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767340334; c=relaxed/simple; bh=2WoOtUgVnGngo1opEuioDWIeyb+NETiI002qJthENXc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B8N816SRz1S9P6NHAofWDU2vmJ3Z4rtaP8MpE8Hvv/IMs/hsdi8/Ja9LKskL1cSl+gpl/J2hszTbLRBAg5WznBX5Xaqyfsmr7DiycfGe+HNxH6mr+Lwcd/i26Hs4gU4RhakDSkX716WCr2n39HG1tsKn6D7x64a52UG5Y5EFRbc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OHlwsphG; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OHlwsphG" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-37ba5af5951so109438881fa.1 for ; Thu, 01 Jan 2026 23:52:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767340330; x=1767945130; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1SwB68mV4E4rv2JZ9xhD6eCQLLJ+hlAXbyX47oNAs8k=; b=OHlwsphGqYV1PxIYdVoCkCynRB7t3WNNELyz2GqjUiLfgv9FQ6T/nyUV3LE14ocmtO u/Y3o8HnnkihsztFmnBrALT0Nj6nz5ueuhXH6lVUKravVcL/bhDe9x7W2vqNCSI2KqBQ D1ksbo5hubTwAWjzrhKAuiZdx0WtoAbk+iMrzcF70E+31nhcDXZbMAFvJ9rzidFDBTZ+ oew6y144NGV2+etWakBc78BXRjxA0LlPATS7otsUUAgyuFt8hHJ01po5pkBZ3DjcTQmA 18uNTF5AYZcB+VYk6fgOAz1MzpsrkEo9dbh9MyU6HL9yyWusAaVkYy9rVN29WyQy3LoF lnZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767340330; x=1767945130; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1SwB68mV4E4rv2JZ9xhD6eCQLLJ+hlAXbyX47oNAs8k=; b=pRBizy1eYOnGE1wtJfMSRA7Y2imte6+OMiFshm1AbNt3XvBXOuehnQVI3UqJgLdY+l XJRhreAk8hIPMRvf6GT+i5Q5/oME4w0e1nhjAZ1A9cL/ChwloclUELGS934oi7zRmjfZ oEfHjaRVhwIlNrLMHSnF2YKEYtYTUjAeNBK13F9K58iX8VcPDwwskcEWg9gBwBiNW/dB ZiRsV6N0LXTcg3ziLQ1HKSRkpUr0XqGkBWrb6LxVEERg/axrQ2UFAO1qVC0tQilL3pPc jSUWd2lNVhcxdWaucOcgsMGi+bk7D4twyaiWZ3nWooi5TqyDnPVTVRMkCcThkV0MAXzO jdbw== X-Forwarded-Encrypted: i=1; AJvYcCVnG2D1nM+gtSXF57/uzX95QL6EXLClXDTQSN9kSjE6Qm51tELCZEyYSXmRWRlzsRQ33Dn9j7anSOGS7bo=@vger.kernel.org X-Gm-Message-State: AOJu0YzZtvP9iNFXVXIqpASJWInk0yAa7+C7ipZubIPS/ow6L+op4RDj ZQQwUWHdkOLD5fete3u3+KdH5TxxShAHOZQP6gxqi7+jE6BuDQYPfbSs X-Gm-Gg: AY/fxX7Zxyd07+JY7VWd+ej8PR2oqfelJ/3PF9DFB9H8rZJmUffS3MyYRgkafEPIh5M Mt82KXxCPOMNJQ/BTgBbuZg7nHJLZX1zCRhDF5U0mULBI8VfSoo1O6pXftfkMA6CrUdJTN/b/nJ D+nw4mjz2iEElB81cfVq6ey0N242zdvTPx+9l2yCzq9WiWpW89p+wqVURpwSEJ5xe3fJcGjZmu8 eHnovtWRP4/jXaZBNBc3Jy9FzhA5hGhiIZUYwmk1p6RbPRHwy346nHqPkUUIKeUnjDajTbhyONP ac/ppMsKjwtHBayf/BtTkoOr1vigGr7qozpskD70woypsPLM3LZmyR4xi+gdUcDlJOEsBlQ7Gfd pwtUpzFf8kvPwfjnvothmRq3HIcKntWX9WCTBwxU0MegI/ZwziPd2vHyUjmObMrO5UbPnMzIhbG EM1O4iE8m13y6S8c4Y/ca5OTPNOt2JY4J/ZuiG1+/r73tO X-Google-Smtp-Source: AGHT+IHVj5/7lah0TGvVE6zyPu1B58rptjPgdldYkgOcVb9OgWJIwYAaYacpr2ejC9qUvEAECjGVeQ== X-Received: by 2002:a2e:ac13:0:b0:37f:cb34:211b with SMTP id 38308e7fff4ca-381215ab664mr112653631fa.18.1767340330304; Thu, 01 Jan 2026 23:52:10 -0800 (PST) Received: from LT-5CG5341NQ4.nordic.imtech.com ([83.245.248.13]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-381224de35bsm107688061fa.7.2026.01.01.23.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jan 2026 23:52:08 -0800 (PST) From: Kari Argillander Date: Fri, 02 Jan 2026 09:51:42 +0200 Subject: [PATCH v2 2/2] rust: pwm: Simplify to_result call sites and unsafe blocks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260102-pwm-rust-v2-2-2702ce57d571@gmail.com> References: <20260102-pwm-rust-v2-0-2702ce57d571@gmail.com> In-Reply-To: <20260102-pwm-rust-v2-0-2702ce57d571@gmail.com> To: Michal Wilczynski , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich Cc: linux-pwm@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Kari Argillander X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1767340323; l=6050; i=kari.argillander@gmail.com; s=20251219; h=from:subject:message-id; bh=2WoOtUgVnGngo1opEuioDWIeyb+NETiI002qJthENXc=; b=LoJkubWyNd2jMjezjwdbWhurEpJkfvtenzsBgKJbTe8DIMR+uSiA5DptNXTjaOJAyJwo1PxMs xWYZn4nKoKNAiVh8RCqCTzJ+4T4f4kRA5jbttOxL7yuEaq68pha+G8Z X-Developer-Key: i=kari.argillander@gmail.com; a=ed25519; pk=RwSxyhTpE3z4sywdDbIkC3q33ZQLNyhYWxT44iTY6r4= Remove unnecessary temporary variables around to_result() calls and move trailing semicolons outside unsafe blocks to improve readability and produce cleaner rustfmt output. No functional change intended. Signed-off-by: Kari Argillander Acked-by: Michal Wilczynski --- rust/kernel/pwm.rs | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs index 4f683158fc08..6c9d667009ef 100644 --- a/rust/kernel/pwm.rs +++ b/rust/kernel/pwm.rs @@ -129,8 +129,7 @@ pub fn set_waveform(&self, wf: &Waveform, exact: bool) = -> Result { // SAFETY: `self.as_raw()` provides a valid `*mut pwm_device` poin= ter. // `&c_wf` is a valid pointer to a `pwm_waveform` struct. The C fu= nction // handles all necessary internal locking. - let ret =3D unsafe { bindings::pwm_set_waveform_might_sleep(self.a= s_raw(), &c_wf, exact) }; - to_result(ret) + to_result(unsafe { bindings::pwm_set_waveform_might_sleep(self.as_= raw(), &c_wf, exact) }) } =20 /// Queries the hardware for the configuration it would apply for a gi= ven @@ -160,9 +159,7 @@ pub fn get_waveform(&self) -> Result { =20 // SAFETY: `self.as_raw()` is a valid pointer. We provide a valid = pointer // to a stack-allocated `pwm_waveform` struct for the kernel to fi= ll. - let ret =3D unsafe { bindings::pwm_get_waveform_might_sleep(self.a= s_raw(), &mut c_wf) }; - - to_result(ret)?; + to_result(unsafe { bindings::pwm_get_waveform_might_sleep(self.as_= raw(), &mut c_wf) })?; =20 Ok(Waveform::from(c_wf)) } @@ -263,8 +260,8 @@ unsafe fn serialize_wfhw(wfhw: &T::WfHw, wfhw_ptr: *mut= c_void) -> Result { core::ptr::from_ref::(wfhw).cast::(), wfhw_ptr.cast::(), size, - ); - } + ) + }; =20 Ok(()) } @@ -284,8 +281,8 @@ unsafe fn deserialize_wfhw(wfhw_ptr: *const c_void) -> = Result { wfhw_ptr.cast::(), core::ptr::from_mut::(&mut wfhw).cast::(), size, - ); - } + ) + }; =20 Ok(wfhw) } @@ -311,9 +308,7 @@ unsafe fn deserialize_wfhw(wfhw_ptr: *const c_void) -> = Result { // Now, call the original release function to free the `pwm_chip` = itself. // SAFETY: `dev` is the valid pointer passed into this callback, w= hich is // the expected argument for `pwmchip_release`. - unsafe { - bindings::pwmchip_release(dev); - } + unsafe { bindings::pwmchip_release(dev) }; } =20 /// # Safety @@ -413,9 +408,7 @@ unsafe fn deserialize_wfhw(wfhw_ptr: *const c_void) -> = Result { match T::round_waveform_fromhw(chip, pwm, &wfhw, &mut rust_wf) { Ok(()) =3D> { // SAFETY: `wf_ptr` is guaranteed valid by the C caller. - unsafe { - *wf_ptr =3D rust_wf.into(); - }; + unsafe { *wf_ptr =3D rust_wf.into() }; 0 } Err(e) =3D> e.to_errno(), @@ -614,16 +607,12 @@ pub fn new<'a>( })?; =20 // SAFETY: `c_chip_ptr` points to a valid chip. - unsafe { - (*c_chip_ptr).dev.release =3D Some(Adapter::::release_callb= ack); - } + unsafe { (*c_chip_ptr).dev.release =3D Some(Adapter::::release_= callback) }; =20 // SAFETY: `c_chip_ptr` points to a valid chip. // The `Adapter`'s `VTABLE` has a 'static lifetime, so the pointer // returned by `as_raw()` is always valid. - unsafe { - (*c_chip_ptr).ops =3D Adapter::::VTABLE.as_raw(); - } + unsafe { (*c_chip_ptr).ops =3D Adapter::::VTABLE.as_raw() }; =20 // Cast the `*mut bindings::pwm_chip` to `*mut Chip`. This is vali= d because // `Chip` is `repr(transparent)` over `Opaque`= , and @@ -645,9 +634,7 @@ unsafe impl AlwaysRefCounted for Chip { fn inc_ref(&self) { // SAFETY: `self.0.get()` points to a valid `pwm_chip` because `se= lf` exists. // The embedded `dev` is valid. `get_device` increments its refcou= nt. - unsafe { - bindings::get_device(&raw mut (*self.0.get()).dev); - } + unsafe { bindings::get_device(&raw mut (*self.0.get()).dev) }; } =20 #[inline] @@ -656,9 +643,7 @@ unsafe fn dec_ref(obj: NonNull>) { =20 // SAFETY: `obj` is a valid pointer to a `Chip` (and thus `binding= s::pwm_chip`) // with a non-zero refcount. `put_device` handles decrement and fi= nal release. - unsafe { - bindings::put_device(&raw mut (*c_chip_ptr).dev); - } + unsafe { bindings::put_device(&raw mut (*c_chip_ptr).dev) }; } } =20 @@ -692,9 +677,7 @@ pub fn register(self) -> Result>> { =20 // SAFETY: `c_chip_ptr` points to a valid chip with its ops initia= lized. // `__pwmchip_add` is the C function to register the chip with the= PWM core. - unsafe { - to_result(bindings::__pwmchip_add(c_chip_ptr, core::ptr::null_= mut()))?; - } + to_result(unsafe { bindings::__pwmchip_add(c_chip_ptr, core::ptr::= null_mut()) })?; =20 let registration =3D Registration { chip: ARef::clone(&self.chip), @@ -730,9 +713,7 @@ fn drop(&mut self) { // SAFETY: `chip_raw` points to a chip that was successfully regis= tered. // `bindings::pwmchip_remove` is the correct C function to unregis= ter it. // This `drop` implementation is called automatically by `devres` = on driver unbind. - unsafe { - bindings::pwmchip_remove(chip_raw); - } + unsafe { bindings::pwmchip_remove(chip_raw) }; } } =20 --=20 2.43.0