diff mbox series

[v1,1/1] thunderbolt: Do not dereference fwnode in struct device

Message ID 20211207154143.11477-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Commit fea783e6e82c9f3713aea425eddcac9611c069ee
Headers show
Series [v1,1/1] thunderbolt: Do not dereference fwnode in struct device | expand

Commit Message

Andy Shevchenko Dec. 7, 2021, 3:41 p.m. UTC
In order to make the underneath API easier to change in the future,
prevent users from dereferencing fwnode from struct device.
Instead, use the specific dev_fwnode() API for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/thunderbolt/acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andy Shevchenko Dec. 7, 2021, 3:49 p.m. UTC | #1
On Tue, Dec 07, 2021 at 05:41:43PM +0200, Andy Shevchenko wrote:
> In order to make the underneath API easier to change in the future,
> prevent users from dereferencing fwnode from struct device.
> Instead, use the specific dev_fwnode() API for that.

...

>  	/* It needs to reference this NHI */
> -	if (nhi->pdev->dev.fwnode != args.fwnode)
> +	if (dev_fwnode(&nhi->pdev->dev) != args.fwnode)

Alternatively:

	if (!device_match_fwnode(&nhi->pdev->dev, args.fwnode))

Tell me. which one you prefer.

>  		goto out_put;
Mika Westerberg Dec. 8, 2021, 10:26 a.m. UTC | #2
On Tue, Dec 07, 2021 at 05:41:43PM +0200, Andy Shevchenko wrote:
> In order to make the underneath API easier to change in the future,
> prevent users from dereferencing fwnode from struct device.
> Instead, use the specific dev_fwnode() API for that.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

This version is fine. Applied to thunderbolt.git/next, thanks!
diff mbox series

Patch

diff --git a/drivers/thunderbolt/acpi.c b/drivers/thunderbolt/acpi.c
index b67e72d5644b..861d0fafb1d9 100644
--- a/drivers/thunderbolt/acpi.c
+++ b/drivers/thunderbolt/acpi.c
@@ -31,7 +31,7 @@  static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
 		return AE_OK;
 
 	/* It needs to reference this NHI */
-	if (nhi->pdev->dev.fwnode != args.fwnode)
+	if (dev_fwnode(&nhi->pdev->dev) != args.fwnode)
 		goto out_put;
 
 	/*