From nobody Wed Feb 11 18:50:07 2026 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 CC0412FBDE2 for ; Tue, 9 Dec 2025 10:03:34 +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=1765274616; cv=none; b=nGM6RiMpi6GJx5aoZKyxmJ91F1lL53V7zva/X/lImU3AmYV3TUvhUa+y+isBWu5u40FK+hRjmFcw0HWfk1BQXGkvd7o4uQ3tt+iiOYIDlL4DdXnPqjIwsssAUC0YlMtg6hdfUfnXd9WNTOBVnS7eoLAgYz74Mlx5JsOUJWrN/yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765274616; c=relaxed/simple; bh=9GEZ1qcQcq+OU+/HJx1o4UIA998BTTxrtDXBo1mZRD4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gPBpi9xrWd7ecvLrlGVCKQjsrt5sCKV0cR4SWi87IirpsZz49cgRZHeutQMbEknhk9ul1BcUa/C42dWC+e4jvVzrZwEQoTYXRU8xIhOZwYrlswHfZd4Z7oNJb1Z00gHA35l0w5oMsLoSEg1mA12zsMfZc9xH44mVGHGQST+AEB4= 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=mUrpEN13; 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="mUrpEN13" Received: from mailtransmit03.runbox ([10.9.9.163] 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 1vSuZ7-00GyzW-BZ; Tue, 09 Dec 2025 11:03:29 +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=YGnBBG9ZzprxJLEp94vtepq3lcPSfdeE6BD41wIj1gg=; b=mUrpEN13REkNMaUzxXJy60b3ra lR3EJczQGfp6BhxvZmLKXwOJRG4Cjf58rrzBDK1tRGJheVUlF3nI/pVTnGrLV0b5VXs99f1YboTU1 TppUIsxBWefpljsR+brKOkzToAxRqku61ZAY0Y/+z9uQxq/LwIprA+6oNSq0Kp424/KkHow+kLK3h LZ17mF3czhqWsCVWxRMvhaU3Fk6i8SThjEFQTxi/E6+0XStJwrBf/j5rCrUm6hnWJFgIkuHTkTH/Y Ffl1xT6d90VvW3bJuyR/5T4KDHqAxwPsZWx4p1zgCWXdO8N96DB9wPxob5uAylZqs0pucEMj8wlel fmJMdaiQ==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vSuZ5-00074w-Vv; Tue, 09 Dec 2025 11:03:28 +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 1vSuZ3-00CND9-Jl; Tue, 09 Dec 2025 11:03:25 +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" , Simon Horman , Mika Westerberg , Andreas Noever , Yehezkel Bernat , Nicolas Frattaroli Cc: David Laight Subject: [PATCH 3/9] bitmap: Use FIELD_PREP() in expansion of FIELD_PREP_WM16() Date: Tue, 9 Dec 2025 10:03:07 +0000 Message-Id: <20251209100313.2867-4-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251209100313.2867-1-david.laight.linux@gmail.com> References: <20251209100313.2867-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 Instead of directly expanding __BF_FIELD_CHECK() (which really ought not be used outside bitfield) and open-coding the generation of the masked value, just call FIELD_PREP() and add an extra check for the mask being at most 16 bits. Signed-off-by: David Laight --- include/linux/hw_bitfield.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/linux/hw_bitfield.h b/include/linux/hw_bitfield.h index df202e167ce4..d7f21b60449b 100644 --- a/include/linux/hw_bitfield.h +++ b/include/linux/hw_bitfield.h @@ -23,15 +23,14 @@ * register, a bit in the lower half is only updated if the corresponding = bit * in the upper half is high. */ -#define FIELD_PREP_WM16(_mask, _val) \ - ({ \ - typeof(_val) __val =3D _val; \ - typeof(_mask) __mask =3D _mask; \ - __BF_FIELD_CHECK(__mask, ((u16)0U), __val, \ - "HWORD_UPDATE: "); \ - (((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) | \ - ((__mask) << 16); \ - }) +#define FIELD_PREP_WM16(mask, val) \ +({ \ + __auto_type _mask =3D mask; \ + u32 _val =3D FIELD_PREP(_mask, val); \ + BUILD_BUG_ON_MSG(_mask > 0xffffu, \ + "FIELD_PREP_WM16: mask too large"); \ + _val | (_mask << 16); \ +}) =20 /** * FIELD_PREP_WM16_CONST() - prepare a constant bitfield element with a ma= sk in --=20 2.39.5