diff mbox series

drm/amd: Use pci_dev_id() to simplify the code

Message ID 20230807131759.107914-1-wangxiongfeng2@huawei.com (mailing list archive)
State New, archived
Headers show
Series drm/amd: Use pci_dev_id() to simplify the code | expand

Commit Message

Xiongfeng Wang Aug. 7, 2023, 1:17 p.m. UTC
PCI core API pci_dev_id() can be used to get the BDF number for a pci
device. We don't need to compose it mannually. Use pci_dev_id() to
simplify the code a little bit.

Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Alex Deucher Aug. 8, 2023, 5:50 p.m. UTC | #1
Applied.  Thanks!

Alex

On Mon, Aug 7, 2023 at 9:22 AM Xiongfeng Wang <wangxiongfeng2@huawei.com> wrote:
>
> PCI core API pci_dev_id() can be used to get the BDF number for a pci
> device. We don't need to compose it mannually. Use pci_dev_id() to
> simplify the code a little bit.
>
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> index 385c6acb5728..aee0cfdc6da3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
> @@ -706,7 +706,7 @@ int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,
>
>         atcs_input.size = sizeof(struct atcs_pref_req_input);
>         /* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
> -       atcs_input.client_id = adev->pdev->devfn | (adev->pdev->bus->number << 8);
> +       atcs_input.client_id = pci_dev_id(adev->pdev);
>         atcs_input.valid_flags_mask = ATCS_VALID_FLAGS_MASK;
>         atcs_input.flags = ATCS_WAIT_FOR_COMPLETION;
>         if (advertise)
> @@ -776,7 +776,7 @@ int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev,
>
>         atcs_input.size = sizeof(struct atcs_pwr_shift_input);
>         /* dGPU id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
> -       atcs_input.dgpu_id = adev->pdev->devfn | (adev->pdev->bus->number << 8);
> +       atcs_input.dgpu_id = pci_dev_id(adev->pdev);
>         atcs_input.dev_acpi_state = dev_state;
>         atcs_input.drv_state = drv_state;
>
> @@ -1141,7 +1141,7 @@ int amdgpu_acpi_get_tmr_info(struct amdgpu_device *adev, u64 *tmr_offset,
>         if (!tmr_offset || !tmr_size)
>                 return -EINVAL;
>
> -       bdf = (adev->pdev->bus->number << 8) | adev->pdev->devfn;
> +       bdf = pci_dev_id(adev->pdev);
>         dev_info = amdgpu_acpi_get_dev(bdf);
>         if (!dev_info)
>                 return -ENOENT;
> @@ -1162,7 +1162,7 @@ int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
>         if (!numa_info)
>                 return -EINVAL;
>
> -       bdf = (adev->pdev->bus->number << 8) | adev->pdev->devfn;
> +       bdf = pci_dev_id(adev->pdev);
>         dev_info = amdgpu_acpi_get_dev(bdf);
>         if (!dev_info)
>                 return -ENOENT;
> --
> 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
index 385c6acb5728..aee0cfdc6da3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
@@ -706,7 +706,7 @@  int amdgpu_acpi_pcie_performance_request(struct amdgpu_device *adev,
 
 	atcs_input.size = sizeof(struct atcs_pref_req_input);
 	/* client id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
-	atcs_input.client_id = adev->pdev->devfn | (adev->pdev->bus->number << 8);
+	atcs_input.client_id = pci_dev_id(adev->pdev);
 	atcs_input.valid_flags_mask = ATCS_VALID_FLAGS_MASK;
 	atcs_input.flags = ATCS_WAIT_FOR_COMPLETION;
 	if (advertise)
@@ -776,7 +776,7 @@  int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev,
 
 	atcs_input.size = sizeof(struct atcs_pwr_shift_input);
 	/* dGPU id (bit 2-0: func num, 7-3: dev num, 15-8: bus num) */
-	atcs_input.dgpu_id = adev->pdev->devfn | (adev->pdev->bus->number << 8);
+	atcs_input.dgpu_id = pci_dev_id(adev->pdev);
 	atcs_input.dev_acpi_state = dev_state;
 	atcs_input.drv_state = drv_state;
 
@@ -1141,7 +1141,7 @@  int amdgpu_acpi_get_tmr_info(struct amdgpu_device *adev, u64 *tmr_offset,
 	if (!tmr_offset || !tmr_size)
 		return -EINVAL;
 
-	bdf = (adev->pdev->bus->number << 8) | adev->pdev->devfn;
+	bdf = pci_dev_id(adev->pdev);
 	dev_info = amdgpu_acpi_get_dev(bdf);
 	if (!dev_info)
 		return -ENOENT;
@@ -1162,7 +1162,7 @@  int amdgpu_acpi_get_mem_info(struct amdgpu_device *adev, int xcc_id,
 	if (!numa_info)
 		return -EINVAL;
 
-	bdf = (adev->pdev->bus->number << 8) | adev->pdev->devfn;
+	bdf = pci_dev_id(adev->pdev);
 	dev_info = amdgpu_acpi_get_dev(bdf);
 	if (!dev_info)
 		return -ENOENT;