i2c: tegra: Set ACPI node as primary fwnode
PATCH 1/1 i2c: tegra: Set ACPI node as primary fwnode
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
--- drivers/i2c/busses/i2c-tegra.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-tegra.c +1 -0
@@ -1826,6 +1826,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) i2c_dev->adapter.class =I2C_CLASS_DEPRECATED ; i2c_dev->adapter.algo = &tegra_i2c_algo; i2c_dev->adapter.nr = pdev->id; +ACPI_COMPANION_SET (&i2c_dev->adapter.dev,ACPI_COMPANION (&pdev->dev));if (i2c_dev->hw->supports_bus_clear) i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info;
Signature · 1 line
2.17.1
Quoted 8 lines · Akhil R
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
Signed-off-by Zubair Waheed <[email protected]>Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 1 + 1 file changed, 1 insertion(+)
Jon Hunter
maintainerQuoted 14 lines · Akhil R
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
Signed-off-by Zubair Waheed <[email protected]>Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 1 + 1 file changed, 1 insertion(+)drivers/i2c/busses/i2c-tegra.c +0
-0
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device *pdev) · line 1832
Quoted 7 lines
drivers/i2c/busses/i2c-tegra.c +1
-0@@ -1826,6 +1826,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) i2c_dev->adapter.class =I2C_CLASS_DEPRECATED ; i2c_dev->adapter.algo = &tegra_i2c_algo; i2c_dev->adapter.nr = pdev->id; +ACPI_COMPANION_SET (&i2c_dev->adapter.dev,ACPI_COMPANION (&pdev->dev));if (i2c_dev->hw->supports_bus_clear) i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info;
Do we always want to set as the primary fwnode even when booting with device-tree? I some other drivers do, but I also see some others ...
if (has_acpi_companion(dev))
ACPI_COMPANION_SET(&i2c_dev->adapter.dev,
ACPI_COMPANION(&pdev->dev));It would be nice to know why it is OK to always do this even for device-tree because it is not clear to me.
Jon
Signature · 1 line
nvpublic
Quoted 27 lines · Jon Hunter
Quoted 14 lines · Akhil R
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
Signed-off-by Zubair Waheed <[email protected]>Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 1 + 1 file changed, 1 insertion(+)drivers/i2c/busses/i2c-tegra.c +0
-0drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device *pdev) · line 1831
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +1
-0@@ -1826,6 +1826,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) i2c_dev->adapter.class =I2C_CLASS_DEPRECATED ; i2c_dev->adapter.algo = &tegra_i2c_algo; i2c_dev->adapter.nr = pdev->id; +ACPI_COMPANION_SET (&i2c_dev->adapter.dev,ACPI_COMPANION (&pdev->dev));if (i2c_dev->hw->supports_bus_clear) i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info;Do we always want to set as the primary fwnode even when booting with device-tree? I some other drivers do, but I also see some others ...
Quoted 6 lines
if (
has_acpi_companion(dev))ACPI_COMPANION_SET(&i2c_dev->adapter.dev, ACPI_COMPANION(&pdev->dev));It would be nice to know why it is OK to always do this even for device-tree because it is not clear to me.
ACPI_COMPANION() returns NULL if there is no ACPI companion, which will cause ACPI_COMPANION_SET() to set the primary fwnode to NULL. If I read the code for set_primary_fwnode() correctly, that's essentially a no-op for DT devices.
I guess that the extra check might save a few cycles by not having to run through all the various conditionals, but it seems a rather minor saving.
Either way is fine with me, though.
Thierry
Jon Hunter
maintainerQuoted 32 lines · Thierry Reding
Quoted 31 lines · Jon Hunter
Quoted 14 lines · Akhil R
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
Signed-off-by Zubair Waheed <[email protected]>Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 1 + 1 file changed, 1 insertion(+)drivers/i2c/busses/i2c-tegra.c +0
-0drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device *pdev) · line 1831
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +1
-0@@ -1826,6 +1826,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) i2c_dev->adapter.class =I2C_CLASS_DEPRECATED ; i2c_dev->adapter.algo = &tegra_i2c_algo; i2c_dev->adapter.nr = pdev->id; +ACPI_COMPANION_SET (&i2c_dev->adapter.dev,ACPI_COMPANION (&pdev->dev));if (i2c_dev->hw->supports_bus_clear) i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info;Do we always want to set as the primary fwnode even when booting with device-tree? I some other drivers do, but I also see some others ...
if (has_acpi_companion(dev)) ACPI_COMPANION_SET(&i2c_dev->adapter.dev, ACPI_COMPANION(&pdev->dev));
Quoted 7 lines
Quoted 2 lines
It would be nice to know why it is OK to always do this even for device-tree because it is not clear to me.
ACPI_COMPANION()returns NULL if there is no ACPI companion, which will causeACPI_COMPANION_SET()to set the primary fwnode to NULL. If I read the code forset_primary_fwnode()correctly, that's essentially a no-op for DT devices.
Yes it does, but doesn't it is not clear to me if it is a good idea to pass NULL to set_primary_fwnode(). It does seem to handle this but my biggest gripe is the lack of explanation in the commit message why this is OK.
Jon
Signature · 1 line
nvpublic
Quoted 44 lines · Thierry Reding
Quoted 12 lines · Jon Hunter
Quoted 11 lines · Akhil R
Quoted 9 lines
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
Signed-off-by Zubair Waheed <[email protected]>Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 1 + 1 file changed, 1 insertion(+)Quoted 5 lines
Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device
Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c +0
-0@@ -1826,6 +1826,7 @@ static int tegra_i2c_probe(struct platform_device*pdev)
Quoted 4 lines
Quoted 4 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device *pdev)
Quoted 4 lines
drivers/i2c/busses/i2c-tegra.c +1
-0i2c_dev->adapter.class =I2C_CLASS_DEPRECATED ; i2c_dev->adapter.algo = &tegra_i2c_algo; i2c_dev->adapter.nr = pdev->id; + ACPI_COMPANION_SET(&i2c_dev->adapter.dev,
ACPI_COMPANION(&pdev->dev));Quoted 2 lines
Quoted 2 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device · line 1831
Quoted 2 lines
drivers/i2c/busses/i2c-tegra.c +0
-0if (i2c_dev->hw->supports_bus_clear) i2c_dev->adapter.bus_recovery_info =
&tegra_i2c_recovery_info;Quoted 9 lines
Quoted 9 lines
Do we always want to set as the primary fwnode even when booting with device-tree? I some other drivers do, but I also see some others ...
if (has_acpi_companion(dev)) ACPI_COMPANION_SET(&i2c_dev->adapter.dev, ACPI_COMPANION(&pdev->dev));Quoted 7 lines
Quoted 2 lines
It would be nice to know why it is OK to always do this even for device-tree because it is not clear to me.
ACPI_COMPANION()returns NULL if there is no ACPI companion, which will causeACPI_COMPANION_SET()to set the primary fwnode to NULL. If I read the code forset_primary_fwnode()correctly, that's essentially a no-op for DT devices.
Quoted 4 lines
Yes it does, but doesn't it is not clear to me if it is a good idea to pass NULL to
set_primary_fwnode(). It does seem to handle this but my biggest gripe is the lack of explanation in the commit message why this is OK.
I saw ACPI_COMPANION_SET() as an empty function if CONFIG_ACPI is not set. Yes, I agree that I should have mentioned this in the commit message. Shall I send a v2 with the details added in the commit description?
Regards,
Akhil
Jon Hunter
maintainerQuoted 44 lines · Akhil R
Quoted 44 lines · Thierry Reding
Quoted 12 lines · Jon Hunter
Quoted 11 lines · Akhil R
Quoted 9 lines
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
Signed-off-by Zubair Waheed <[email protected]>Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 1 + 1 file changed, 1 insertion(+)Quoted 5 lines
Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device
Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c +0
-0@@ -1826,6 +1826,7 @@ static int tegra_i2c_probe(struct platform_device*pdev)
Quoted 4 lines
Quoted 4 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device *pdev)
Quoted 4 lines
drivers/i2c/busses/i2c-tegra.c +1
-0i2c_dev->adapter.class =I2C_CLASS_DEPRECATED ; i2c_dev->adapter.algo = &tegra_i2c_algo; i2c_dev->adapter.nr = pdev->id; + ACPI_COMPANION_SET(&i2c_dev->adapter.dev,
ACPI_COMPANION(&pdev->dev));Quoted 2 lines
Quoted 2 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_probe(struct platform_device · line 1831
Quoted 2 lines
drivers/i2c/busses/i2c-tegra.c +0
-0if (i2c_dev->hw->supports_bus_clear) i2c_dev->adapter.bus_recovery_info =
&tegra_i2c_recovery_info;Quoted 16 lines
Quoted 11 lines
Do we always want to set as the primary fwnode even when booting with device-tree? I some other drivers do, but I also see some others ...
if (has_acpi_companion(dev)) ACPI_COMPANION_SET(&i2c_dev->adapter.dev, ACPI_COMPANION(&pdev->dev));It would be nice to know why it is OK to always do this even for device-tree because it is not clear to me.
ACPI_COMPANION()returns NULL if there is no ACPI companion, which will causeACPI_COMPANION_SET()to set the primary fwnode to NULL. If I read the code forset_primary_fwnode()correctly, that's essentially a no-op for DT devices.
Quoted 5 lines
Quoted 4 lines
Yes it does, but doesn't it is not clear to me if it is a good idea to pass NULL to
set_primary_fwnode(). It does seem to handle this but my biggest gripe is the lack of explanation in the commit message why this is OK.I saw
ACPI_COMPANION_SET()as an empty function ifCONFIG_ACPIis not set.
That's not the issue. By default CONFIG_ACPI is enabled for arm64 but for Tegra we typically boot with device-tree. So I was more concerned about the case where ACPI_COMPANION_SET() is not an empty function.
Quoted 2 lines
Yes, I agree that I should have mentioned this in the commit message. Shall I send a v2 with the details added in the commit description?
No need, especially as Thierry has already applied. I am not familiar with this function and primary/secondary fwnodes so wanted to understand there is no issue for device tree.
Jon
Signature · 1 line
nvpublic
Wolfram Sang
AppliedQuoted 5 lines · Akhil R
Set ACPI node as the primary fwnode of I2C adapter to allow enumeration of child devices from the ACPI table
Signed-off-by Zubair Waheed <[email protected]>Signed-off-by Akhil R <[email protected]>
Applied to for-next, thanks!