RE: [PATCH v5 13/26] cxl/port: Store the downstream port's Component Register mappings in struct cxl_dport

From: Dan Williams
Date: Fri Jun 09 2023 - 22:24:01 EST


Terry Bowman wrote:
> From: Robert Richter <rrichter@xxxxxxx>
>
> Same as for ports, also store the downstream port's Component Register
> mappings, use struct cxl_dport for that.
>
> Signed-off-by: Robert Richter <rrichter@xxxxxxx>
> Signed-off-by: Terry Bowman <terry.bowman@xxxxxxx>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> ---
> drivers/cxl/core/port.c | 11 +++++++++++
> drivers/cxl/cxl.h | 2 ++
> 2 files changed, 13 insertions(+)
>
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 305125b193ce..a40d8cefb57d 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -708,6 +708,13 @@ static inline int cxl_port_setup_regs(struct cxl_port *port,
> component_reg_phys);
> }
>
> +static inline int cxl_dport_setup_regs(struct cxl_dport *dport,
> + resource_size_t component_reg_phys)
> +{
> + return cxl_setup_comp_regs(dport->dev, &dport->comp_map,
> + component_reg_phys);
> +}
> +
> static struct cxl_port *__devm_cxl_add_port(struct device *host,
> struct device *uport,
> resource_size_t component_reg_phys,
> @@ -992,6 +999,10 @@ __devm_cxl_add_dport(struct cxl_port *port, struct device *dport_dev,
> dport->component_reg_phys = component_reg_phys;
> dport->port = port;
>
> + rc = cxl_dport_setup_regs(dport, component_reg_phys);
> + if (rc && rc != -ENODEV)
> + return ERR_PTR(rc);

Ah I see that you wanted to share a similar function between this case
and the last patch, but I would still remove one layer of indirection
and make the setup return 0 if there is nothing to do rather than the

if (rc && rc != -ENODEV)

...the stresses out the reader wondering where that special error code
case is generated.

Otherwise, makes sense.