Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753219AbcLFKmq (ORCPT ); Tue, 6 Dec 2016 05:42:46 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:34714 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753188AbcLFKml (ORCPT ); Tue, 6 Dec 2016 05:42:41 -0500 MIME-Version: 1.0 In-Reply-To: <55a33378-e235-08da-251e-fff432be72fb@laposte.net> References: <196dd443-e3c7-2c37-1dd1-bc1d249ea2fb@laposte.net> <55a33378-e235-08da-251e-fff432be72fb@laposte.net> From: Geert Uytterhoeven Date: Tue, 6 Dec 2016 11:42:40 +0100 X-Google-Sender-Auth: _W7c8nXJ8Ds60ssq_Ban_pThjQg Message-ID: Subject: Re: [PATCH] bitops: add equivalent of BIT(x) for bitfields To: Sebastian Frias Cc: zijun_hu , Sasha Levin , Andrew Morton , "linux-kernel@vger.kernel.org" , Linus Torvalds , Mason , Maxime Coquelin , Harvey Harrison , Borislav Petkov Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1712 Lines: 50 On Tue, Dec 6, 2016 at 11:31 AM, Sebastian Frias wrote: > 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. ... which means "generate a value"?? > 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); "val |= 0x5a << 12;" looks much more readable to me... > 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. OK. So it inserts a value into a bitfield. Yes, that can be useful. Now let's find a sensible name for this. Perhaps inspired by a PowerPC mnemonic? At least that would be more obvious than "GENVALUE", IMHO... 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