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 487BCC7EE23 for ; Fri, 24 Feb 2023 22:39:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbjBXWjx (ORCPT ); Fri, 24 Feb 2023 17:39:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbjBXWjv (ORCPT ); Fri, 24 Feb 2023 17:39:51 -0500 Received: from fgw21-7.mail.saunalahti.fi (fgw21-7.mail.saunalahti.fi [62.142.5.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32DB219685 for ; Fri, 24 Feb 2023 14:39:49 -0800 (PST) Received: from localhost (88-113-24-128.elisa-laajakaista.fi [88.113.24.128]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id 2319e286-b494-11ed-a2f4-005056bdd08f; Sat, 25 Feb 2023 00:39:45 +0200 (EET) From: andy.shevchenko@gmail.com Date: Sat, 25 Feb 2023 00:39:45 +0200 To: Asmaa Mnebhi Cc: Andy Shevchenko , "linus.walleij@linaro.org" , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] gpio: mmio: handle "ngpios" properly in bgpio_init() Message-ID: References: <20230224192021.22591-1-asmaa@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fri, Feb 24, 2023 at 09:31:23PM +0000, Asmaa Mnebhi kirjoitti: ... > > The problem with this change is that you need to provide bgpio_bits. > > > > So, if there is a property when bgpio_bits will be updated? > > > > That's said what you need is something like this: > > 1) split "ngpios" handling code (lines ~718-744 in gpiolib.c) into a helper > > function that is available inside drivers/gpio; > > 2) use it in bgpio_init() by overriding bgpio_bits. > > > > ret = new_helper(); > > if (ret) > > gc->bgpio_bits = sz * 8; > > else > > ... = gc->ngpio; > > So this new_helper() which reads the ngpios property, would be called from > bgpio_init() and From gpiochip_add_data_with_key() correct? Since there are > some drivers that don’t use bgpio_init(). Correct. > Also, shouldn't "gc->bgpio_bits = = sz * 8;" be independent of new_helper() Nope. You need to link them anyway. > function? "bgpio_bits" is described as "number of register bits used for a > generic GPIO i.e. * 8" which seems different from "ngpio" > described as "the number of GPIOs handled by this controller" But you are right, this should be = round_up(gc->ngpio, 8); to match the logic with sz. -- With Best Regards, Andy Shevchenko