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 071F21519AC for ; Fri, 13 Feb 2026 23:25:05 +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=1771025106; cv=none; b=YWafeA+OTgGso7ACJrari0LhzbwRAJQeS8oRrWz37Xm5ewlAmTuJR3ZjQP0VawRUi5vLZHMl75Q2ek6EtkbDPgmd/4seCeq5fhCz76jAwL4aFA9Mq5qlajsXClylr+UScOcD/SOXioO+qeR2ncCx3CUTPqxKWGtL8l3F/itxqK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771025106; c=relaxed/simple; bh=+Cy0exCwD17FBWf1Irxa5KxC0yK7N4G0OEXldr2bQHI=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:To:From:Subject: References:In-Reply-To; b=Swx0C6mhTyeb3yEOPcoMSJxDjpFf/shXNIfLLl3RCJoYIN1J6S528x657SIJ26R//s88c8m+1OCYQ/zPQhh7eO9jPtUzhuk+b/3JCIvIt+3bs0+X7H4JMRM8sfvb6T+RLa+m9c+QcYMWq/f1Ma2eO/pdtliuMLlkulaApmBCkQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bmFcTr87; 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="bmFcTr87" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24CA2C116C6; Fri, 13 Feb 2026 23:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771025105; bh=+Cy0exCwD17FBWf1Irxa5KxC0yK7N4G0OEXldr2bQHI=; h=Date:Cc:To:From:Subject:References:In-Reply-To:From; b=bmFcTr87Y2leLavKpbUDtR2Abd06edx1dH0wNEQUMMua8lM+Wp/rTsia/Q5ij8uM5 sLIWJSLmKXGPQ74Hd5DRnkx/+GE9RlCLXymiaCRj1sNp7oQXGEI/LSsosmzJ5m2V9Q fITMFDM7/GpxP/84DpICUGo2gkAFuX4bcyxaXmRj6f1N3ilIElZuTdcvDMp9Wll7jm G6dTFBdvkaCFFfZBetMi8unSupzcUXmKr8jvatQr1ejChou6JrHA3cKymIElo8xdbF +O5LZDMycChlmj1tqLON24sYcX7FLg9JcQ779f3wc49ExVI0fu6wVlhl69DLXEMheW SOMOi2UrFUVwg== 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 Date: Sat, 14 Feb 2026 00:25:02 +0100 Message-Id: Cc: "Greg Kroah-Hartman" , "Rafael J. Wysocki" , "Arnd Bergmann" , "Bartosz Golaszewski" , "Hans de Goede" , To: "Dmitry Torokhov" From: "Danilo Krummrich" Subject: Re: [PATCH] driver core: platform: allow attaching software nodes when creating devices References: In-Reply-To: On Fri Feb 13, 2026 at 11:36 PM CET, Dmitry Torokhov wrote: > Extend platform_device_info structure with an optional pointer to a > software node to be used as a secondary firmware node for the device > being created. If software node has not been registered yet it will be > automatically registered. > > This reduces boilerplate needed when switching legacy board code to > static device properties/GPIO references. Are there any patches for this already? If so, how do you plan to land them= ? > Signed-off-by: Dmitry Torokhov > --- > drivers/base/platform.c | 15 ++++++++++----- > include/linux/platform_device.h | 23 ++++++++++++----------- > 2 files changed, 22 insertions(+), 16 deletions(-) > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index b45d41b018ca..bef69ad68e02 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -850,6 +850,9 @@ struct platform_device *platform_device_register_full= ( > int ret; > struct platform_device *pdev; > =20 > + if (pdevinfo->swnode && pdevinfo->properties) > + return ERR_PTR(-EINVAL); Unfortunate that we can't catch this at build time. > + > pdev =3D platform_device_alloc(pdevinfo->name, pdevinfo->id); > if (!pdev) > return ERR_PTR(-ENOMEM); > @@ -865,17 +868,19 @@ struct platform_device *platform_device_register_fu= ll( > pdev->dev.coherent_dma_mask =3D pdevinfo->dma_mask; > } > =20 > - ret =3D platform_device_add_resources(pdev, > - pdevinfo->res, pdevinfo->num_res); While the formatting is indeed not great, I prefer not to change this in th= is patch. The same goes for the other unrelated formatting changes in this pat= ch. > + ret =3D platform_device_add_resources(pdev, pdevinfo->res, pdevinfo->nu= m_res); > if (ret) > goto err; > =20 > - ret =3D platform_device_add_data(pdev, > - pdevinfo->data, pdevinfo->size_data); > + ret =3D platform_device_add_data(pdev, pdevinfo->data, pdevinfo->size_d= ata); > if (ret) > goto err; > =20 > - if (pdevinfo->properties) { > + if (pdevinfo->swnode) { > + ret =3D device_add_software_node(&pdev->dev, pdevinfo->swnode); > + if (ret) > + goto err; > + } else if (pdevinfo->properties) { > ret =3D device_create_managed_software_node(&pdev->dev, > pdevinfo->properties, NULL); > if (ret) > diff --git a/include/linux/platform_device.h b/include/linux/platform_dev= ice.h > index 813da101b5bf..3d96edfe0ee6 100644 > --- a/include/linux/platform_device.h > +++ b/include/linux/platform_device.h > @@ -119,21 +119,22 @@ extern int platform_get_irq_byname_optional(struct = platform_device *dev, > extern int platform_add_devices(struct platform_device **, int); > =20 > struct platform_device_info { > - struct device *parent; > - struct fwnode_handle *fwnode; > - bool of_node_reused; > + struct device *parent; > + struct fwnode_handle *fwnode; > + bool of_node_reused; > =20 > - const char *name; > - int id; > + const char *name; > + int id; > =20 > - const struct resource *res; > - unsigned int num_res; > + const struct resource *res; > + unsigned int num_res; > =20 > - const void *data; > - size_t size_data; > - u64 dma_mask; > + const void *data; > + size_t size_data; > + u64 dma_mask; > =20 > - const struct property_entry *properties; > + const struct software_node *swnode; > + const struct property_entry *properties; It would be nice to document that the two are mutually exclusive. > }; > extern struct platform_device *platform_device_register_full( > const struct platform_device_info *pdevinfo);