On Thu, Nov 24, 2022 at 10:35:10AM -0800, Dan Williams wrote:
> Accept any cxl_test topology device as the first argument in
> cxl_chbs_context. This is in preparation for reworking the detection of
> the component registers across VH and RCH topologies. Move
> mock_acpi_table_parse_cedt() beneath the definition of is_mock_port()
> and use is_mock_port() instead of the explicit mock cxl_acpi device
> check.

I'll ACK this change, alhtough I don't appreciate the code move and modify
in the same patch. It hides the diff.

The commit msg seems needlessly vague. Why not state what was done?
Something like: 'Accept any topology device in cxl_chbs_context'

> 
> Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
> ---
>  tools/testing/cxl/test/cxl.c |   80 
> +++++++++++++++++++++---------------------
>  1 file changed, 40 insertions(+), 40 deletions(-)
> 
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index facfcd11cb67..42a34650dd2f 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -320,46 +320,6 @@ static int populate_cedt(void)
>       return 0;
>  }
>  
> -/*
> - * WARNING, this hack assumes the format of 'struct
> - * cxl_cfmws_context' and 'struct cxl_chbs_context' share the property that
> - * the first struct member is the device being probed by the cxl_acpi
> - * driver.
> - */
> -struct cxl_cedt_context {
> -     struct device *dev;
> -};
> -
> -static int mock_acpi_table_parse_cedt(enum acpi_cedt_type id,
> -                                   acpi_tbl_entry_handler_arg handler_arg,
> -                                   void *arg)
> -{
> -     struct cxl_cedt_context *ctx = arg;
> -     struct device *dev = ctx->dev;
> -     union acpi_subtable_headers *h;
> -     unsigned long end;
> -     int i;
> -
> -     if (dev != &cxl_acpi->dev)
> -             return acpi_table_parse_cedt(id, handler_arg, arg);
> -
> -     if (id == ACPI_CEDT_TYPE_CHBS)
> -             for (i = 0; i < ARRAY_SIZE(mock_cedt.chbs); i++) {
> -                     h = (union acpi_subtable_headers *)&mock_cedt.chbs[i];
> -                     end = (unsigned long)&mock_cedt.chbs[i + 1];
> -                     handler_arg(h, arg, end);
> -             }
> -
> -     if (id == ACPI_CEDT_TYPE_CFMWS)
> -             for (i = 0; i < ARRAY_SIZE(mock_cfmws); i++) {
> -                     h = (union acpi_subtable_headers *) mock_cfmws[i];
> -                     end = (unsigned long) h + mock_cfmws[i]->header.length;
> -                     handler_arg(h, arg, end);
> -             }
> -
> -     return 0;
> -}
> -
>  static bool is_mock_bridge(struct device *dev)
>  {
>       int i;
> @@ -410,6 +370,46 @@ static bool is_mock_port(struct device *dev)
>       return false;
>  }
>  
> +/*
> + * WARNING, this hack assumes the format of 'struct cxl_cfmws_context'
> + * and 'struct cxl_chbs_context' share the property that the first
> + * struct member is cxl_test device being probed by the cxl_acpi
> + * driver.
> + */
> +struct cxl_cedt_context {
> +     struct device *dev;
> +};
> +
> +static int mock_acpi_table_parse_cedt(enum acpi_cedt_type id,
> +                                   acpi_tbl_entry_handler_arg handler_arg,
> +                                   void *arg)
> +{
> +     struct cxl_cedt_context *ctx = arg;
> +     struct device *dev = ctx->dev;
> +     union acpi_subtable_headers *h;
> +     unsigned long end;
> +     int i;
> +
> +     if (!is_mock_port(dev) && !is_mock_dev(dev))
> +             return acpi_table_parse_cedt(id, handler_arg, arg);
> +
> +     if (id == ACPI_CEDT_TYPE_CHBS)
> +             for (i = 0; i < ARRAY_SIZE(mock_cedt.chbs); i++) {
> +                     h = (union acpi_subtable_headers *)&mock_cedt.chbs[i];
> +                     end = (unsigned long)&mock_cedt.chbs[i + 1];
> +                     handler_arg(h, arg, end);
> +             }
> +
> +     if (id == ACPI_CEDT_TYPE_CFMWS)
> +             for (i = 0; i < ARRAY_SIZE(mock_cfmws); i++) {
> +                     h = (union acpi_subtable_headers *) mock_cfmws[i];
> +                     end = (unsigned long) h + mock_cfmws[i]->header.length;
> +                     handler_arg(h, arg, end);
> +             }
> +
> +     return 0;
> +}
> +
>  static int host_bridge_index(struct acpi_device *adev)
>  {
>       return adev - host_bridge;
> 

Reply via email to