From patchwork Wed Mar 3 15:28:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 393288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA9D5C4332E for ; Thu, 4 Mar 2021 00:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80B4664E56 for ; Thu, 4 Mar 2021 00:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357397AbhCDAab (ORCPT ); Wed, 3 Mar 2021 19:30:31 -0500 Received: from mga12.intel.com ([192.55.52.136]:10027 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347077AbhCCPbE (ORCPT ); Wed, 3 Mar 2021 10:31:04 -0500 IronPort-SDR: J30wKRvOQPsszfdiLHSFv63gnQ/JNFLmYN/e93nV2JmrPy7Ef0OsNIt+LeeNsUip+QF460OUWT 0IDzEKpnTdSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9912"; a="166470328" X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="166470328" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2021 07:28:17 -0800 IronPort-SDR: OOj6IutRWMLCnYeCRsILydQ9Qd26V5PAR/QkI4SLvIF7uCpnENYTBxmELjLFK80GS2W48U9xo/ M6QGnmQoiBdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="506827348" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Mar 2021 07:28:16 -0800 From: Heikki Krogerus To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] spi: Add support for software nodes Date: Wed, 3 Mar 2021 18:28:11 +0300 Message-Id: <20210303152814.35070-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210303152814.35070-1-heikki.krogerus@linux.intel.com> References: <20210303152814.35070-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Making it possible for the drivers to assign complete software fwnodes to the devices instead of only the device properties in those nodes. Signed-off-by: Heikki Krogerus --- drivers/spi/spi.c | 13 +++++++++++-- include/linux/spi/spi.h | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index b08efe88ccd6c..9b46998ae2a44 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -686,6 +686,15 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, } } + if (chip->swnode) { + status = device_add_software_node(&proxy->dev, chip->swnode); + if (status) { + dev_err(&ctlr->dev, "failed to add softwade node to '%s': %d\n", + chip->modalias, status); + goto err_remove_props; + } + } + status = spi_add_device(proxy); if (status < 0) goto err_remove_props; @@ -693,8 +702,7 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, return proxy; err_remove_props: - if (chip->properties) - device_remove_properties(&proxy->dev); + device_remove_software_node(&proxy->dev); err_dev_put: spi_dev_put(proxy); return NULL; @@ -719,6 +727,7 @@ void spi_unregister_device(struct spi_device *spi) } if (ACPI_COMPANION(&spi->dev)) acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev)); + device_remove_software_node(&spi->dev); device_unregister(&spi->dev); } EXPORT_SYMBOL_GPL(spi_unregister_device); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 592897fa4f030..f47f94ea6fa99 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -20,6 +20,7 @@ struct dma_chan; struct property_entry; +struct software_node; struct spi_controller; struct spi_transfer; struct spi_controller_mem_ops; @@ -1409,7 +1410,8 @@ static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd) * @modalias: Initializes spi_device.modalias; identifies the driver. * @platform_data: Initializes spi_device.platform_data; the particular * data stored there is driver-specific. - * @properties: Additional device properties for the device. + * @properties: Deprecated - use software node instead. + * @swnode: Software node for the device. * @controller_data: Initializes spi_device.controller_data; some * controllers need hints about hardware setup, e.g. for DMA. * @irq: Initializes spi_device.irq; depends on how the board is wired. @@ -1448,6 +1450,7 @@ struct spi_board_info { char modalias[SPI_NAME_SIZE]; const void *platform_data; const struct property_entry *properties; + const struct software_node *swnode; void *controller_data; int irq; From patchwork Wed Mar 3 15:28:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 394107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E790C433E6 for ; Thu, 4 Mar 2021 00:30:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80C7764EDF for ; Thu, 4 Mar 2021 00:30:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1451169AbhCDAaf (ORCPT ); Wed, 3 Mar 2021 19:30:35 -0500 Received: from mga12.intel.com ([192.55.52.136]:9923 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382291AbhCCPcz (ORCPT ); Wed, 3 Mar 2021 10:32:55 -0500 IronPort-SDR: Sr5U72FaFhAHhm35sbOm3TRTXJ0ZNDLk4NLeiOHPVNxXbuUI+WWRC6RnrdEjhG/F7UAAmmAInF Kv5nrx9zsC8g== X-IronPort-AV: E=McAfee;i="6000,8403,9912"; a="166470333" X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="166470333" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2021 07:28:19 -0800 IronPort-SDR: 9TojOpu288DBEoJ1hIQQD7edse9fAKl+VRX8EUfAvWnbqN2vb6dbCTMtuJoyFJd8xWPdZkTItA PQFaACRwY2Kw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="506827350" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Mar 2021 07:28:18 -0800 From: Heikki Krogerus To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH 2/4] ARM: pxa: icontrol: Constify the software node Date: Wed, 3 Mar 2021 18:28:12 +0300 Message-Id: <20210303152814.35070-3-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210303152814.35070-1-heikki.krogerus@linux.intel.com> References: <20210303152814.35070-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org When device properties are supplied to the devices, in reality a software fwnode that holds those properties is created which is then assigned to the device. If the device properties are constant the software node can also be constant. Signed-off-by: Heikki Krogerus Cc: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik --- arch/arm/mach-pxa/icontrol.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-pxa/icontrol.c b/arch/arm/mach-pxa/icontrol.c index 151e26ec06968..04a12523cdee0 100644 --- a/arch/arm/mach-pxa/icontrol.c +++ b/arch/arm/mach-pxa/icontrol.c @@ -74,13 +74,17 @@ static const struct property_entry mcp251x_properties[] = { {} }; +static const struct software_node mcp251x_node = { + .properties = mcp251x_properties, +}; + static struct spi_board_info mcp251x_board_info[] = { { .modalias = "mcp2515", .max_speed_hz = 6500000, .bus_num = 3, .chip_select = 0, - .properties = mcp251x_properties, + .swnode = &mcp251x_node, .controller_data = &mcp251x_chip_info1, .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1) }, @@ -89,7 +93,7 @@ static struct spi_board_info mcp251x_board_info[] = { .max_speed_hz = 6500000, .bus_num = 3, .chip_select = 1, - .properties = mcp251x_properties, + .swnode = &mcp251x_node, .controller_data = &mcp251x_chip_info2, .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2) }, @@ -98,7 +102,7 @@ static struct spi_board_info mcp251x_board_info[] = { .max_speed_hz = 6500000, .bus_num = 4, .chip_select = 0, - .properties = mcp251x_properties, + .swnode = &mcp251x_node, .controller_data = &mcp251x_chip_info3, .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3) }, @@ -107,7 +111,7 @@ static struct spi_board_info mcp251x_board_info[] = { .max_speed_hz = 6500000, .bus_num = 4, .chip_select = 1, - .properties = mcp251x_properties, + .swnode = &mcp251x_node, .controller_data = &mcp251x_chip_info4, .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4) } From patchwork Wed Mar 3 15:28:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 393287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31E9AC43381 for ; Thu, 4 Mar 2021 00:30:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1134A64EDF for ; Thu, 4 Mar 2021 00:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382993AbhCDAah (ORCPT ); Wed, 3 Mar 2021 19:30:37 -0500 Received: from mga12.intel.com ([192.55.52.136]:10027 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383742AbhCCPei (ORCPT ); Wed, 3 Mar 2021 10:34:38 -0500 IronPort-SDR: iLUVgTYScuyBvtvHIkb3AIQ4UWMdh5lHw3sDzOAvlY+kGpzHKbmqm3g822H/EXjTamSk0ELuhP Y3MCxcxNOqlA== X-IronPort-AV: E=McAfee;i="6000,8403,9912"; a="166470335" X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="166470335" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2021 07:28:22 -0800 IronPort-SDR: RPt4lLlzu2fWIoJ14T40IJ8a65oWBlAzUlHbEBWqxWJX18Vw2WSdZLl2iWu2T/bgfWWTxE2LxV PZXGQiNdQ9OA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,220,1610438400"; d="scan'208";a="506827357" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Mar 2021 07:28:20 -0800 From: Heikki Krogerus To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH 3/4] ARM: pxa: zeus: Constify the software node Date: Wed, 3 Mar 2021 18:28:13 +0300 Message-Id: <20210303152814.35070-4-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210303152814.35070-1-heikki.krogerus@linux.intel.com> References: <20210303152814.35070-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org When device properties are supplied to the devices, in reality a software fwnode that holds those properties is created which is then assigned to the device. If the device properties are constant the software node can also be constant. Signed-off-by: Heikki Krogerus Cc: Daniel Mack Cc: Haojian Zhuang Cc: Robert Jarzmik --- arch/arm/mach-pxa/zeus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c index b27fc7ac9ceab..97700429633ee 100644 --- a/arch/arm/mach-pxa/zeus.c +++ b/arch/arm/mach-pxa/zeus.c @@ -433,10 +433,14 @@ static const struct property_entry mcp251x_properties[] = { {} }; +static const struct software_node mcp251x_node = { + .properties = mcp251x_properties, +}; + static struct spi_board_info zeus_spi_board_info[] = { [0] = { .modalias = "mcp2515", - .properties = mcp251x_properties, + .swnode = &mcp251x_node, .irq = PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO), .max_speed_hz = 1*1000*1000, .bus_num = 3,