From: Robert Richter <[email protected]>
The component registers of a component may not exist or are not
needed. The setup may fail for that reason. In some cases the
initialization should continue anyway. Thus, always initialize struct
cxl_register_map with valid values. In case of errors, zero it, set a
value for @dev and make @resource a the valid value using
CXL_RESOURCE_NONE.
Signed-off-by: Robert Richter <[email protected]>
Signed-off-by: Terry Bowman <[email protected]>
---
drivers/cxl/core/port.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 724be8448eb4..2d22e7a5629b 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -693,16 +693,17 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev,
static int cxl_setup_comp_regs(struct device *dev, struct cxl_register_map *map,
resource_size_t component_reg_phys)
{
- if (component_reg_phys == CXL_RESOURCE_NONE)
- return 0;
-
*map = (struct cxl_register_map) {
.dev = dev,
- .reg_type = CXL_REGLOC_RBI_COMPONENT,
.resource = component_reg_phys,
- .max_size = CXL_COMPONENT_REG_BLOCK_SIZE,
};
+ if (component_reg_phys == CXL_RESOURCE_NONE)
+ return 0;
+
+ map->reg_type = CXL_REGLOC_RBI_COMPONENT;
+ map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE;
+
return cxl_setup_regs(map);
}
--
2.34.1
On Fri, 30 Jun 2023 18:16:22 -0500
Terry Bowman <[email protected]> wrote:
> From: Robert Richter <[email protected]>
>
> The component registers of a component may not exist or are not
> needed. The setup may fail for that reason. In some cases the
> initialization should continue anyway. Thus, always initialize struct
> cxl_register_map with valid values. In case of errors, zero it, set a
> value for @dev and make @resource a the valid value using
> CXL_RESOURCE_NONE.
>
> Signed-off-by: Robert Richter <[email protected]>
> Signed-off-by: Terry Bowman <[email protected]>
Seems reasonable to me.
Reviewed-by: Jonathan Cameron <[email protected]>
> ---
> drivers/cxl/core/port.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 724be8448eb4..2d22e7a5629b 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -693,16 +693,17 @@ static struct cxl_port *cxl_port_alloc(struct device *uport_dev,
> static int cxl_setup_comp_regs(struct device *dev, struct cxl_register_map *map,
> resource_size_t component_reg_phys)
> {
> - if (component_reg_phys == CXL_RESOURCE_NONE)
> - return 0;
> -
> *map = (struct cxl_register_map) {
> .dev = dev,
> - .reg_type = CXL_REGLOC_RBI_COMPONENT,
> .resource = component_reg_phys,
> - .max_size = CXL_COMPONENT_REG_BLOCK_SIZE,
> };
>
> + if (component_reg_phys == CXL_RESOURCE_NONE)
> + return 0;
> +
> + map->reg_type = CXL_REGLOC_RBI_COMPONENT;
> + map->max_size = CXL_COMPONENT_REG_BLOCK_SIZE;
> +
> return cxl_setup_regs(map);
> }
>