From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (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 EFE0D315D29 for ; Fri, 13 Feb 2026 22:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771022187; cv=none; b=mSmgEKSnd548i+TbI5TNU4wC8JrCTQ835kNr1IyCfRlouz2AHM5PlC1kisjEQBe7vbBvPgZ/Ihy9St0Gpqvt1iSVspoJCqDyOb4/q8piL5JfzFKs9wbXsbB+v1/Yi0TXFNtjZ0YMzuZC993zak8VEWZCZRCqzRjDgp8I2+6vo+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771022187; c=relaxed/simple; bh=oVTU1zKhANibNRT4SwAkYTOEvTSrsooX2FCTPqCmY6Y=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=DAoh3iFoR4JJr15w+vUecr8WZ8PduQEdZdWtPW1n5CwaCxB+fu+nBeDQP/JH8LXRJiBfm2THYhaB1oZOkf5xsR4QKWbF5gJKjocGEuInYFJyQvYAc7812GhCT2wFuVQT1Tg9SfFO3SfL7vAHg0nLWpNLgoR47HO5de+jK/hAFaI= 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=XHfYVduN; arc=none smtp.client-ip=74.125.82.182 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="XHfYVduN" Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-2ba9c484e5eso1458274eec.1 for ; Fri, 13 Feb 2026 14:36:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771022185; x=1771626985; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=gTM+KuSwhK9eHFn0vF9h35+vNAzwh9qid0+g/zYMTZI=; b=XHfYVduNhc1c9R26tlU6c14Qfp6DCKMbdb1zPwpgMGt/b4JXq4V0u5D1h1c0fWZ62D 96V86vneEGnXtiJk/+l0/bD0DdF7zQ+Gswuz8tyr0aZELEOzwTg9e6z97BX3qhIppu36 ++6Rv9Axipt74Beivo58M41787GE6ZpltsE7vASoNEghJ7W7La94sZ6GNmG6eQey1S7g KA+VyYxHLL2aRKAeC3Vz+kkicfhB3Hv8Jz+Wh0R9hmGIGe47QKETXfFwOW7j0rRekmei 1X1R1IjxSL7kdKcCaVOm0yu02sgxknWf0EuKkbumBBATae6uEJgEzaEL0+BEuVImodxE OiRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771022185; x=1771626985; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gTM+KuSwhK9eHFn0vF9h35+vNAzwh9qid0+g/zYMTZI=; b=r02MZ0Fybdc/Eo5f4rymLH9v73KIQMCm5TRpixTTqWHEQIOC6LF5k2Gb/02mxo0fMo ftnhftB00J/oeprN8TGtrRKXX3pfqyk/khe0voKXpaLHnuQ53PUC/cFfkqgYxur+fMCu FWs7LmkqXyXLOk3JlsBVE1Id8kehPgy/daRU8qFgVOfKCTTYouF7/gjPkCg0yXzs1Bgc d914Lvi3kYtZskkTzCReGwze52OG0JwJJokREdZQfMFSQCd+ZXFy0fzLcMLZw5VXxbSB VzGUkxlQkQvwURgjAU6iHAyS+3oXK7XJSDN15ROZ5GVVNAdJdkX0UzItv+9OVT+K0ldE drSQ== X-Forwarded-Encrypted: i=1; AJvYcCXIuTCLM5ycIFfw6EzBONPIxZ2wYmMgEOptZEKYxKiTM9i5iW8dM4KKHMwQbK0ToR2hhSAZQseaLvgYTZU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+JRmKV11hYCdb8iDBwmFEOGICJ/0EmpVEnUwZWT2nsUsxN3CK YHflOrrqxySUSF6ItlrLZZrZQ6aFqQ6WmINTrfpDUn4qo1djixM9jcPk X-Gm-Gg: AZuq6aKdDPZckXrjgx/gjrAi/I1jv7J490ixCRY50HU8EOwzcnNRkkAeNBJEoOGPjQS VOZlzontJlgMisdS3dJyBZcm63lCr/d1S8rWQ29W639JqECGnngZzNFqdT2ZHReVnXeN2N85E+o NTjbo/qtzYGiAyq43qUuKYtVVKlMkm77lwn/Ak2FEIttSlmvYZ8H64VfgE2hJPHRPLzz6/89++5 IO9zCsPg533Nh4qHWUzrq+zWk0FGyVs/Wyq2yr4docul9/1UvT4kEDc9Df/b0B05LmT7iojqy5K eDZa33VEffuYuMSH4tZx+Y+FRcWNfjVDkqrMDd3o/W2DMX2/7ZghQtJuQySgm3GspYVI3TYaNVZ dKmympzxdAMBbeOFUbCwy9LEWL/zbu984scSQtyez0kem1IoyS2Whc/7PlWi3cx0LpmPgvz8GJA 5BoH/7TbhM2C1wSgKjrVI2nE0N1T+HUc712+f3Gz1m+GqRBMrYYbnvEtw2VjDrcCJfzPUQ3CW9L CM= X-Received: by 2002:a05:7301:7c01:b0:2ba:b37a:6b37 with SMTP id 5a478bee46e88-2bac97d26dbmr354792eec.30.1771022184816; Fri, 13 Feb 2026 14:36:24 -0800 (PST) Received: from google.com ([2a00:79e0:2ebe:8:b713:5e7b:5963:d2ad]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bacb658544sm184144eec.17.2026.02.13.14.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Feb 2026 14:36:24 -0800 (PST) Date: Fri, 13 Feb 2026 14:36:21 -0800 From: Dmitry Torokhov To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Danilo Krummrich , Arnd Bergmann , Bartosz Golaszewski , Hans de Goede , linux-kernel@vger.kernel.org Subject: [PATCH] driver core: platform: allow attaching software nodes when creating devices Message-ID: 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 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. 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; + if (pdevinfo->swnode && pdevinfo->properties) + return ERR_PTR(-EINVAL); + pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id); if (!pdev) return ERR_PTR(-ENOMEM); @@ -865,17 +868,19 @@ struct platform_device *platform_device_register_full( pdev->dev.coherent_dma_mask = pdevinfo->dma_mask; } - ret = platform_device_add_resources(pdev, - pdevinfo->res, pdevinfo->num_res); + ret = platform_device_add_resources(pdev, pdevinfo->res, pdevinfo->num_res); if (ret) goto err; - ret = platform_device_add_data(pdev, - pdevinfo->data, pdevinfo->size_data); + ret = platform_device_add_data(pdev, pdevinfo->data, pdevinfo->size_data); if (ret) goto err; - if (pdevinfo->properties) { + if (pdevinfo->swnode) { + ret = device_add_software_node(&pdev->dev, pdevinfo->swnode); + if (ret) + goto err; + } else if (pdevinfo->properties) { ret = device_create_managed_software_node(&pdev->dev, pdevinfo->properties, NULL); if (ret) diff --git a/include/linux/platform_device.h b/include/linux/platform_device.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); 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; - const char *name; - int id; + const char *name; + int id; - const struct resource *res; - unsigned int num_res; + const struct resource *res; + unsigned int num_res; - const void *data; - size_t size_data; - u64 dma_mask; + const void *data; + size_t size_data; + u64 dma_mask; - const struct property_entry *properties; + const struct software_node *swnode; + const struct property_entry *properties; }; extern struct platform_device *platform_device_register_full( const struct platform_device_info *pdevinfo); -- 2.53.0.310.g728cabbaf7-goog -- Dmitry