From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9355C433EF for ; Tue, 23 Nov 2021 16:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234962AbhKWQfa (ORCPT ); Tue, 23 Nov 2021 11:35:30 -0500 Received: from mail-ua1-f42.google.com ([209.85.222.42]:42617 "EHLO mail-ua1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234281AbhKWQf0 (ORCPT ); Tue, 23 Nov 2021 11:35:26 -0500 Received: by mail-ua1-f42.google.com with SMTP id t13so44868621uad.9; Tue, 23 Nov 2021 08:32:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V9TIRszl8dgvuwgR6nhL0A0nOi/JDggQAeXQjF3xH3Y=; b=VKa3hFWLqY+/OtL0PTiZF4DLCLK07pPe0KVvYhyaCA70YwmGx2rlsI70rE5kr2wyQ+ oIbnrtTqEn3FBcUYgddEGjtdeRfS//0v7fCaRwrQvT2ActbSi2gcXq/hd/LL+0YQFnlv cVq2oMvcUEb2tzi6V8NgsoxiSc4aclMTECIV+gDdZYzNvR/7k0FHiX3aS2EUQjphSsru rdlfwgpkaz9mzI+RNi1uORSHomLA4qn7ShemKnoi8eTbRQjZl+9+psihshJIKXEQq84N bzv+Z8xL+bVZUAMjha+7vlUTt7P/d+POvoiu2VsmPEHqE3sqm+FvGcTojwSuj0BFz0hf Xjsw== X-Gm-Message-State: AOAM5313FUF1F/RX6je30Rlo79WJCEgrxKZ0MwyBJMBNwRLok/0rTEuM 1TBqjYm04K+RU5Wg9G+IlXgFi0/2YwvTYwBM X-Google-Smtp-Source: ABdhPJyszXvo4yp8uEtdldHH020MjHk7hIZxcaJ+iT/idyXQC9pfreWyP51D4YgUbH6wWFmlQL4rfA== X-Received: by 2002:ab0:2508:: with SMTP id j8mr10526408uan.16.1637685137194; Tue, 23 Nov 2021 08:32:17 -0800 (PST) Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com. [209.85.222.43]) by smtp.gmail.com with ESMTPSA id s2sm6600879uap.7.2021.11.23.08.32.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Nov 2021 08:32:16 -0800 (PST) Received: by mail-ua1-f43.google.com with SMTP id t13so44868505uad.9; Tue, 23 Nov 2021 08:32:16 -0800 (PST) X-Received: by 2002:a9f:3e01:: with SMTP id o1mr10338972uai.89.1637685125903; Tue, 23 Nov 2021 08:32:05 -0800 (PST) MIME-Version: 1.0 References: <3a54a6703879d10f08cf0275a2a69297ebd2b1d4.1637592133.git.geert+renesas@glider.be> <01b44b38c087c151171f8d45a2090474c2559306.camel@sipsolutions.net> <12825803045d1cec0df968f72a9ef2724a2548fb.camel@sipsolutions.net> In-Reply-To: <12825803045d1cec0df968f72a9ef2724a2548fb.camel@sipsolutions.net> From: Geert Uytterhoeven Date: Tue, 23 Nov 2021 17:31:54 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 01/17] bitfield: Add non-constant field_{prep,get}() helpers To: Johannes Berg Cc: Tony Lindgren , Russell King , Rajendra Nayak , Paul Walmsley , Michael Turquette , Stephen Boyd , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Tero Kristo , Jonathan Cameron , Lars-Peter Clausen , Lorenzo Bianconi , Benoit Parrot , Mauro Carvalho Chehab , Adrian Hunter , Andrew Jeffery , Ulf Hansson , Joel Stanley , Ping-Ke Shih , Kalle Valo , "David S . Miller" , Jakub Kicinski , Linus Walleij , Liam Girdwood , Mark Brown , Magnus Damm , Eduardo Valentin , Keerthy , "Rafael J . Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Jaroslav Kysela , Takashi Iwai , Linux ARM , "open list:TI ETHERNET SWITCH DRIVER (CPSW)" , Linux Kernel Mailing List , linux-clk , Linux-Renesas , linux-iio@vger.kernel.org, Linux Media Mailing List , Linux MMC List , linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, linux-wireless , netdev , "open list:GPIO SUBSYSTEM" , Linux PM list , ALSA Development Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Johannes, On Tue, Nov 23, 2021 at 5:21 PM Johannes Berg wrote: > On Tue, 2021-11-23 at 09:30 +0100, Geert Uytterhoeven wrote: > > > We have the upper-case (constant) versions, and already > > > {u32,...}_get_bits()/etc. > > > > These don't work for non-const masks. > > Obviously, I know that. Still, just saying. > > I'm actually in the opposite camp to you I guess - I much prefer the > typed versions (u32_get_bits() and friends) over the FIELD_GET() macros > that are more magic. > > Mostly though that's because the typed ones also have le32_/be32_/... > variants, which are tremendously useful, and so I prefer to use them all > across. In fact, I have considered in the past to just remove the upper- > case macros entirely but ... no time I guess. OK, I have to think a bit about this. FTR, initially I didn't like the FIELD_{GET,PREP}() macros neither ;-) > In fact, you have e.g. code in drivers/usb/chipidea/udc.c that does > things like cpu_to_le32(mul << __ffs(...)) - though in those cases it's > actually constant today, so you could already write it as > le32_encode_bits(...). Yeah, there are lots of opportunities for improvement for drivers/usb/chipidea/. I didn't include a conversion patch for that driver, as it led me too deep into the rabbit hole, and I wanted to get something posted rather sooner than later... 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C322DC433EF for ; Wed, 24 Nov 2021 07:12:00 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EDF7A175D; Wed, 24 Nov 2021 08:11:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EDF7A175D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1637737919; bh=6MNdNQ9eKKu8i6TIhz2Gu/lq3dZxYmOh1N/P0irb708=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=E/kOJjYx9sDG/5/zcaDxyo115dX6nuG3Oz+/d1rWEmRB4Hr8C2+UfxZ3kD8CsEOdi gfUH0xDSISGBH4rMOe+KDwZ+uryYTmqO/dxIDnZUWIajiNL23VD9j4eZnhP6vmvPG5 wk+SkHLTToGXfvLK/rncFXOA84+Iyycw/4Kt1BMc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 01D1AF80571; Wed, 24 Nov 2021 08:06:10 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B1F48F80511; Tue, 23 Nov 2021 17:32:27 +0100 (CET) Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 91A92F80507 for ; Tue, 23 Nov 2021 17:32:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 91A92F80507 Received: by mail-oi1-f176.google.com with SMTP id m6so45686399oim.2 for ; Tue, 23 Nov 2021 08:32:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V9TIRszl8dgvuwgR6nhL0A0nOi/JDggQAeXQjF3xH3Y=; b=JolWKgto2uK0gk6jijQxZkqxQqICLqqolbTNYc+x/5w25J1Ky+PcfXniGbXdRigSpN C1ENZ9fhAc442hR6ckTjaB8CYuIvfcl4vWV9Yb5N/S2qvKAmTGkI7+b/Ci5c8pzQOt2F Olmra/CuTTcX06Bt7dbbDwzw3rBrS1d86+49pOvZjfJ8MDg4avTf1uQsI6obfSPj/RzD lzX4bKzV4RfpgEfJOFcB0Y/qiYTuepPplRgX0eHh658hHGqMAcrXFSEfJP7rLKgo52xF 7ydNRdpvwt70FpBiTctJvg+ZmzJFKb5mV894DkiMQTF7tlYrJW192XqkYUX9NBjS8wq0 0mCg== X-Gm-Message-State: AOAM533Rp2YvA+IA4+mK+C55Ba23eXPbwgGW63g1yZT0ld4bqb2jXLEv rHxo45u1mTkSbDMjtmzhDKX1JacEwzgFAed0 X-Google-Smtp-Source: ABdhPJyvVWTA7FJVLeRrt3Hyrysj/cXISWJ4fLWvQhY2g468rsvnkQwdra/DTSSviWosD2V5v+qvSg== X-Received: by 2002:aca:100f:: with SMTP id 15mr3658949oiq.82.1637685137087; Tue, 23 Nov 2021 08:32:17 -0800 (PST) Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com. [209.85.210.42]) by smtp.gmail.com with ESMTPSA id r5sm2635009oiw.20.2021.11.23.08.32.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Nov 2021 08:32:16 -0800 (PST) Received: by mail-ot1-f42.google.com with SMTP id x19-20020a9d7053000000b0055c8b39420bso34619852otj.1 for ; Tue, 23 Nov 2021 08:32:16 -0800 (PST) X-Received: by 2002:a9f:3e01:: with SMTP id o1mr10338972uai.89.1637685125903; Tue, 23 Nov 2021 08:32:05 -0800 (PST) MIME-Version: 1.0 References: <3a54a6703879d10f08cf0275a2a69297ebd2b1d4.1637592133.git.geert+renesas@glider.be> <01b44b38c087c151171f8d45a2090474c2559306.camel@sipsolutions.net> <12825803045d1cec0df968f72a9ef2724a2548fb.camel@sipsolutions.net> In-Reply-To: <12825803045d1cec0df968f72a9ef2724a2548fb.camel@sipsolutions.net> From: Geert Uytterhoeven Date: Tue, 23 Nov 2021 17:31:54 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 01/17] bitfield: Add non-constant field_{prep, get}() helpers To: Johannes Berg Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Wed, 24 Nov 2021 08:05:53 +0100 Cc: Alexandre Belloni , Daniel Lezcano , linux-aspeed@lists.ozlabs.org, Liam Girdwood , Tony Lindgren , linux-wireless , Michael Turquette , Amit Kucheria , Ulf Hansson , Adrian Hunter , linux-clk , Ping-Ke Shih , Lars-Peter Clausen , openbmc@lists.ozlabs.org, "Rafael J . Wysocki" , Magnus Damm , Russell King , linux-iio@vger.kernel.org, Ludovic Desroches , Joel Stanley , Jakub Kicinski , Zhang Rui , Linus Walleij , Linux Media Mailing List , ALSA Development Mailing List , "open list:TI ETHERNET SWITCH DRIVER \(CPSW\)" , Benoit Parrot , "open list:GPIO SUBSYSTEM" , Mark Brown , Lorenzo Bianconi , Takashi Iwai , Mauro Carvalho Chehab , Kalle Valo , Linux ARM , Eduardo Valentin , Paul Walmsley , Rajendra Nayak , Tero Kristo , Andrew Jeffery , Keerthy , Linux PM list , Linux MMC List , Nicolas Ferre , Linux Kernel Mailing List , Linux-Renesas , Stephen Boyd , netdev , "David S . Miller" , Jonathan Cameron X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi Johannes, On Tue, Nov 23, 2021 at 5:21 PM Johannes Berg wrote: > On Tue, 2021-11-23 at 09:30 +0100, Geert Uytterhoeven wrote: > > > We have the upper-case (constant) versions, and already > > > {u32,...}_get_bits()/etc. > > > > These don't work for non-const masks. > > Obviously, I know that. Still, just saying. > > I'm actually in the opposite camp to you I guess - I much prefer the > typed versions (u32_get_bits() and friends) over the FIELD_GET() macros > that are more magic. > > Mostly though that's because the typed ones also have le32_/be32_/... > variants, which are tremendously useful, and so I prefer to use them all > across. In fact, I have considered in the past to just remove the upper- > case macros entirely but ... no time I guess. OK, I have to think a bit about this. FTR, initially I didn't like the FIELD_{GET,PREP}() macros neither ;-) > In fact, you have e.g. code in drivers/usb/chipidea/udc.c that does > things like cpu_to_le32(mul << __ffs(...)) - though in those cases it's > actually constant today, so you could already write it as > le32_encode_bits(...). Yeah, there are lots of opportunities for improvement for drivers/usb/chipidea/. I didn't include a conversion patch for that driver, as it led me too deep into the rabbit hole, and I wanted to get something posted rather sooner than later... 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