From nobody Sun Feb 8 15:58:25 2026 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 C24D7369964; Tue, 3 Feb 2026 06:11:53 +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=1770099113; cv=none; b=RV/vX82LG64aC1hXYyFveTYJAR4qPswRAgJg5YHeZrKEqFM00L+d3W1hMWxS4LZI0wNTQcNnRA9mn/P2+qtQSJs2tXE+p1FJVOdRjihm3LKldqiskyQTHRe9DLnjGtCoEV3pKPqEptcWy48hYNKjca7oYfsOtbiLvmGcR7tYmPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770099113; c=relaxed/simple; bh=9YxyRXQE5kVPwTtGkSgy0U2f3ePQUxO3G44Txlw2CP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JCosR/2QEXpep2CnKwkYCwSElKuIlIRvK1p+VjCsgWQawzSdL0Pa6PPWsPFWa4i3pYFSvOSIER6VPv9fxT2sqgwUooEmfvJYtxCIMvJDcFWa0DFwvAtuccLbN00cRzLuYrFakV55We/JiC52UMh+kEYWVyuva3VTWbu73DkMpyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Oa1RfMNw; 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="Oa1RfMNw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08F45C2BC86; Tue, 3 Feb 2026 06:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770099113; bh=9YxyRXQE5kVPwTtGkSgy0U2f3ePQUxO3G44Txlw2CP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oa1RfMNwz78iW7e/YjWiAp+BQrjFLnw4oJUi5eeGIFaIR/6nuXdTboMq4FhSCeCj9 rizGM7Yk+AGmnSWqNWV62R0s1aIYY1jq70rowLWkrgjYHDSmQUjcfilgTRzyVzpcrm BzqATe1xT19KJl9RmnJBCCo095Iu6C3nEqqVECgx5zPIwSjFQ73KczvN+k9QYp5eZo ATrVYq8vtCEaaJo+PiRoa6mlJNKgl8GQoCjAY5TGDZ/rzXFpzC19UO7M/43ExFHe96 J9ZY0q94KX8eTtfw/3C9/MNWLGfB9nPmqFk4XDn2jBV6kEg6GroFURhWiflEyqWcSJ 82pynaxkGxUJg== From: Tzung-Bi Shih To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Bartosz Golaszewski , Linus Walleij Cc: Jonathan Corbet , Shuah Khan , Laurent Pinchart , Wolfram Sang , Jason Gunthorpe , Johan Hovold , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chrome-platform@lists.linux.dev, tzungbi@kernel.org, Dan Williams , linux-gpio@vger.kernel.org Subject: [PATCH v2 01/11] gpio: Access `gpio_bus_type` in gpiochip_setup_dev() Date: Tue, 3 Feb 2026 06:10:48 +0000 Message-ID: <20260203061059.975605-2-tzungbi@kernel.org> X-Mailer: git-send-email 2.53.0.rc2.204.g2597b5adb4-goog In-Reply-To: <20260203061059.975605-1-tzungbi@kernel.org> References: <20260203061059.975605-1-tzungbi@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To make the intent clear, access `gpio_bus_type` only when it's ready in gpiochip_setup_dev(). Signed-off-by: Tzung-Bi Shih --- v2: - No changes. v1: https://lore.kernel.org/all/20260116081036.352286-7-tzungbi@kernel.org drivers/gpio/gpiolib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 039cd3e56baf..f51f53511ae3 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -902,6 +902,8 @@ static int gpiochip_setup_dev(struct gpio_device *gdev) struct fwnode_handle *fwnode =3D dev_fwnode(&gdev->dev); int ret; =20 + gdev->dev.bus =3D &gpio_bus_type; + /* * If fwnode doesn't belong to another device, it's safe to clear its * initialized flag. @@ -1078,7 +1080,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, = void *data, =20 device_initialize(&gdev->dev); gdev->dev.type =3D &gpio_dev_type; - gdev->dev.bus =3D &gpio_bus_type; gdev->dev.parent =3D gc->parent; device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc)); =20 @@ -1216,8 +1217,8 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, = void *data, * we get a device node entry in sysfs under * /sys/bus/gpio/devices/gpiochipN/dev that can be used for * coldplug of device nodes and other udev business. - * We can do this only if gpiolib has been initialized. - * Otherwise, defer until later. + * We can do this only if gpiolib has been initialized + * (i.e., `gpio_bus_type` is ready). Otherwise, defer until later. */ if (gpiolib_initialized) { ret =3D gpiochip_setup_dev(gdev); --=20 2.53.0.rc2.204.g2597b5adb4-goog