public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] ACPI: VIOT: Do not dereference fwnode in struct device
@ 2022-08-02 19:35 Andy Shevchenko
  2022-08-03 10:03 ` Eric Auger
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-08-02 19:35 UTC (permalink / raw)
  To: Eric Auger, linux-acpi, iommu, linux-kernel
  Cc: Jean-Philippe Brucker, Rafael J. Wysocki, Len Brown,
	Andy Shevchenko

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() and device_match_fwnode()
APIs for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/viot.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c
index 647f11cf165d..6132092dab2a 100644
--- a/drivers/acpi/viot.c
+++ b/drivers/acpi/viot.c
@@ -88,7 +88,7 @@ static int __init viot_get_pci_iommu_fwnode(struct viot_iommu *viommu,
 		return -ENODEV;
 	}
 
-	fwnode = pdev->dev.fwnode;
+	fwnode = dev_fwnode(&pdev->dev);
 	if (!fwnode) {
 		/*
 		 * PCI devices aren't necessarily described by ACPI. Create a
@@ -101,7 +101,7 @@ static int __init viot_get_pci_iommu_fwnode(struct viot_iommu *viommu,
 		}
 		set_primary_fwnode(&pdev->dev, fwnode);
 	}
-	viommu->fwnode = pdev->dev.fwnode;
+	viommu->fwnode = dev_fwnode(&pdev->dev);
 	pci_dev_put(pdev);
 	return 0;
 }
@@ -314,7 +314,7 @@ static int viot_dev_iommu_init(struct device *dev, struct viot_iommu *viommu,
 		return -ENODEV;
 
 	/* We're not translating ourself */
-	if (viommu->fwnode == dev->fwnode)
+	if (device_match_fwnode(dev, viommu->fwnode))
 		return -EINVAL;
 
 	ops = iommu_ops_from_fwnode(viommu->fwnode);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] ACPI: VIOT: Do not dereference fwnode in struct device
  2022-08-02 19:35 [PATCH v1 1/1] ACPI: VIOT: Do not dereference fwnode in struct device Andy Shevchenko
@ 2022-08-03 10:03 ` Eric Auger
  2022-08-08 17:31   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Auger @ 2022-08-03 10:03 UTC (permalink / raw)
  To: Andy Shevchenko, linux-acpi, iommu, linux-kernel
  Cc: Jean-Philippe Brucker, Rafael J. Wysocki, Len Brown

Hi Andy,

On 8/2/22 21:35, 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() and device_match_fwnode()
> APIs for that.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  drivers/acpi/viot.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c
> index 647f11cf165d..6132092dab2a 100644
> --- a/drivers/acpi/viot.c
> +++ b/drivers/acpi/viot.c
> @@ -88,7 +88,7 @@ static int __init viot_get_pci_iommu_fwnode(struct viot_iommu *viommu,
>  		return -ENODEV;
>  	}
>  
> -	fwnode = pdev->dev.fwnode;
> +	fwnode = dev_fwnode(&pdev->dev);
>  	if (!fwnode) {
>  		/*
>  		 * PCI devices aren't necessarily described by ACPI. Create a
> @@ -101,7 +101,7 @@ static int __init viot_get_pci_iommu_fwnode(struct viot_iommu *viommu,
>  		}
>  		set_primary_fwnode(&pdev->dev, fwnode);
>  	}
> -	viommu->fwnode = pdev->dev.fwnode;
> +	viommu->fwnode = dev_fwnode(&pdev->dev);
>  	pci_dev_put(pdev);
>  	return 0;
>  }
> @@ -314,7 +314,7 @@ static int viot_dev_iommu_init(struct device *dev, struct viot_iommu *viommu,
>  		return -ENODEV;
>  
>  	/* We're not translating ourself */
> -	if (viommu->fwnode == dev->fwnode)
> +	if (device_match_fwnode(dev, viommu->fwnode))
>  		return -EINVAL;
>  
>  	ops = iommu_ops_from_fwnode(viommu->fwnode);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] ACPI: VIOT: Do not dereference fwnode in struct device
  2022-08-03 10:03 ` Eric Auger
@ 2022-08-08 17:31   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-08-08 17:31 UTC (permalink / raw)
  To: Eric Auger, Andy Shevchenko
  Cc: ACPI Devel Maling List, iommu, Linux Kernel Mailing List,
	Jean-Philippe Brucker, Rafael J. Wysocki, Len Brown

On Wed, Aug 3, 2022 at 12:03 PM Eric Auger <eric.auger@redhat.com> wrote:
>
> Hi Andy,
>
> On 8/2/22 21:35, 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() and device_match_fwnode()
> > APIs for that.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Eric Auger <eric.auger@redhat.com>

Applied, thanks!

> > ---
> >  drivers/acpi/viot.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/acpi/viot.c b/drivers/acpi/viot.c
> > index 647f11cf165d..6132092dab2a 100644
> > --- a/drivers/acpi/viot.c
> > +++ b/drivers/acpi/viot.c
> > @@ -88,7 +88,7 @@ static int __init viot_get_pci_iommu_fwnode(struct viot_iommu *viommu,
> >               return -ENODEV;
> >       }
> >
> > -     fwnode = pdev->dev.fwnode;
> > +     fwnode = dev_fwnode(&pdev->dev);
> >       if (!fwnode) {
> >               /*
> >                * PCI devices aren't necessarily described by ACPI. Create a
> > @@ -101,7 +101,7 @@ static int __init viot_get_pci_iommu_fwnode(struct viot_iommu *viommu,
> >               }
> >               set_primary_fwnode(&pdev->dev, fwnode);
> >       }
> > -     viommu->fwnode = pdev->dev.fwnode;
> > +     viommu->fwnode = dev_fwnode(&pdev->dev);
> >       pci_dev_put(pdev);
> >       return 0;
> >  }
> > @@ -314,7 +314,7 @@ static int viot_dev_iommu_init(struct device *dev, struct viot_iommu *viommu,
> >               return -ENODEV;
> >
> >       /* We're not translating ourself */
> > -     if (viommu->fwnode == dev->fwnode)
> > +     if (device_match_fwnode(dev, viommu->fwnode))
> >               return -EINVAL;
> >
> >       ops = iommu_ops_from_fwnode(viommu->fwnode);
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-08 17:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-02 19:35 [PATCH v1 1/1] ACPI: VIOT: Do not dereference fwnode in struct device Andy Shevchenko
2022-08-03 10:03 ` Eric Auger
2022-08-08 17:31   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox