diff mbox

[1/2] spi: dw: Initialize of_node to discover DT node children

Message ID 1412711297-31857-2-git-send-email-tthayer@opensource.altera.com
State New, archived
Headers show

Commit Message

tthayer@opensource.altera.com Oct. 7, 2014, 7:48 p.m. UTC
From: Thor Thayer <tthayer@opensource.altera.com>

1. The of_node element must be initialized to enable discovery of node
children. The discovery takes place in the of_register_spi_devices() function.
2. Grabbing the bus-num from the device tree.
3. Update the SOCFPGA configuration.

Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
---
 arch/arm/configs/socfpga_defconfig |    1 +
 drivers/spi/spi-dw-mmio.c          |    5 ++++-
 drivers/spi/spi-dw.c               |    3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

Comments

dinguyen@opensource.altera.com Oct. 7, 2014, 7:42 p.m. UTC | #1
On 10/07/2014 02:48 PM, tthayer@opensource.altera.com wrote:
> From: Thor Thayer <tthayer@opensource.altera.com>
> 
> 1. The of_node element must be initialized to enable discovery of node
> children. The discovery takes place in the of_register_spi_devices() function.
> 2. Grabbing the bus-num from the device tree.
> 3. Update the SOCFPGA configuration.

updating the socfpga_defconfig should be a separate patch.

Dinh
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
tthayer@opensource.altera.com Oct. 7, 2014, 7:55 p.m. UTC | #2
On 10/07/2014 02:42 PM, Dinh Nguyen wrote:
> On 10/07/2014 02:48 PM, tthayer@opensource.altera.com wrote:
>> From: Thor Thayer <tthayer@opensource.altera.com>
>>
>> 1. The of_node element must be initialized to enable discovery of node
>> children. The discovery takes place in the of_register_spi_devices() function.
>> 2. Grabbing the bus-num from the device tree.
>> 3. Update the SOCFPGA configuration.
> updating the socfpga_defconfig should be a separate patch.
>
> Dinh
OK, I will remove it. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown Oct. 7, 2014, 8:40 p.m. UTC | #3
On Tue, Oct 07, 2014 at 02:48:16PM -0500, tthayer@opensource.altera.com wrote:
> From: Thor Thayer <tthayer@opensource.altera.com>
> 
> 1. The of_node element must be initialized to enable discovery of node
> children. The discovery takes place in the of_register_spi_devices() function.
> 2. Grabbing the bus-num from the device tree.
> 3. Update the SOCFPGA configuration.

No, each of these should be in a separate patch - it's especially bad to
be updating the defconfig in the same patch as the driver, these changes
should be totally unrelated.
tthayer@opensource.altera.com Oct. 7, 2014, 8:59 p.m. UTC | #4
On 10/07/2014 03:40 PM, Mark Brown wrote:
> On Tue, Oct 07, 2014 at 02:48:16PM -0500, tthayer@opensource.altera.com wrote:
>> From: Thor Thayer <tthayer@opensource.altera.com>
>>
>> 1. The of_node element must be initialized to enable discovery of node
>> children. The discovery takes place in the of_register_spi_devices() function.
>> 2. Grabbing the bus-num from the device tree.
>> 3. Update the SOCFPGA configuration.
> No, each of these should be in a separate patch - it's especially bad to
> be updating the defconfig in the same patch as the driver, these changes
> should be totally unrelated.
OK. I will split these and remove the defconfig.

Dinh pointed the defconfig issue out to me as well.

Thanks for reviewing,

Thor
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko Oct. 8, 2014, 8:17 a.m. UTC | #5
On Tue, 2014-10-07 at 14:48 -0500, tthayer@opensource.altera.com wrote:
> From: Thor Thayer <tthayer@opensource.altera.com>
> 
> 1. The of_node element must be initialized to enable discovery of node
> children. The discovery takes place in the of_register_spi_devices() function.
> 2. Grabbing the bus-num from the device tree.
> 3. Update the SOCFPGA configuration.

[]

> --- a/drivers/spi/spi-dw.c
> +++ b/drivers/spi/spi-dw.c
> @@ -671,6 +671,9 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
>  	master->cleanup = dw_spi_cleanup;
>  	master->transfer_one_message = dw_spi_transfer_one_message;
>  	master->max_speed_hz = dws->max_freq;
> +#if defined(CONFIG_OF)
> +	master->dev.of_node = dev->of_node;
> +#endif

I'm not sure you need this #ifdef surrounded an assignment.
If I'm wrong then you probably have to use if (IS_ENABLED(CONFIG_OF)).
tthayer@opensource.altera.com Oct. 8, 2014, 6:27 p.m. UTC | #6
On 10/08/2014 03:17 AM, Andy Shevchenko wrote:
> On Tue, 2014-10-07 at 14:48 -0500, tthayer@opensource.altera.com wrote:
>> From: Thor Thayer <tthayer@opensource.altera.com>
>>
>> 1. The of_node element must be initialized to enable discovery of node
>> children. The discovery takes place in the of_register_spi_devices() function.
>> 2. Grabbing the bus-num from the device tree.
>> 3. Update the SOCFPGA configuration.
> []
>
>> --- a/drivers/spi/spi-dw.c
>> +++ b/drivers/spi/spi-dw.c
>> @@ -671,6 +671,9 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
>>   	master->cleanup = dw_spi_cleanup;
>>   	master->transfer_one_message = dw_spi_transfer_one_message;
>>   	master->max_speed_hz = dws->max_freq;
>> +#if defined(CONFIG_OF)
>> +	master->dev.of_node = dev->of_node;
>> +#endif
> I'm not sure you need this #ifdef surrounded an assignment.
> If I'm wrong then you probably have to use if (IS_ENABLED(CONFIG_OF)).
>
Hi Andy.

Good point. I will remove those.

Thank you for reviewing.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/configs/socfpga_defconfig b/arch/arm/configs/socfpga_defconfig
index d7a5855..54f3540 100644
--- a/arch/arm/configs/socfpga_defconfig
+++ b/arch/arm/configs/socfpga_defconfig
@@ -52,6 +52,7 @@  CONFIG_CAN_C_CAN_PLATFORM=y
 CONFIG_CAN_DEBUG_DEVICES=y
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_PROC_DEVICETREE=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=2
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index 21ce0e3..b8483057 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -82,7 +82,10 @@  static int dw_spi_mmio_probe(struct platform_device *pdev)
 	dws->num_cs = num_cs;
 
 	if (pdev->dev.of_node) {
-		int i;
+		int i, prop;
+
+		if (!of_property_read_u32(pdev->dev.of_node, "bus-num", &prop))
+			dws->bus_num = prop;
 
 		for (i = 0; i < dws->num_cs; i++) {
 			int cs_gpio = of_get_named_gpio(pdev->dev.of_node,
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 0dd0623..d8be9f9 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -671,6 +671,9 @@  int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 	master->cleanup = dw_spi_cleanup;
 	master->transfer_one_message = dw_spi_transfer_one_message;
 	master->max_speed_hz = dws->max_freq;
+#if defined(CONFIG_OF)
+	master->dev.of_node = dev->of_node;
+#endif
 
 	/* Basic HW init */
 	spi_hw_init(dws);