Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1723549ybp; Wed, 9 Oct 2019 19:30:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeeJwZuBknyu5wMcrtDkmsWxQAkhOQbgljyHagQQNoZmASZe6ketb5TfdZJUjcxlvyMe00 X-Received: by 2002:a17:906:f847:: with SMTP id ks7mr5840678ejb.213.1570674609987; Wed, 09 Oct 2019 19:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570674609; cv=none; d=google.com; s=arc-20160816; b=yG+GrKRD1fK4oMmj/a5+D/HACG/XSNNgqkDMEwNrYkgMENTIagQQaVGdPJfIbuXW28 C4mKQHdxkOKnayUzL565lQq/VkmcQ9AiZZ57CZpoYBQt7uGEmhOnIh5zd+q1pdG3bKaa P4BFBJgEnf3aZ4cM4WfFwdEfgCPNTGam6ANJoS2KCAcdj2i/YVXNISeSyjVPXws3bVlu Pc646yzMFH+DW/qXjL8Les+aeUVFW11TQx5ISFHc+6bJGejbiLJdlbsSDRQC5DafJXLY R1BL1r3Nz+XY9cvkvkrJBVt5hwHbnYbi2Ik9DFrfSXgXruajI75SHNttsTF1T8IgkhEP LfHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=Q7utFN6RzuE8eM4XqhBr6De112exitRV2SZcLvRw+/Y=; b=PrL8Zg/ylyxJqhn/VcUHMqsU1uzuiGgurTMOK/s72gmGcvBFA+oO3z4zdBVDonRbYq xYhcuEkePRWv/VXi4M4FTxhMLlZ4qBSp3m5cgpXUv5ydrx122wH7j5kvw3yunwzALfzh +JyZjkYzGRKg+iGDsEFCUx6Pmmph5XpyiQXGqORRahoz9pQfoe01hn+5JDgB7ZXmPXry oZjvScESFledpXc6EK7BSOZi9viiYUcX5XQlZgL3ag1gXaQwShFZm+Q8LRaJ7VWp3Xor Z2FPS1FR1QeRLyKqWvjfE03N9MtE1DK3uVSeyE3lQMbydrGf/AfuqdUhwMvoUuJvdtPc VDVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=lfR7F1no; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si2590338edz.77.2019.10.09.19.29.46; Wed, 09 Oct 2019 19:30:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=lfR7F1no; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732696AbfJJC3h (ORCPT + 99 others); Wed, 9 Oct 2019 22:29:37 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:47106 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbfJJC3g (ORCPT ); Wed, 9 Oct 2019 22:29:36 -0400 X-Greylist: delayed 35730 seconds by postgrey-1.27 at vger.kernel.org; Wed, 09 Oct 2019 22:29:34 EDT Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) (authenticated) by conssluserg-06.nifty.com with ESMTP id x9A2TQrh010258; Thu, 10 Oct 2019 11:29:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com x9A2TQrh010258 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1570674567; bh=Q7utFN6RzuE8eM4XqhBr6De112exitRV2SZcLvRw+/Y=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lfR7F1noQwk6SX0ADbu5hKqkv67oZZhkBR8M6ERsWbkWf/LBefvJB7MvjzmMX3W0Q 7L83VrJkxM1N+VrTTE4fgeC7YZcwg+yEC6YHciTFMF7TegJxQpPGoMoz8PmTaVxIyr +M8Zy5Fu94jMJYGO9Xv//G91R47IMsjmMAXaGmxZnLQq64JxF9yZfADZo5HMTn1OJp 7V5g5Gy99M56A5Z0VFjxSkNCpDWYaB86VII91VcMNjRcvyhn9NikZboIxHeEYyL/q1 XSK4qnIPuNqb61MSha+vSHUboZB28OxPNNruQmr1ebGCD2Zat3JKE5DWtAFja4OVoa WHnGEk3JR445Q== X-Nifty-SrcIP: [209.85.222.53] Received: by mail-ua1-f53.google.com with SMTP id w7so1446634uag.4; Wed, 09 Oct 2019 19:29:27 -0700 (PDT) X-Gm-Message-State: APjAAAX1QGhuxHrQAYuy+NsIKjkrzCraAou8bec8dD4x0BNrBUl69egu t1bH4nOZSdR/HWbV/lT8XKrusc9cdFYkTHWU5Jg= X-Received: by 2002:a9f:31c5:: with SMTP id w5mr3361388uad.40.1570674566294; Wed, 09 Oct 2019 19:29:26 -0700 (PDT) MIME-Version: 1.0 References: <893c3b4f03266c9496137cc98ac2b1bd27f92c73.1570633189.git.vilhelm.gray@gmail.com> <20191009170917.GG32742@smile.fi.intel.com> In-Reply-To: From: Masahiro Yamada Date: Thu, 10 Oct 2019 11:28:50 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v17 01/14] bitops: Introduce the for_each_set_clump8 macro To: Geert Uytterhoeven , Andy Shevchenko , William Breathitt Gray Cc: Linus Walleij , Bartosz Golaszewski , Andrew Morton , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , linux-arch , Rasmus Villemoes , linux-arm-kernel , Linux PM mailing list , Phil Reid , Lukas Wunner , sean.nyekjaer@prevas.dk, morten.tiljeset@prevas.dk, Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 10, 2019 at 3:54 AM Geert Uytterhoeven wrote: > > Hi Andy, > > On Wed, Oct 9, 2019 at 7:09 PM Andy Shevchenko > wrote: > > On Thu, Oct 10, 2019 at 01:28:08AM +0900, Masahiro Yamada wrote: > > > On Thu, Oct 10, 2019 at 12:27 AM William Breathitt Gray > > > wrote: > > > > > > > > This macro iterates for each 8-bit group of bits (clump) with set bits, > > > > within a bitmap memory region. For each iteration, "start" is set to the > > > > bit offset of the found clump, while the respective clump value is > > > > stored to the location pointed by "clump". Additionally, the > > > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to > > > > respectively get and set an 8-bit value in a bitmap memory region. > > > > > Why is the return type "unsigned long" where you know > > > it return the 8-bit value ? > > > > Because bitmap API operates on unsigned long type. This is not only > > consistency, but for sake of flexibility in case we would like to introduce > > more calls like clump16 or so. > > TBH, that doesn't convince me: those functions explicitly take/return an > 8-bit value, and have "8" in their name. The 8-bit value is never > really related to, retrieved from, or stored in a full "unsigned long" > element of a bitmap, only to/from/in a part (byte) of it. > > Following your rationale, all of iowrite{8,16,32,64}*() should take an > "unsigned long" value, too. > +1 Using u8/u16/u32/u64 looks more consistent with other bitmap helpers. void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits); void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits); static inline void bitmap_from_u64(unsigned long *dst, u64 mask); If you want to see more examples from other parts, int of_property_read_u8(const struct device_node *np, const char *propname, u8 *out_value) int of_property_read_u16(const struct device_node *np, const char *propname, u16 *out_value) -- Best Regards Masahiro Yamada