From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3C58361647 for ; Thu, 2 Apr 2026 15:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775145234; cv=none; b=D7bbU/Mg/F0F+7k6f8FsOeVl9ibFnGYv8OUOJ4OI2sfnp03IxUGrBPF4JJ09xWICS5annPuo5VJof3Fjmz3CK5WOf4rktndiS23+TovpnWbojwDyR2/GtM8qvCD+v8OZwb626ggL3ye3MBSvYTYAXcZQSfb5UrYqnU7hZoATaDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775145234; c=relaxed/simple; bh=FpxvnJ8xBjj+6gf6q2qKDpOtmvlTUDIXfg+/vStZ1+g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gG04QLH+hGiqNwHlIkDA9Xf8jImf8HwjKCYho38jplpsu0ihkFqQNcHKB8Z+nP4ZAblx5CAmNR3ZsoytQnuSqpG3fCAyLzlMACmo6aJUCsIZLQ7O//dmzSAInQyEM3wAvkCbguv4a4Q8dLMmiuhZvBAtZ/i6T1sbWsWoOwtQ/rI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Hb31qHE7; arc=none smtp.client-ip=74.125.82.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hb31qHE7" Received: by mail-dy1-f169.google.com with SMTP id 5a478bee46e88-2c66eafc1easo2078289eec.1 for ; Thu, 02 Apr 2026 08:53:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775145232; x=1775750032; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gbXKujNeQw4fmWcbhBupJNqIEgoiL9nCv2NG6T/ZbEc=; b=Hb31qHE70lpWkrGJZm/DpjhBa5cca+InP3n68MyakEUiTrXXvIjxpjgRejT7usywNe n4rQWihT+3cO/foAbbjiY3LS/LB1F6PzpE3QKG8ZsZejXaf2CBxqiya+M8UvFrBjfQeS XVr1ILlr+vNwPl3k5tYCPTPMQ+FUy+YD585KG5jxDz7p6KE1xVfm+/j+cH5nT7sYmdoM 6krcSbzsq5pYD/SqwoFpPF5IBUjNDtnfc0AnUxp5kbi/fgFS8zHkCGbEnnekotgvx9Tf Pfba5bR+x+O9e2Xhp9fW9f+KB9dhaBQq3aSB2ER1SoTidNXu99zF6AWp0F0qKbyeplkR xTZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775145232; x=1775750032; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gbXKujNeQw4fmWcbhBupJNqIEgoiL9nCv2NG6T/ZbEc=; b=QtamVnxcYNCSDvtTGZOBdmxo6wa+3225ciyoD/+37i+PLbx2v5nnOP7KC8bA9HXS8B Pfx3rLJAcOJaHAAQrDmZegRZBfvUK0ko5gDmWrL69D5qKmx5yJwuEtp62sIn3eMig4fP 6bq6uAfGTD6Izk6ajTZpdeYLR5nZdLCoBAzogFYyvLZnh1BMx5H8cGPgepRKcOfiJ71r 7fkhahqgfjibqbuDVs7mEOnVWSqcBSy3htMbuOO8fspM+TQavtb5UpWHYzN2XwZqOy+P Z2P7EXTuC6hCLDFrKjhfolHu1PIWGtRZiElYI3DlUkjdKQgcP/CWnVmPzaoxoE2USXgT K2jg== X-Forwarded-Encrypted: i=1; AJvYcCXElKtTKurx5PEyg8bvTjVa5tF6EPpWR9WViQWAgYIlUP0i/dhwQO6JpZssyllTxyaGu9iTrR786Qcgddg=@vger.kernel.org X-Gm-Message-State: AOJu0YwCJ7oOGxPxb1OGcmhz8i6rITyppfe3f7HbW+L4L2dWmmH3lpYS h+FJ5jzpRpfn/xUBsxLQaK+T7jKOqKQmSq6Pown9m+DZRiU7vOEr4s2z X-Gm-Gg: AeBDieujptrBPiz7QE9QmIAm/3g1VfR9T5eyAXsXkStVZ9OA3whJzbyQt3lChtBndKs g+Qna/9WOb+zey9zwgSO+wzJB2gs6QMJqLHhQivtsbLuYeJiFq0mGuZEvAQMZyofaRPIb0Owq8s 75i7xRVzDNb6u49R0e1q9RmepD6bQ4CK36d6Ar7Um/oYFoSOLQQSnsd1x47XpfTr5UNSdzFK9zf XpI/klak/sqgGmP9r6aB/jXfW/EO69h838ra6oW0o44IBhUKt7w+Spw+lenX6JqKOrSazQuBftB ZKbs5G9zA6yhaql1IHMe5pMekktMfR+7io+7j2K//oPBPlzUAkOt0xwVJwstu5hNb5NEbqKARUL UQAgzeCsaJiOBrvZOOjwB8R08VmnWRNzcPhuTETK6tu8HHntJ/++eww7zgJ7boHMtxioguXmcuO aWTOjyGS/mquTII0zrdNOZ1qWDWUqt3kN1iq0QAS2xuhNzh9iTWfwgb2y95soPbqC5 X-Received: by 2002:a05:7300:3708:b0:2c7:ea98:da0 with SMTP id 5a478bee46e88-2c9323b72c2mr4759468eec.19.1775145231911; Thu, 02 Apr 2026 08:53:51 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:902a:cd8d:1c0d:8926]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2cb92ea0ef1sm638703eec.21.2026.04.02.08.53.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2026 08:53:51 -0700 (PDT) Date: Thu, 2 Apr 2026 08:53:48 -0700 From: Dmitry Torokhov To: Bartosz Golaszewski Cc: Santosh Kumar Yadav , Peter Korsgaard , Hans de Goede , Ilpo =?utf-8?B?SsOkcnZpbmVu?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH] platform/x86: barco-p50-gpio: attach software node to its target GPIO device Message-ID: References: <20260331112819.103298-1-bartosz.golaszewski@oss.qualcomm.com> 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 Thu, Apr 02, 2026 at 01:29:35AM -0700, Bartosz Golaszewski wrote: > On Wed, 1 Apr 2026 04:09:21 +0200, Dmitry Torokhov > said: > > On Tue, Mar 31, 2026 at 01:28:19PM +0200, Bartosz Golaszewski wrote: > >> The software node representing the GPIO controller to consumers is > >> "dangling": it's not really attached to the device. The GPIO lookup > >> relies on matching the name of the node to the chip's label. Set it as > >> the secondary firmware node of the platform device to enable proper > >> fwnode-based GPIO lookup. > >> > >> Signed-off-by: Bartosz Golaszewski > >> --- > >> drivers/platform/x86/barco-p50-gpio.c | 2 ++ > >> 1 file changed, 2 insertions(+) > >> > >> diff --git a/drivers/platform/x86/barco-p50-gpio.c b/drivers/platform/x86/barco-p50-gpio.c > >> index 2a6d8607c402..5f4ffa584295 100644 > >> --- a/drivers/platform/x86/barco-p50-gpio.c > >> +++ b/drivers/platform/x86/barco-p50-gpio.c > >> @@ -365,6 +365,8 @@ static int p50_gpio_probe(struct platform_device *pdev) > >> if (ret) > >> return dev_err_probe(&pdev->dev, ret, "failed to register software nodes"); > >> > >> + set_secondary_fwnode(&pdev->dev, software_node_fwnode(&gpiochip_node)); > >> + > >> led_info.fwnode = software_node_fwnode(&gpio_leds_node); > >> p50->leds_pdev = platform_device_register_full(&led_info); > >> if (IS_ERR(p50->leds_pdev)) { > > > > I looks like http://sashiko.dev patch critique is on point: > > > > Ok, let's unpack it. > > > " > > Is the software node attached too late to take effect? > > > > In the probe function, devm_gpiochip_add_data() is called before this > > set_secondary_fwnode() call. During GPIO chip registration, the gpiolib > > core snapshots the parent device's fwnode. > > > > What does it mean "to snapshot" the parent's fwnode? > > What happens is this: > > static struct fwnode_handle *gpiochip_choose_fwnode(struct gpio_chip *gc) > { > if (gc->fwnode) > return gc->fwnode; > > if (gc->parent) > return dev_fwnode(gc->parent); > > return NULL; > } > > gc->fwnode is NULL so we set gc->parent as the GPIO controller's fwnode. However if parent does not have fwnode assigned (dev->fwnode is NULL) this will return NULL as well. This effectively severs the link between the gpiochip and the parent device. > > > Because the secondary fwnode is not yet set on pdev->dev when this snapshot > > happens, the GPIO device is registered with a NULL fwnode, which seems to > > defeat the purpose of enabling fwnode-based lookups. > > > > Sashiko is completely wrong here: not only is the device registered with the > parent's fwnode assigned, the secondary fwnode is a property of the *fwnode*, > not of the device. We set the secondary fwnode of the parent's real fwnode. > This is carried over to the GPIO controller's device properties even after > it's been created. I do not think it is wrong. If the parent does not have fwnode assigned (and it does not) then you do not have a fwnode object to attach a secondary node to. The node you are attaching as a secondary becomes primary, but it is *too late*. The link has been severed, gpiochip's fwnode is a NULL pointer and has no idea that the parent now has a valid fwnode. I think this woudl be a better approach: @@ -426,7 +419,6 @@ MODULE_DEVICE_TABLE(dmi, dmi_ids); static int __init p50_module_init(void) { - struct resource res = DEFINE_RES_IO(P50_GPIO_IO_PORT_BASE, P50_PORT_CMD + 1); int ret; if (!dmi_first_match(dmi_ids)) @@ -436,7 +428,15 @@ static int __init p50_module_init(void) if (ret) return ret; - gpio_pdev = platform_device_register_simple(DRIVER_NAME, PLATFORM_DEVID_NONE, &res, 1); + gpio_pdev = platform_device_register_full(&(struct platform_device_info){ + .name = DRIVER_NAME, + .id = PLATFORM_DEVID_NONE, + .res = (const struct resource[]){ + DEFINE_RES_IO(P50_GPIO_IO_PORT_BASE, P50_PORT_CMD + 1), + }, + .num_res = 1, + .swnode = &gpiochip_node, + }); if (IS_ERR(gpio_pdev)) { pr_err("failed registering %s: %ld\n", DRIVER_NAME, PTR_ERR(gpio_pdev)); platform_driver_unregister(&p50_gpio_driver); This way you start with the right node right away. Thanks. -- Dmitry