Re: [PATCH 09/18] cxl: Add helper function to retrieve ACPI handle of CXL root device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 06 Feb 2023 13:50:42 -0700
Dave Jiang <dave.jiang@xxxxxxxxx> wrote:

> Provide a helper to find the ACPI0017 device in order to issue the _DSM.
> The helper will take the 'struct device' from a cxl_port and iterate until
> the root device is reached. The ACPI handle will be returned from the root
> device.
> 
> Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx>
> ---
>  drivers/cxl/core/acpi.c |   30 ++++++++++++++++++++++++++++++
>  drivers/cxl/cxl.h       |    1 +
>  2 files changed, 31 insertions(+)
> 
> diff --git a/drivers/cxl/core/acpi.c b/drivers/cxl/core/acpi.c
> index 86dc6c9c1f24..05fcd4751619 100644
> --- a/drivers/cxl/core/acpi.c
> +++ b/drivers/cxl/core/acpi.c
> @@ -5,6 +5,7 @@
>  #include <linux/kernel.h>
>  #include <linux/acpi.h>
>  #include <linux/pci.h>
> +#include <linux/platform_device.h>
>  #include <asm/div64.h>
>  #include "cxlpci.h"
>  #include "cxl.h"
> @@ -13,6 +14,35 @@ const guid_t acpi_cxl_qtg_id_guid =
>  	GUID_INIT(0xF365F9A6, 0xA7DE, 0x4071,
>  		  0xA6, 0x6A, 0xB4, 0x0C, 0x0B, 0x4F, 0x8E, 0x52);
>  
> +/**
> + * cxl_acpi_get_root_acpi_handle - get the ACPI handle of the CXL root device
> + * @dev: 'struct device' to start searching from. Should be from cxl_port->dev.
> + * Looks for the ACPI0017 device and return the ACPI handle
> + **/

Inconsistent comment style.

> +acpi_handle cxl_acpi_get_rootdev_handle(struct device *dev)
> +{
> +	struct device *itr = dev, *root_dev;

Not nice for readability to have an assignment in a list of definitions
all on the same line.

> +	acpi_handle handle;
> +
> +	if (!dev)
> +		return ERR_PTR(-EINVAL);
> +
> +	while (itr->parent) {
> +		root_dev = itr;
> +		itr = itr->parent;
> +	}
> +
> +	if (!dev_is_platform(root_dev))
> +		return ERR_PTR(-ENODEV);
> +
> +	handle = ACPI_HANDLE(root_dev);
> +	if (!handle)
> +		return ERR_PTR(-ENODEV);
> +
> +	return handle;
> +}
> +EXPORT_SYMBOL_NS_GPL(cxl_acpi_get_rootdev_handle, CXL);
> +
>  /**
>   * cxl_acpi_evaluate_qtg_dsm - Retrieve QTG ids via ACPI _DSM
>   * @handle: ACPI handle
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index e70df07f9b4b..ac6ea550ab0a 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -733,6 +733,7 @@ struct qtg_dsm_output {
>  
>  struct qtg_dsm_output *cxl_acpi_evaluate_qtg_dsm(acpi_handle handle,
>  						 struct qtg_dsm_input *input);
> +acpi_handle cxl_acpi_get_rootdev_handle(struct device *dev);
>  
>  /*
>   * Unit test builds overrides this to __weak, find the 'strong' version
> 
> 




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux