From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (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 B4A281F936 for ; Thu, 12 Feb 2026 01:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770858746; cv=none; b=ZJWDD28U2oFOIG/vlZOLQP3P5o1eRc3AWCVY82FJAjpRbyHsbKSa3TLnIxkPqSGbxR3eoXaFlge35ZCvYh/U/0/xq/+Yr/dL3EhcGPEUbqqRRsuDo9dvaVy+mCa+uPOgT9WGcTY/mZNU2Oh6MK8p0kCCwhBBimLuQ5MdrSm6VGQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770858746; c=relaxed/simple; bh=AyIZT07Uyx8/boB1SCBM6I+oBCCw7IQ6fi/nF+wwhII=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G8DY1COJMfkDQM8bFL6B+h9b7cOIAh/KT4bc1MbwRupgQgyvcqWClxmGzFIqc0SkeiO0dgtAfmWVHWPVTj2auw9jL1QwTNa6yKzVBZ70uaZSE2F+HhF3ENuvbbJtZpdrtf2gM/jIS8x0jqPBtasTTFqdn16avz+YMG7yQ3sOJOo= 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=G5xxkMHC; arc=none smtp.client-ip=74.125.82.176 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="G5xxkMHC" Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-2b7da62b487so244266eec.1 for ; Wed, 11 Feb 2026 17:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770858744; x=1771463544; 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=AteVZ7Dt/6NPuj41q9ANIYjSOQ/ZqhGsME93Ny+Mmnk=; b=G5xxkMHC6AAk3ChvlWHyxKEwrw7OwkcaS51PVsQPs2+cIHCGJlS7hLJksFg08T53Vj HEqKCwOhFGTj7qpieYfEiYRDYcBHI4ggUIs5GMcRv/gHlNrABd+AqyieDBfqLLPvNEAL vl01SxFF7UFgRFPwbVb8KpOrLxrjcsT7A6eL58lIpsc24JC5kHt57Vva1oYNYJuNqj7Y yz66A556PrSvgnbRmau6qwppWll+lyEryzOAchHVsbMgKcPJZafbNdHVJOmnSHocuNfT gEqyNpLA4DpLiPWsJLMFTvP+trZds2p1OMfykWCgpQOjqo0VFPCdNR9l25qAIsaTjpt2 DEgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770858744; x=1771463544; 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=AteVZ7Dt/6NPuj41q9ANIYjSOQ/ZqhGsME93Ny+Mmnk=; b=oGN/a/3+9j8O6KZEFs54GRxLo42FoUhs3lwSxNSkh+mKSmeRT9iOtt5kdFmLzg2yim +ZVb25is3szeu4gJ+lceZKZRDVKk4VwIPo7NaiMGG+gyOlBiTrU2eJxvcvvlVJJNuYTh gHih/EYpTWaa2sjN3jLcjG8IibMbXZip1OaPI8VhcV7fNKtpKg91U95gVDor3XTXXxVe 7k54N2k604QzdmyMxUAz/nHyOaxtIZ7pNvI2n1JNVsxhNrHEnOHno6RfJT4WS58lv3vG a+K4UCWVz245fxhNjvpscUJB279TVwbkQlzfK+WSizhGTr/yeSbqZh8y+5bo7hdH6rSD VxLA== X-Forwarded-Encrypted: i=1; AJvYcCWPoBXBt06RBscZvQsSXvYWJYoyPlLUKMWCMSOjBSpb+q0lWit32ElpnKDKOiE6x4SY/gNbV7478JzQ5AE=@vger.kernel.org X-Gm-Message-State: AOJu0YyJ1bqegges45LVxQeIVrne1VPwzcHWyvl9JsZDS2N/+yaij0jI SYsqNq/gJJsWjvqewfcCZZv3E06q1WrodFWYNVk//WGhfu310pmhOEsn X-Gm-Gg: AZuq6aIyQ2FusbI+YmXIJKSOP9Pvruf6HsBJMjYZvsgs0VjlxNoQAh4/rGil6MkDbP0 iXyC1xQsgoGeYKx+xY+N3ggvPZW0TGwNnmH4a5BnlQMWMW2iIh/ebn7s1cmtl/cHmhKdKS91tH4 xSRFWuVxORX/zvfR/jVR8qL9ITAiKmfX1e/9zw/lN+XfmM1MASYx2V6waAh7n7WiW+9DInpaHN+ KP3XaKdlnYWPw7YQTTeUVw2Oj1UoHA82EWZVe5W9b3UqjGHyY5CsfDrgNKCGbwyvGw53fSgEoEw +IvBKGQbGhebuNelCsrsJgycTMGzAPPP3+5FbUYd68jzjy2N1O0YwPnqUtZmvoloQwxTKdm0e4A MIL09SOr7gEz1+yEoKY8He+wC7S14zFa0/sZDwSGtctKNVJ9xv9ajfTv+bE5raHuyYNt3YecLN8 54dFIuruao8/FT8DVULVQqnnVEtyPYKBsoVmOyCjWKkQgaCdU6SdLnE12Rl/i9u1c= X-Received: by 2002:a05:7300:572c:b0:2ba:9560:af0 with SMTP id 5a478bee46e88-2baa7fb1856mr565278eec.14.1770858743621; Wed, 11 Feb 2026 17:12:23 -0800 (PST) Received: from google.com ([2a00:79e0:2ebe:8:f5e:c935:ddee:63d0]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ba9dcea9b7sm2441009eec.25.2026.02.11.17.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Feb 2026 17:12:23 -0800 (PST) Date: Wed, 11 Feb 2026 17:12:20 -0800 From: Dmitry Torokhov To: Arnd Bergmann Cc: Bartosz Golaszewski , Aaro Koskinen , Janusz Krzysztofik , Tony Lindgren , Russell King , Hans de Goede , Linux-OMAP , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770 Message-ID: References: <20260211131350.126966-1-bartosz.golaszewski@oss.qualcomm.com> <213b82de-fee8-4ebf-a8ee-d8ca783ce403@app.fastmail.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 Wed, Feb 11, 2026 at 01:40:44PM -0800, Dmitry Torokhov wrote: > On Wed, Feb 11, 2026 at 05:31:52PM +0100, Arnd Bergmann wrote: > > On Wed, Feb 11, 2026, at 14:13, Bartosz Golaszewski wrote: > > > Currently the board file for Nokia 770 creates dummy software nodes not > > > attached in any way to the actual GPIO controller devices and uses the > > > fact that GPIOLIB matching swnode's name to the GPIO chip's label during > > > software node lookup. This behavior is wrong and we want to remove it. > > > To that end, we need to first convert all existing users to creating > > > actual fwnode links. > > > > > > Create real software nodes for GPIO controllers on OMAP16xx and > > > reference them from the software nodes in the nokia board file. > > > > > > Signed-off-by: Bartosz Golaszewski > > > --- > > > > I don't see mistakes here, and I don't want to throw a wrench in > > this patch, but I wonder if there is a way to take this one step further: > > > > > @@ -244,6 +263,14 @@ static int __init omap16xx_gpio_init(void) > > > iounmap(base); > > > > > > platform_device_register(omap16xx_gpio_dev[i]); > > > + > > > + ret = device_add_software_node(&omap16xx_gpio_dev[i]->dev, > > > + omap16xx_gpio_swnodes[i]); > > > + > > > + if (ret) { > > > + dev_err(&pdev->dev, "Failed to add software node.\n"); > > > + return ret; > > > + } > > > > I was planning to go through the remaining 'static struct platform_device' > > definitions in arch/arm/ after the planned board file removal and > > try to convert these to 'platform_device_info' or similar, using > > platform_device_register_full(). Since that function already contains > > code to dynamically allocate the software_node, I had hoped that > > a lot of this would just go away. > > > > However, I see that your patch creates pointers to those software_node > > instances, so think that would become a bit harder, but I have not > > actually tried it. > > > > Do you know if there is a good way to do this without using static > > platform devices? > > I wonder if something like below will help reducing boilerplate... And then we can change the gpio16xx like this (on top of Bartosz changes): diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c index 177621cb4784..a42f13890b94 100644 --- a/arch/arm/mach-omap1/gpio16xx.c +++ b/arch/arm/mach-omap1/gpio16xx.c @@ -26,7 +26,7 @@ #define SYSCONFIG_WORD 0x14 /* mpu gpio */ -static struct resource omap16xx_mpu_gpio_resources[] = { +static const struct resource omap16xx_mpu_gpio_resources[] __initconst = { { .start = OMAP1_MPUIO_VBASE, .end = OMAP1_MPUIO_VBASE + SZ_2K - 1, @@ -38,7 +38,7 @@ static struct resource omap16xx_mpu_gpio_resources[] = { }, }; -static struct omap_gpio_reg_offs omap16xx_mpuio_regs = { +static const struct omap_gpio_reg_offs omap16xx_mpuio_regs = { .revision = USHRT_MAX, .direction = OMAP_MPUIO_IO_CNTL, .datain = OMAP_MPUIO_INPUT_LATCH, @@ -49,27 +49,27 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = { .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE, }; -static struct omap_gpio_platform_data omap16xx_mpu_gpio_config = { +static const struct omap_gpio_platform_data omap16xx_mpu_gpio_config __initconst = { .is_mpuio = true, .bank_width = 16, .bank_stride = 1, .regs = &omap16xx_mpuio_regs, }; -const struct software_node omap16xx_mpu_gpio_swnode = { }; +static const struct software_node omap16xx_mpu_gpio_swnode; -static struct platform_device omap16xx_mpu_gpio = { - .name = "omap_gpio", - .id = 0, - .dev = { - .platform_data = &omap16xx_mpu_gpio_config, - }, - .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources), - .resource = omap16xx_mpu_gpio_resources, +static const struct platform_device_info omap16xx_mpu_gpio_info __initconst = { + .name = "omap_gpio", + .id = 0, + .data = &omap16xx_mpu_gpio_config, + .size_data = sizeof(omap16xx_mpu_gpio_config), + .res = omap16xx_mpu_gpio_resources, + .num_res = ARRAY_SIZE(omap16xx_mpu_gpio_resources), + .swnode = &omap16xx_mpu_gpio_swnode, }; /* gpio1 */ -static struct resource omap16xx_gpio1_resources[] = { +static const struct resource omap16xx_gpio1_resources[] __initconst = { { .start = OMAP1610_GPIO1_BASE, .end = OMAP1610_GPIO1_BASE + SZ_2K - 1, @@ -81,7 +81,7 @@ static struct resource omap16xx_gpio1_resources[] = { }, }; -static struct omap_gpio_reg_offs omap16xx_gpio_regs = { +static const struct omap_gpio_reg_offs omap16xx_gpio_regs = { .revision = OMAP1610_GPIO_REVISION, .direction = OMAP1610_GPIO_DIRECTION, .set_dataout = OMAP1610_GPIO_SET_DATAOUT, @@ -97,25 +97,25 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = { .edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2, }; -static struct omap_gpio_platform_data omap16xx_gpio1_config = { +static const struct omap_gpio_platform_data omap16xx_gpio1_config __initconst = { .bank_width = 16, .regs = &omap16xx_gpio_regs, }; -const struct software_node omap16xx_gpio1_swnode = { }; +static const struct software_node omap16xx_gpio1_swnode; -static struct platform_device omap16xx_gpio1 = { - .name = "omap_gpio", - .id = 1, - .dev = { - .platform_data = &omap16xx_gpio1_config, - }, - .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources), - .resource = omap16xx_gpio1_resources, +static const struct platform_device_info omap16xx_gpio1_info __initconst = { + .name = "omap_gpio", + .id = 1, + .data = &omap16xx_gpio1_config, + .size_data = sizeof(omap16xx_gpio1_config), + .res = omap16xx_gpio1_resources, + .num_res = ARRAY_SIZE(omap16xx_gpio1_resources), + .swnode = &omap16xx_gpio1_swnode, }; /* gpio2 */ -static struct resource omap16xx_gpio2_resources[] = { +static const struct resource omap16xx_gpio2_resources[] __initconst = { { .start = OMAP1610_GPIO2_BASE, .end = OMAP1610_GPIO2_BASE + SZ_2K - 1, @@ -127,25 +127,25 @@ static struct resource omap16xx_gpio2_resources[] = { }, }; -static const struct software_node omap16xx_gpio2_swnode = { }; +static const struct software_node omap16xx_gpio2_swnode; -static struct omap_gpio_platform_data omap16xx_gpio2_config = { +static const struct omap_gpio_platform_data omap16xx_gpio2_config __initconst = { .bank_width = 16, .regs = &omap16xx_gpio_regs, }; -static struct platform_device omap16xx_gpio2 = { - .name = "omap_gpio", - .id = 2, - .dev = { - .platform_data = &omap16xx_gpio2_config, - }, - .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources), - .resource = omap16xx_gpio2_resources, +static const struct platform_device_info omap16xx_gpio2_info __initconst = { + .name = "omap_gpio", + .id = 2, + .data = &omap16xx_gpio2_config, + .size_data = sizeof(omap16xx_gpio2_config), + .res = omap16xx_gpio2_resources, + .num_res = ARRAY_SIZE(omap16xx_gpio2_resources), + .swnode = &omap16xx_gpio2_swnode, }; /* gpio3 */ -static struct resource omap16xx_gpio3_resources[] = { +static const struct resource omap16xx_gpio3_resources[] __initconst = { { .start = OMAP1610_GPIO3_BASE, .end = OMAP1610_GPIO3_BASE + SZ_2K - 1, @@ -157,25 +157,25 @@ static struct resource omap16xx_gpio3_resources[] = { }, }; -static struct omap_gpio_platform_data omap16xx_gpio3_config = { +static const struct omap_gpio_platform_data omap16xx_gpio3_config __initconst = { .bank_width = 16, .regs = &omap16xx_gpio_regs, }; -static const struct software_node omap16xx_gpio3_swnode = { }; +static const struct software_node omap16xx_gpio3_swnode; -static struct platform_device omap16xx_gpio3 = { - .name = "omap_gpio", - .id = 3, - .dev = { - .platform_data = &omap16xx_gpio3_config, - }, - .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources), - .resource = omap16xx_gpio3_resources, +static const struct platform_device_info omap16xx_gpio3_info __initconst = { + .name = "omap_gpio", + .id = 3, + .data = &omap16xx_gpio3_config, + .size_data = sizeof(omap16xx_gpio3_config), + .res = omap16xx_gpio3_resources, + .num_res = ARRAY_SIZE(omap16xx_gpio3_resources), + .swnode = &omap16xx_gpio3_swnode, }; /* gpio4 */ -static struct resource omap16xx_gpio4_resources[] = { +static const struct resource omap16xx_gpio4_resources[] __initconst = { { .start = OMAP1610_GPIO4_BASE, .end = OMAP1610_GPIO4_BASE + SZ_2K - 1, @@ -187,37 +187,29 @@ static struct resource omap16xx_gpio4_resources[] = { }, }; -static struct omap_gpio_platform_data omap16xx_gpio4_config = { +static const struct omap_gpio_platform_data omap16xx_gpio4_config __initconst = { .bank_width = 16, .regs = &omap16xx_gpio_regs, }; -static const struct software_node omap16xx_gpio4_swnode = { }; - -static struct platform_device omap16xx_gpio4 = { - .name = "omap_gpio", - .id = 4, - .dev = { - .platform_data = &omap16xx_gpio4_config, - }, - .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources), - .resource = omap16xx_gpio4_resources, -}; +static const struct software_node omap16xx_gpio4_swnode; -static struct platform_device *omap16xx_gpio_dev[] __initdata = { - &omap16xx_mpu_gpio, - &omap16xx_gpio1, - &omap16xx_gpio2, - &omap16xx_gpio3, - &omap16xx_gpio4, +static const struct platform_device_info omap16xx_gpio4_info __initconst = { + .name = "omap_gpio", + .id = 4, + .data = &omap16xx_gpio4_config, + .size_data = sizeof(omap16xx_gpio4_config), + .res = omap16xx_gpio4_resources, + .num_res = ARRAY_SIZE(omap16xx_gpio4_resources), + .swnode = &omap16xx_gpio4_swnode, }; -static const struct software_node *omap16xx_gpio_swnodes[] __initconst = { - &omap16xx_mpu_gpio_swnode, - &omap16xx_gpio1_swnode, - &omap16xx_gpio2_swnode, - &omap16xx_gpio3_swnode, - &omap16xx_gpio4_swnode, +static const struct platform_device_info * const omap16xx_gpio_dev[] __initconst = { + &omap16xx_mpu_gpio_info, + &omap16xx_gpio1_info, + &omap16xx_gpio2_info, + &omap16xx_gpio3_info, + &omap16xx_gpio4_info, }; /* @@ -227,11 +219,7 @@ static const struct software_node *omap16xx_gpio_swnodes[] __initconst = { */ static int __init omap16xx_gpio_init(void) { - int i, ret; - void __iomem *base; - struct resource *res; - struct platform_device *pdev; - struct omap_gpio_platform_data *pdata; + int i; if (!cpu_is_omap16xx()) return -EINVAL; @@ -240,36 +228,41 @@ static int __init omap16xx_gpio_init(void) * Enable system clock for GPIO module. * The CAM_CLK_CTRL *is* really the right place. */ - omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04, - ULPD_CAM_CLK_CTRL); + omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04, ULPD_CAM_CLK_CTRL); for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++) { - pdev = omap16xx_gpio_dev[i]; - pdata = pdev->dev.platform_data; + const struct platform_device_info *pdev_info = omap16xx_gpio_dev[i]; + const struct resource *res = NULL; + struct platform_device *pdev; + void __iomem *base; + int j; + + for (j = 0; j < pdev_info->num_res; j++) { + if (resource_type(&pdev_info->res[j]) == IORESOURCE_MEM) { + res = &pdev_info->res[j]; + break; + } + } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (unlikely(!res)) { - dev_err(&pdev->dev, "Invalid mem resource.\n"); + pr_err("gpio%d: Invalid mem resource.\n", i); return -ENODEV; } base = ioremap(res->start, resource_size(res)); if (unlikely(!base)) { - dev_err(&pdev->dev, "ioremap failed.\n"); + pr_err("gpio%d: ioremap failed.\n", i); return -ENOMEM; } __raw_writel(SYSCONFIG_WORD, base + OMAP1610_GPIO_SYSCONFIG); iounmap(base); - platform_device_register(omap16xx_gpio_dev[i]); - - ret = device_add_software_node(&omap16xx_gpio_dev[i]->dev, - omap16xx_gpio_swnodes[i]); - - if (ret) { - dev_err(&pdev->dev, "Failed to add software node.\n"); - return ret; + pdev = platform_device_register_full(pdev_info); + if (IS_ERR(pdev)) { + pr_err("gpio%d: Failed to register device: %ld\n", + i, PTR_ERR(pdev)); + return PTR_ERR(pdev); } } > > Thanks. > -- Dmitry