[5/7] cxl/mem: Move device register setup

Message ID 20210407222625.320177-6-ben.widawsky@intel.com
State New
Headers show
Series
  • Enumerate HDM Decoder registers
Related show

Commit Message

Ben Widawsky April 7, 2021, 10:26 p.m.
Support expansion of register block types that the driver will attempt
to recognize by pulling the code up into the register block scanning
loop. Subsequent code can easily add in new register block types with
this.

Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>
---
 drivers/cxl/mem.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Jonathan Cameron April 8, 2021, 5:28 p.m. | #1
On Wed, 7 Apr 2021 15:26:23 -0700
Ben Widawsky <ben.widawsky@intel.com> wrote:

> Support expansion of register block types that the driver will attempt

> to recognize by pulling the code up into the register block scanning

> loop. Subsequent code can easily add in new register block types with

> this.

> 

> Signed-off-by: Ben Widawsky <ben.widawsky@intel.com>


Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>>


> ---

>  drivers/cxl/mem.c | 19 +++++++++----------

>  1 file changed, 9 insertions(+), 10 deletions(-)

> 

> diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c

> index 60b95c524c3e..49f651694cb0 100644

> --- a/drivers/cxl/mem.c

> +++ b/drivers/cxl/mem.c

> @@ -1020,6 +1020,15 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm)

>  			base = cxl_mem_map_regblock(cxlm, reg_lo, reg_hi);

>  			if (IS_ERR(base))

>  				return PTR_ERR(base);

> +

> +			cxl_setup_device_regs(dev, base, &regs->device_regs);

> +			if (!regs->status || !regs->mbox || !regs->memdev) {

> +				dev_err(dev, "registers not found: %s%s%s\n",

> +						!regs->status ? "status " : "",

> +						!regs->mbox ? "mbox " : "",

> +						!regs->memdev ? "memdev" : "");

> +				return -ENXIO;

> +			}

>  			break;

>  		}

>  	}

> @@ -1029,16 +1038,6 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm)

>  		return -ENXIO;

>  	}

>  

> -	cxl_setup_device_regs(dev, base, &regs->device_regs);

> -

> -	if (!regs->status || !regs->mbox || !regs->memdev) {

> -		dev_err(dev, "registers not found: %s%s%s\n",

> -			!regs->status ? "status " : "",

> -			!regs->mbox ? "mbox " : "",

> -			!regs->memdev ? "memdev" : "");

> -		return -ENXIO;

> -	}

> -

>  	return 0;

>  }

>

Patch

diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
index 60b95c524c3e..49f651694cb0 100644
--- a/drivers/cxl/mem.c
+++ b/drivers/cxl/mem.c
@@ -1020,6 +1020,15 @@  static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
 			base = cxl_mem_map_regblock(cxlm, reg_lo, reg_hi);
 			if (IS_ERR(base))
 				return PTR_ERR(base);
+
+			cxl_setup_device_regs(dev, base, &regs->device_regs);
+			if (!regs->status || !regs->mbox || !regs->memdev) {
+				dev_err(dev, "registers not found: %s%s%s\n",
+						!regs->status ? "status " : "",
+						!regs->mbox ? "mbox " : "",
+						!regs->memdev ? "memdev" : "");
+				return -ENXIO;
+			}
 			break;
 		}
 	}
@@ -1029,16 +1038,6 @@  static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
 		return -ENXIO;
 	}
 
-	cxl_setup_device_regs(dev, base, &regs->device_regs);
-
-	if (!regs->status || !regs->mbox || !regs->memdev) {
-		dev_err(dev, "registers not found: %s%s%s\n",
-			!regs->status ? "status " : "",
-			!regs->mbox ? "mbox " : "",
-			!regs->memdev ? "memdev" : "");
-		return -ENXIO;
-	}
-
 	return 0;
 }