Re: [PATCH] testing/cxl: Fix abused pci_bus_read_config_word() on platform device

From: Dan Williams
Date: Mon Oct 21 2024 - 16:43:47 EST


Zhijian Li (Fujitsu) wrote:
> Hey Dan,
>
> Thanks for your review...
>
> I want to confirm with you
[..]
>
> Just to confirm, do you mean add device type check to drivers/cxl/core/cdat.c
>
> --- a/drivers/cxl/core/cdat.c
> +++ b/drivers/cxl/core/cdat.c
> @@ -5,6 +5,7 @@
> #include <linux/fw_table.h>
> #include <linux/node.h>
> #include <linux/overflow.h>
> +#include <linux/platform_device.h>
> #include "cxlpci.h"
> #include "cxlmem.h"
> #include "core.h"
> @@ -641,9 +642,13 @@ static int cxl_endpoint_gather_bandwidth(struct cxl_region *cxlr,
> void *ptr;
> int rc;
>
> + if (dev_is_pci(cxlds->dev))
> + return -ENODEV;
> +
> if (cxlds->rcd)
> return -ENODEV;
>

Yes, this one looks good to me. Place the determination as far out into
a leaf function as possible.