Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1707277imm; Mon, 3 Sep 2018 07:27:12 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbl1uqIWbzD6026YAYWbLesjBxX8LJ6akNX4XPf0fHvWZf9swgj+izTjLa5XdIr3sawzxZI X-Received: by 2002:a17:902:a613:: with SMTP id u19-v6mr29192396plq.234.1535984832890; Mon, 03 Sep 2018 07:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535984832; cv=none; d=google.com; s=arc-20160816; b=ucVoiNTieseBn+1yILJMHDB6YcYGI6xPf47fsQ/tvdDWmnbL3u/ZEH7w9cLPO6XGCa NNQGxkBTtsL81o927M4hKHs02xnjhsstr+eBRyGvGTcmh0WN3YoUv1jR/15lNhNj5aUa mtLVY1a1dzNugRtb4im5u7P7/EDgneWDg2qSKonWXbud6n0xQ4+XuWsIgjL2PB1OvVzp I57Mlwdy53PreEZjmKRo6UKuZwDlX6zVZG35/p7cjCsrrl3hoqj/IPqsil/oiHBFsG/w U5m9oeYGdVx4V2g6v0MfwbPfDfKxzBY7l1d/wBUmMB0we/begb+PeWSrkHeEfeDW3aGd at2g== 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:arc-authentication-results; bh=ieJYxPIHnls2eLt2LBMcGhyRCnh9HRaFFFqYzIhSTtA=; b=zQbb25dTarkEnhbuIOwXeIi/Q82XU/4zBXfTnjzutt+dposKnKTe3ebs43anWKuAYJ scMiGfdz+/p9M4kGdO7+Bu82iFPktC8fnO9ErPsEJ9YjZ/aSg+yrhr4C7nE1+2FZZW+b IVYirie6LkdyRjYasl0dTeEFjav9lOC75aAnQTsKuz3Wz2AgG2xRWL+52dbPLfykVWDy pgXojVrCxYFpfAt+42h+9VqNQ6UPNiRq3uuoPNiNrSJNwbvXXW3PZOLksBKKy5x0pLLy z8J5Edinrrz6yhWeJprL0ZxPobIDi+yAPUWYyxu5GDos4EtpxXnYTWIY9RpTxARZ/VzZ 588A== ARC-Authentication-Results: i=1; mx.google.com; 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 p126-v6si4118708pgp.685.2018.09.03.07.26.57; Mon, 03 Sep 2018 07:27:12 -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; 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 S1727582AbeICSoy (ORCPT + 99 others); Mon, 3 Sep 2018 14:44:54 -0400 Received: from mail-ua1-f65.google.com ([209.85.222.65]:33586 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbeICSoy (ORCPT ); Mon, 3 Sep 2018 14:44:54 -0400 Received: by mail-ua1-f65.google.com with SMTP id i4-v6so562951uak.0; Mon, 03 Sep 2018 07:24:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ieJYxPIHnls2eLt2LBMcGhyRCnh9HRaFFFqYzIhSTtA=; b=AxXaxI1zazlA0wM2fmhmVJLnZyNdVPd+NqDqeZ4EQ3Z+o3eRZ+ex+Luo53F1unBZwl S/noQHcLLUW+fjakFixVGcGh8r0CsDXEBvP2B7Z95cWDoVX6IuDSjVFXuc6MbcD+EGvS 4WWzKveZKAN8qUX3+hfqK6fO9Q3lnmg2S+pDYvkQ4x6ffi/Ut6CcKOKlz/eSQbis/U3H b5LKFppefROtNklGzi5+1p5UnQQ1PQwGlISr2dicIQGFwoo8iT82Zf6J6JG4Szg3tTJB 3BEHiqa1HAAnt511ZmM7kf5WoVw0YhgBgaEPxHrsmrtvgeQWeJItOtE42ED8SDsHdbVb 9vEw== X-Gm-Message-State: APzg51DBEvuhJdT2DETdn76YjQMRyP21lGZwGXh3IFQTdXX6cPDjbohF XL/79XYca7psy3baIAUr+EjK1jm0ycvu362QrAg= X-Received: by 2002:ab0:72ca:: with SMTP id g10-v6mr15954675uap.33.1535984668854; Mon, 03 Sep 2018 07:24:28 -0700 (PDT) MIME-Version: 1.0 References: <20180831225616.29221-1-jmkrzyszt@gmail.com> <20180902120144.6855-1-jmkrzyszt@gmail.com> <20180902120144.6855-2-jmkrzyszt@gmail.com> <20180903043129.GA17856@bombadil.infradead.org> In-Reply-To: <20180903043129.GA17856@bombadil.infradead.org> From: Geert Uytterhoeven Date: Mon, 3 Sep 2018 16:24:16 +0200 Message-ID: Subject: Re: [PATCH v7 1/4] gpiolib: Pass bitmaps, not integer arrays, to get/set array To: Matthew Wilcox Cc: Janusz Krzysztofik , Linus Walleij , Jonathan Corbet , Miguel Ojeda Sandonis , peter.korsgaard@barco.com, Peter Rosin , Ulf Hansson , Andrew Lunn , Florian Fainelli , "David S. Miller" , Dominik Brodowski , Greg KH , Kishon Vijay Abraham I , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald , Jiri Slaby , Willy Tarreau , "open list:DOCUMENTATION" , Linux I2C , Linux MMC List , netdev , linux-iio@vger.kernel.org, driverdevel , "open list:SERIAL DRIVERS" , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , sebastien.bourdelin@savoirfairelinux.com, Lukas Wunner , Rojhalat Ibrahim , Russell King , ext Tony Lindgren , Yegor Yefremov , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , linuxppc-dev 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 Mon, Sep 3, 2018 at 6:31 AM Matthew Wilcox wrote: > > +++ b/drivers/auxdisplay/hd44780.c > > @@ -62,17 +62,12 @@ static void hd44780_strobe_gpio(struct hd44780 *hd) > > /* write to an LCD panel register in 8 bit GPIO mode */ > > static void hd44780_write_gpio8(struct hd44780 *hd, u8 val, unsigned int rs) > > { > > - int values[10]; /* for DATA[0-7], RS, RW */ > > - unsigned int i, n; > > - > > - for (i = 0; i < 8; i++) > > - values[PIN_DATA0 + i] = !!(val & BIT(i)); > > - values[PIN_CTRL_RS] = rs; > > - n = 9; > > - if (hd->pins[PIN_CTRL_RW]) { > > - values[PIN_CTRL_RW] = 0; > > - n++; > > - } > > + DECLARE_BITMAP(values, 10); /* for DATA[0-7], RS, RW */ > > + unsigned int n; > > + > > + *values = val; > > + __assign_bit(8, values, rs); > > + n = hd->pins[PIN_CTRL_RW] ? 10 : 9; > > Doesn't this assume little endian bitmaps? Has anyone tested this on > big-endian machines? include/linux/bitops.h: static __always_inline void __assign_bit(long nr, volatile unsigned long *addr, bool value) { if (value) __set_bit(nr, addr); else __clear_bit(nr, addr); } include/asm-generic/bitops/non-atomic.h: static inline void __set_bit(int nr, volatile unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); *p |= mask; } include/linux/bits.h: #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) Looks like native endianness to me. 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