Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752945AbcLFKbk (ORCPT ); Tue, 6 Dec 2016 05:31:40 -0500 Received: from smtpoutz29.laposte.net ([194.117.213.104]:34491 "EHLO smtp.laposte.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752078AbcLFKbi (ORCPT ); Tue, 6 Dec 2016 05:31:38 -0500 Subject: Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields To: Geert Uytterhoeven References: <196dd443-e3c7-2c37-1dd1-bc1d249ea2fb@laposte.net> Cc: zijun_hu , Sasha Levin , Andrew Morton , "linux-kernel@vger.kernel.org" , Linus Torvalds , Mason , Maxime Coquelin , Harvey Harrison , Borislav Petkov From: Sebastian Frias Message-ID: <55a33378-e235-08da-251e-fff432be72fb@laposte.net> Date: Tue, 6 Dec 2016 11:31:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-VR-SrcIP: 92.154.11.170 X-VR-FullState: 0 X-VR-Score: -100 X-VR-Cause-1: gggruggvucftvghtrhhoucdtuddrfeelfedrhedtgddthecutefuodetggdotefrodftvfcurfhrohhf X-VR-Cause-2: ihhlvgemucfntefrqffuvffgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhs X-VR-Cause-3: ucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefu X-VR-Cause-4: vggsrghsthhirghnucfhrhhirghsuceoshhfkeegsehlrghpohhsthgvrdhnvghtqeenucfkphepledv X-VR-Cause-5: rdduheegrdduuddrudejtdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopegludej X-VR-Cause-6: vddrvdejrddtrddvudegngdpihhnvghtpeelvddrudehgedruddurddujedtpdhmrghilhhfrhhomhep X-VR-Cause-7: shhfkeegsehlrghpohhsthgvrdhnvghtpdhrtghpthhtohepghgvvghrtheslhhinhhugidqmheikehk X-VR-Cause-8: rdhorhhg X-VR-AvState: No X-VR-State: 0 X-VR-State: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1325 Lines: 41 On 05/12/16 18:48, Geert Uytterhoeven wrote: > On Mon, Dec 5, 2016 at 2:36 PM, Sebastian Frias wrote: >> Introduce SETBITFIELD(msb, lsb, value) macro to ease dealing with >> continuous bitfields, just as BIT(x) does for single bits. > > If it's a bitfield, why not calling it that way? > I don't know if you saw v2 (or v3 for that matter), but the name was changed to GENVALUE. Also a small use case was added to the commit message: "Introduce GENVALUE(msb, lsb, value) macro..." "...This is useful mostly for creating values to be packed together via OR operations, ex: u32 val = 0x11110000; val |= GENVALUE(19, 12, 0x5a); now 'val = 0x1115a000'" > So what about BITFIELD(start ,size), like arch/tile/kernel/tile-desc_32.c has? > >> SETBITFIELD_ULL(msb, lsb, value) macro is also added. > > Confused by the need for a "value" parameter... "value" is the value to be massaged (shifted, masked) into a [msb:lsb] bitfield. > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds >