From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 0BE69303A0A for ; Tue, 9 Dec 2025 18:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765306497; cv=none; b=ZwZpm4xbqC9C6f8R+h5kRZMjEKdIFf+T1Nhywbde/fvw7NDeU+uNZPQ6FLEz/KYJRkmwxHDNYPyS5rK0EIekBAE0oqcF/KDoA4rzHu9s0hoPaDi29lMJGuzi09OrsY14Y2oaXjx+0qC6auhPzZMANtx1nRa96pXcGHByY3IVJ2o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765306497; c=relaxed/simple; bh=oxnsSzSSQAu/Bk/v2zSRSRpD8UW0cATc07H6GarnzDA=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FrVO4PhXhCDzvosam8x/xiCZ/N80GzdjXpeUpqFZCuKlhlmrHGiKiTgUjTbhH2SeK4HvOCLEC/jgUh6a+3/f5sw5CQtYJBKyB85E3MHFXSuiJ1eTujw4ovaseGu+VXfGjqVX8Cb6aZmEMbZ6sfxZJkdGo1ZLDxrKOkOpR6zTClw= 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=hgmPErcd; arc=none smtp.client-ip=209.85.128.41 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="hgmPErcd" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-477a1c28778so75546665e9.3 for ; Tue, 09 Dec 2025 10:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765306494; x=1765911294; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=HpdLUaMszOte+9P9trLbr49o0T/8IL0zVkv1y9a6ACQ=; b=hgmPErcdpbOmWNv97DFI6MjvwovMomPavckD2iQ/zkYmw1PxLyXmJNwIWcKt5I0EDk U+5r5ujCHuKSyWjPGyaBIqyP4UmwKS+lUsWnqCCLTwKg5GbDGIkrA16ZidVCfyFlDwCU hPT2D9Ki5Tl88Y0jMGMa3SPDMA7LYl2LbkUT2fOsuwB1psGSHE93Twai/5sDGyyyeBSI TPQxA6fONxJKZjbFxAa53IJsk3n2T4gytPU7mD5H2QKFqRi9ESqMzGwApHiWW0P9uciX N17Av0DtfJjkw7TJ6YyWk/JmhOV8uS7XcLGfr2WhQHXYLXg35yxesgy4BqgXfzIYdr6A 0iKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765306494; x=1765911294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HpdLUaMszOte+9P9trLbr49o0T/8IL0zVkv1y9a6ACQ=; b=GXeUG0P/CLOo4CndgNpAYZWBvRmIpsECEz94MgXlcHm2M0AWhoK6dwvYHGGC+aHLmL wqzdWtG3GGsL2cYvyrDCc/W0Au8PphnAFDoIXKYDOG4eP5wMWei0ODRZ4/sfzjq0163M RZ1Lu3++OhF23eT4Mbv5071hpgUyGUP6bVqEIJ8kXZLKWhDNiVeASw3dHLhjpVWTYVsA JKXygmDCBAr9H+MNKVS8CwvR6HzgSFEuNIMsij3QkEPkX5BeRQRxShT3Dz85zea0d6Sq 6mEBxzQmOKWXmzdiuPDCvEi9x54a5QYfCRKT5czYKR2ogHNdX7A7z+ggiVIb8+luNi/F 8mMA== X-Forwarded-Encrypted: i=1; AJvYcCWMb8WCc8DB21KWT52ZsSwd7sfjoqC1J5XnCkADBM7fszRViwl237izC1MrEqWfDZIVMsb+OB43qQ4EqX8=@vger.kernel.org X-Gm-Message-State: AOJu0YxLy2PX6iC5AkE6HnhxBupX7I6/L4rvluKiqiaRlocR078KnYJ6 eHAMQKe7m59u4hkhcVxMePWBiCfWdDBdROlK/G1wqgeuYefX/dHEq47R X-Gm-Gg: ASbGncuJ+nHblLkQKBmX5L97UhCNu0o7qvLBEAntS8PO1YbjwzuC/TzlgWIO7Vl+O7P 3nN0KL5mY01qNWWZSOdKJ9fu9ppdQXQPHHhw2k4k0D/XAg5QgjABeGXcopbVnpZnj/dib1vb4eJ /yyu/ddWoixjg1Q+wIOJ9exE4ivgORPnowDCvRHL40kZd6/IpeSF9zKxR0kWalp2pO13ttVWw+n O1hkwgYyajBf1W0R9sj7wgsM0ZCDgFcsAOLvJupG/X+4oEKXBjOCn9YO9MSjLdc1I/H+1eUxyn5 lLZWqoPI/h/5iEPpXrjqnNSmtQyLBx7bEkSz3Q9JMCIXNr1+EReiqMDu6m01ue7rH1HmKpdcS13 59o9nKWR1jdBq1NmWLIfxteQR+SMxS1SWuf8DBitaBob/3U3ubYNIwy+9JyqdL0yhdf9VEO4A15 tSU76sbGeRUAQsIa7gurqM2yljhO6qFURPhf2geugIMFDid0+xCuXxOXE2K9k4H2k= X-Google-Smtp-Source: AGHT+IFirw91TWSXU8QHpRvuGGX1U+haycOXGSNcwfW+RwtLxsf2h/xkUvj8XnU+zmLfR4fhgmr1+A== X-Received: by 2002:a05:600c:444a:b0:477:6e02:54a5 with SMTP id 5b1f17b1804b1-47939e20a92mr115156485e9.18.1765306494210; Tue, 09 Dec 2025 10:54:54 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42f7d331092sm33581359f8f.30.2025.12.09.10.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 10:54:53 -0800 (PST) Date: Tue, 9 Dec 2025 18:54:52 +0000 From: David Laight To: Andy Shevchenko Cc: Yury Norov , Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Geert Uytterhoeven , Alexandre Belloni , Jonathan Cameron , Crt Mori , Richard Genoud , Luo Jie , Peter Zijlstra , Jakub Kicinski , netdev@vger.kernel.org, "David S . Miller" , Simon Horman , Mika Westerberg , Andreas Noever , Yehezkel Bernat , Nicolas Frattaroli Subject: Re: [PATCH 3/9] bitmap: Use FIELD_PREP() in expansion of FIELD_PREP_WM16() Message-ID: <20251209185452.707f4dbe@pumpkin> In-Reply-To: References: <20251209100313.2867-1-david.laight.linux@gmail.com> <20251209100313.2867-4-david.laight.linux@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 9 Dec 2025 17:46:21 +0200 Andy Shevchenko wrote: > On Tue, Dec 09, 2025 at 10:03:07AM +0000, david.laight.linux@gmail.com wrote: > > > 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. > > ... > > > +#define FIELD_PREP_WM16(mask, val) \ > > +({ \ > > + __auto_type _mask = mask; \ > > + u32 _val = FIELD_PREP(_mask, val); \ > > > + BUILD_BUG_ON_MSG(_mask > 0xffffu, \ > > + "FIELD_PREP_WM16: mask too large"); \ > > Can it be static_assert() instead? No, they have to be 'integer constant expressions' not just 'compile time constants'. Pretty useless for anything non-trivial. David > > > + _val | (_mask << 16); \ > > +}) >