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 X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADDF4ECDE20 for ; Wed, 11 Sep 2019 09:11:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F52B206A1 for ; Wed, 11 Sep 2019 09:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbfIKJLI (ORCPT ); Wed, 11 Sep 2019 05:11:08 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:60895 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbfIKJLI (ORCPT ); Wed, 11 Sep 2019 05:11:08 -0400 Received: from localhost (unknown [148.69.85.38]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 9046124001F; Wed, 11 Sep 2019 09:11:05 +0000 (UTC) Date: Wed, 11 Sep 2019 11:11:01 +0200 From: Alexandre Belloni To: Linus Walleij Cc: Ludovic Desroches , Nicolas Ferre , "open list:GPIO SUBSYSTEM" , Linux ARM , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] pinctrl: at91-pio4: implement .get_multiple and .set_multiple Message-ID: <20190911091101.GC21254@piout.net> References: <20190905141304.22005-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On 11/09/2019 01:27:10+0100, Linus Walleij wrote: > On Thu, Sep 5, 2019 at 3:13 PM Alexandre Belloni > wrote: > > > > Implement .get_multiple and .set_multiple to allow reading or setting > > multiple pins simultaneously. Pins in the same bank will all be switched at > > the same time, improving synchronization and performances. > > > > Signed-off-by: Alexandre Belloni > > Good initiative! > > > + for (bank = 0; bank < atmel_pioctrl->nbanks; bank++) {> + unsigned int word = bank; > > + unsigned int offset = 0; > > + unsigned int reg; > > + > > +#if ATMEL_PIO_NPINS_PER_BANK != BITS_PER_LONG > > Should it not be > rather than != ? > Realistically, the only case that could happen would be ATMEL_PIO_NPINS_PER_BANK == 32 and BITS_PER_LONG ==64. so I would go for ATMEL_PIO_NPINS_PER_BANK < BITS_PER_LONG > > + word = BIT_WORD(bank * ATMEL_PIO_NPINS_PER_BANK); > > + offset = bank * ATMEL_PIO_NPINS_PER_BANK % BITS_PER_LONG; > > +#endif > > This doesn't look good for multiplatform kernels. > I don't think we have multiplatform kernels that run both in 32 and 64 bits. I don't believe ATMEL_PIO_NPINS_PER_BANK will ever change, it has been 32 on all the atmel SoCs since 2001. > We need to get rid of any compiletime constants like this. > > Not your fault I suppose it is already there, but this really need > to be fixed. Any ideas? > I can go for a variable instead of a constant but the fact is that there is currently no 64bit SoC with that IP. I added the compile time check just in case a 64 bit SoC appears with that IP one day. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com 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 X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 766E8ECDE27 for ; Wed, 11 Sep 2019 09:11:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48E4D2168B for ; Wed, 11 Sep 2019 09:11:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="stQe9BpX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48E4D2168B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AvMdLxRPDfrewoj0zXS2Born2hz1DRiuRSXteYtAJzc=; b=stQe9BpX7OAinr Vc+lIHLwo+xmrmbRRB/mvZKYGgyK5rZVu6GZOROa2qjElD+nMFisLS4bxrPmdImdEWkoR9atBKNyo XunkfyNrxkAJj92PwEgzBnkpi/5ZvZgWRCMpmg3XuTpeIHIcauKfeSIHzIgW08mBVw6DSKbff3qE7 x/V2J4xlE6YoeGkMhEG9jRcafZ5abxp5DPx11oah4l20BErhmceKVerNLwIO/vpobG9Dzk2H/q9WL Q1jJVjeV7GoCy8g4fLL56BqPHJYrRHred7GpPlvmxxHwuHLaC8s5TaC8JBOAB4gEjZkVIM6cTxWJa n7DIrSI23UpmReSnA6UA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i7yej-0006S3-St; Wed, 11 Sep 2019 09:11:17 +0000 Received: from relay10.mail.gandi.net ([217.70.178.230]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i7yee-0006RY-VS for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2019 09:11:15 +0000 Received: from localhost (unknown [148.69.85.38]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 9046124001F; Wed, 11 Sep 2019 09:11:05 +0000 (UTC) Date: Wed, 11 Sep 2019 11:11:01 +0200 From: Alexandre Belloni To: Linus Walleij Subject: Re: [PATCH] pinctrl: at91-pio4: implement .get_multiple and .set_multiple Message-ID: <20190911091101.GC21254@piout.net> References: <20190905141304.22005-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190911_021113_166499_38A23F30 X-CRM114-Status: GOOD ( 15.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:GPIO SUBSYSTEM" , Ludovic Desroches , Linux ARM , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 11/09/2019 01:27:10+0100, Linus Walleij wrote: > On Thu, Sep 5, 2019 at 3:13 PM Alexandre Belloni > wrote: > > > > Implement .get_multiple and .set_multiple to allow reading or setting > > multiple pins simultaneously. Pins in the same bank will all be switched at > > the same time, improving synchronization and performances. > > > > Signed-off-by: Alexandre Belloni > > Good initiative! > > > + for (bank = 0; bank < atmel_pioctrl->nbanks; bank++) {> + unsigned int word = bank; > > + unsigned int offset = 0; > > + unsigned int reg; > > + > > +#if ATMEL_PIO_NPINS_PER_BANK != BITS_PER_LONG > > Should it not be > rather than != ? > Realistically, the only case that could happen would be ATMEL_PIO_NPINS_PER_BANK == 32 and BITS_PER_LONG ==64. so I would go for ATMEL_PIO_NPINS_PER_BANK < BITS_PER_LONG > > + word = BIT_WORD(bank * ATMEL_PIO_NPINS_PER_BANK); > > + offset = bank * ATMEL_PIO_NPINS_PER_BANK % BITS_PER_LONG; > > +#endif > > This doesn't look good for multiplatform kernels. > I don't think we have multiplatform kernels that run both in 32 and 64 bits. I don't believe ATMEL_PIO_NPINS_PER_BANK will ever change, it has been 32 on all the atmel SoCs since 2001. > We need to get rid of any compiletime constants like this. > > Not your fault I suppose it is already there, but this really need > to be fixed. Any ideas? > I can go for a variable instead of a constant but the fact is that there is currently no 64bit SoC with that IP. I added the compile time check just in case a 64 bit SoC appears with that IP one day. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel