From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40B611DDC28; Thu, 12 Mar 2026 04:52:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773291178; cv=none; b=ngfk9ZHJuaZf+hrsMHuWDJiiwYsSoiXOkU6hQj6E/ryo0h2Ofr7d1XheEoxVs7F7YPf1q66mTv1wxwwlZXYfm990cizUWWVULs0ArTC3BX/fx01cqKZP4MxgBRqBheKExvxLd7FKy/25/Jm074EK/8yeeGUDJt5DG2OoGBhAQ28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773291178; c=relaxed/simple; bh=SBD/dmp8BPTvxKp8T1wibLDp6tEJo9cqmyfGT+xkaUA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BcQPLMlH5HqK6q4P9vBG0Igqf7lwxm3lbcINAD86pnImr25hfJnWyISdoT3piApwYTXXx+h4LX0glZkkBe4pl26m9MAOd99TR+btVLzzbAiS7sC/lXIkAmqosoYyFMpTvFm0TKsEEfuh2bulchhd1bFcJ0PxjlmFWveWbaezjIg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nxc/IBnY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nxc/IBnY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3ACEC4CEF7; Thu, 12 Mar 2026 04:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773291177; bh=SBD/dmp8BPTvxKp8T1wibLDp6tEJo9cqmyfGT+xkaUA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Nxc/IBnYSqS9cJj76LagMrz4AAvFI+8Rvna64PzDTc+p4ItB2T8PR41+A9P8QGDxk LVHp79ZLrM/iqVQdu39fbJ12Gomz79dN30DTU0bLdbq/U5vNWGPAF7BZoO1IvPuQNU e/18KXBm5HuhTfPq+syLDSqdGC+2hqCEHbAinfrU2525ZM1A5Znwab4/WtM11aBMb9 ckuGyyOiOOci4oTmFbCZFSBf4Huwk6nCGgvjfHTIqvKk80rnrD3rLmcL1eZ4HR1E0z M4Ojkn7xUOEMUJ/cKswsMH7tqt9mSEgAfNeome3npIrAiU/rn0nsEP/Zr4U6+yWiTw 5k4IRF58plDag== Date: Thu, 12 Mar 2026 04:52:54 +0000 From: Tzung-Bi Shih To: Bartosz Golaszewski Cc: Geert Uytterhoeven , Linus Walleij , Shuah Khan , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v4 1/6] gpio: Access `gpio_bus_type` in gpiochip_setup_dev() Message-ID: References: <20260223061726.82161-1-tzungbi@kernel.org> <20260223061726.82161-2-tzungbi@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Mar 11, 2026 at 07:36:51AM -0700, Bartosz Golaszewski wrote: > On Wed, 11 Mar 2026 12:44:31 +0100, Geert Uytterhoeven > said: > > Hi Tzung-Bi, > > > > On Mon, 23 Feb 2026 at 07:17, Tzung-Bi Shih wrote: > >> To make the intent clear, access `gpio_bus_type` only when it's ready in > >> gpiochip_setup_dev(). > >> > >> Reviewed-by: Linus Walleij > >> Signed-off-by: Tzung-Bi Shih > > > > Thanks for your patch, which is now commit cc11f4ef666fbca0 ("gpio: > > Access `gpio_bus_type` in gpiochip_setup_dev()") in gpio/gpio/for-next. > > > >> --- a/drivers/gpio/gpiolib.c > >> +++ b/drivers/gpio/gpiolib.c > >> @@ -901,6 +901,8 @@ static int gpiochip_setup_dev(struct gpio_device *gdev) > >> struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); > >> int ret; > >> > >> + gdev->dev.bus = &gpio_bus_type; > >> + > >> /* > >> * If fwnode doesn't belong to another device, it's safe to clear its > >> * initialized flag. > >> @@ -1082,7 +1084,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, > >> * then make sure they get free():ed there. > >> */ > >> gdev->dev.type = &gpio_dev_type; > >> - gdev->dev.bus = &gpio_bus_type; > >> gdev->dev.parent = gc->parent; > >> device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc)); > >> > > > > Postponing this assignment does have an impact on early > > messages. E.g. on RBTX4927: > > > > -gpio gpiochip0: Static allocation of GPIO base is deprecated, use > > dynamic allocation. > > + gpiochip0: Static allocation of GPIO base is deprecated, use > > dynamic allocation. > > > > Or with CONFIG_DEBUG_GPIO=y, e.g. on BeagleBone black: > > > > -gpio gpiochip0: (gpio-0-31): created GPIO range 0->7 ==> > > 44e10800.pinmux PIN 0->7 > > -gpio gpiochip0: (gpio-0-31): created GPIO range 8->11 ==> > > 44e10800.pinmux PIN 90->93 > > -gpio gpiochip0: (gpio-0-31): created GPIO range 12->27 ==> > > 44e10800.pinmux PIN 12->27 > > -gpio gpiochip0: (gpio-0-31): created GPIO range 28->31 ==> > > 44e10800.pinmux PIN 30->33 > > + gpiochip0: (gpio-0-31): created GPIO range 0->7 ==> > > 44e10800.pinmux PIN 0->7 > > + gpiochip0: (gpio-0-31): created GPIO range 8->11 ==> > > 44e10800.pinmux PIN 90->93 > > + gpiochip0: (gpio-0-31): created GPIO range 12->27 ==> > > 44e10800.pinmux PIN 12->27 > > + gpiochip0: (gpio-0-31): created GPIO range 28->31 ==> > > 44e10800.pinmux PIN 30->33 > > [...] > > > > Note the spaces at the beginning of the printed lines. > > Reverting the commit re-adds the "gpio" prefix. Thanks for catching this. > > > > As per the comment in gpiochip_add_data_with_key(): we may end up with > a functional chip before gpiochip_setup_dev() is called and so before we > assign the bus type. > > dev_printk() helpers only read the name field of the bus type so it should > be safe, I don't see anyone else accessing it before we register it. > > I think it makes sense to revert this commit. Tzung-Bi: what do you think? That makes sense. I agree, let's revert it.