From nobody Sun Dec 14 12:12:46 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 9CDA93126D8; Fri, 12 Dec 2025 19:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765568304; cv=none; b=ht0RzKRmzOJF5RhBdafrz30JzkJrgx/TuP6xjxz9Lfr5TjW8zd5wdpIZTMdEH6sQtJrxF85Mcftnxr0EAaZt3xjRgZRdy02ieJjpWsMhCH31yIdc8A7kw62YIZ6xEb+UWqsROH2XZkOr7IzaUGZzqxc+2JXZ7eZX3Bu+fumyREU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765568304; c=relaxed/simple; bh=qGRxQF8GFDnNcaSRGguN86dTeYa8fKIIpe8exdR+8yE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s8tSaU9sYziGc2JBBH994lRhUnq2D+0doTF+jg5cRUXxQzmCiKOQNcrPvOEe0cpfao3iSl9Nl4/4PiyGLT4sTjz79BfVVSGy+ebtGOnP4ZvsMUjxGGlvhSMVoH5kEYu8lV2kmq0CczK4WiGrSqpB95Echs4243QFgqbsqUpsrvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=rcVDa5YA; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="rcVDa5YA" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vU8xy-007TcT-UY; Fri, 12 Dec 2025 20:38:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=Gz2PF6SRur9iX1hthbk/yf6ubztCbT5FrnIggMPjKuA=; b=rcVDa5YAtioXHHVFgViVLZVf/H UsgytYd98oJzotmL6Uz1rLYrBDtNcBajZ6A0uKmzGLd6NpSRstQJ+R62nDgaQvkGegAka3G3QCC11 X0oMvTj3XNCvh7LHxM9gCaw4VG6znltNOkSCEL8Osrl/CSMSLXep+vIyNMu5wTYD611YLaBQqE9Y5 SKFTjQMeCLSCd39S9LIx/MxqJuXOCJl0/hHzQ/NZFGosKhJN7blvUmwhCw5VoZM89WTrngWC5uMSE Txbo9nWxITLP9PrisAfEmcWMW8D8kbeXnTHh4zcjEJJ+2FNShrHaW3HuPInJ0hJYPO0Z7iYdkHslp hLdlVHPA==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vU8xy-0006uz-KF; Fri, 12 Dec 2025 20:38:14 +0100 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vU8xf-0030pR-Ru; Fri, 12 Dec 2025 20:37:55 +0100 From: david.laight.linux@gmail.com To: Yury Norov , Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Geert Uytterhoeven , Alexandre Belloni , Jonathan Cameron , Crt Mori , Richard Genoud , Andy Shevchenko , Luo Jie , Peter Zijlstra , Jakub Kicinski , netdev@vger.kernel.org, "David S . Miller" , Mika Westerberg , Andreas Noever , Yehezkel Bernat , Nicolas Frattaroli Cc: David Laight Subject: [PATCH v2 07/16] bitfield: FIELD_MODIFY: Only do a single read/write on the target Date: Fri, 12 Dec 2025 19:37:12 +0000 Message-Id: <20251212193721.740055-8-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251212193721.740055-1-david.laight.linux@gmail.com> References: <20251212193721.740055-1-david.laight.linux@gmail.com> 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 Content-Type: text/plain; charset="utf-8" From: David Laight Replace the: *reg &=3D ~mask; *reg |=3D new_value; with a single assignment. While the compiler will usually optimise the extra access away it isn't guaranteed. Signed-off-by: David Laight --- include/linux/bitfield.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h index f1859e28df5d..c354ca2ef1a0 100644 --- a/include/linux/bitfield.h +++ b/include/linux/bitfield.h @@ -200,8 +200,7 @@ __auto_type _val =3D 1 ? (val) : _mask; \ typecheck_pointer(_reg_p); \ __BF_FIELD_CHECK(_mask, *(_reg_p), _val, "FIELD_MODIFY: "); \ - *(_reg_p) &=3D ~(_mask); \ - *(_reg_p) |=3D (_val << __bf_shf(_mask)) & _mask; \ + *_reg_p =3D (*_reg_p & ~_mask) | ((_val << __bf_shf(_mask)) & _mask); \ }) =20 extern void __compiletime_error("value doesn't fit into mask") --=20 2.39.5