diff mbox series

[v4,4/5] blkmap: store type of blkmap slice in corresponding structure

Message ID 20250203105912.196654-5-sughosh.ganu@linaro.org
State New
Headers show
Series Add pmem node for preserving distro ISO's | expand

Commit Message

Sughosh Ganu Feb. 3, 2025, 10:59 a.m. UTC
Add information about the type of blkmap slice in the corresponding
slice structure. Put information in the blkmap slice structure to
identify if it is associated with a memory or linear mapped
device. Which can then be used to take specific action based on the
type of the blkmap slice.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V3:
* Add the map type to the blkmap slice instead of the entire blkmap
  device

 drivers/block/blkmap.c | 4 ++++
 include/blkmap.h       | 6 ++++++
 2 files changed, 10 insertions(+)

Comments

Ilias Apalodimas Feb. 21, 2025, 6:39 p.m. UTC | #1
Hi Tobias,

This looks ok to me, but OTOH I haven't been involved with blkmap too much.

On Mon, 3 Feb 2025 at 12:59, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> Add information about the type of blkmap slice in the corresponding
> slice structure. Put information in the blkmap slice structure to
> identify if it is associated with a memory or linear mapped
> device. Which can then be used to take specific action based on the
> type of the blkmap slice.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
> Changes since V3:
> * Add the map type to the blkmap slice instead of the entire blkmap
>   device
>
>  drivers/block/blkmap.c | 4 ++++
>  include/blkmap.h       | 6 ++++++
>  2 files changed, 10 insertions(+)
>
> diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c
> index 34eed1380dc..4c71ec784e0 100644
> --- a/drivers/block/blkmap.c
> +++ b/drivers/block/blkmap.c
> @@ -25,12 +25,14 @@ struct blkmap;
>   * @node: List node used to associate this slice with a blkmap
>   * @blknr: Start block number of the mapping
>   * @blkcnt: Number of blocks covered by this mapping
> + * @type: Type of blkmap slice
>   */
>  struct blkmap_slice {
>         struct list_head node;
>
>         lbaint_t blknr;
>         lbaint_t blkcnt;
> +       enum blkmap_slice_type type;
>
>         /**
>          * @read: - Read from slice
> @@ -169,6 +171,7 @@ int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
>                 .slice = {
>                         .blknr = blknr,
>                         .blkcnt = blkcnt,
> +                       .type = BLKMAP_SLICE_LINEAR,
>
>                         .read = blkmap_linear_read,
>                         .write = blkmap_linear_write,
> @@ -248,6 +251,7 @@ int __blkmap_map_mem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
>                 .slice = {
>                         .blknr = blknr,
>                         .blkcnt = blkcnt,
> +                       .type = BLKMAP_SLICE_MEM,
>
>                         .read = blkmap_mem_read,
>                         .write = blkmap_mem_write,
> diff --git a/include/blkmap.h b/include/blkmap.h
> index d53095437fa..c7b4bf13c4e 100644
> --- a/include/blkmap.h
> +++ b/include/blkmap.h
> @@ -9,6 +9,12 @@
>
>  #include <dm/lists.h>
>
> +/* Type of blkmap slice, Linear or Memory */
> +enum blkmap_slice_type {
> +       BLKMAP_SLICE_LINEAR = 1,
> +       BLKMAP_SLICE_MEM,
> +};
> +
>  /**
>   * struct blkmap - Block map
>   *
> --
> 2.34.1
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c
index 34eed1380dc..4c71ec784e0 100644
--- a/drivers/block/blkmap.c
+++ b/drivers/block/blkmap.c
@@ -25,12 +25,14 @@  struct blkmap;
  * @node: List node used to associate this slice with a blkmap
  * @blknr: Start block number of the mapping
  * @blkcnt: Number of blocks covered by this mapping
+ * @type: Type of blkmap slice
  */
 struct blkmap_slice {
 	struct list_head node;
 
 	lbaint_t blknr;
 	lbaint_t blkcnt;
+	enum blkmap_slice_type type;
 
 	/**
 	 * @read: - Read from slice
@@ -169,6 +171,7 @@  int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
 		.slice = {
 			.blknr = blknr,
 			.blkcnt = blkcnt,
+			.type = BLKMAP_SLICE_LINEAR,
 
 			.read = blkmap_linear_read,
 			.write = blkmap_linear_write,
@@ -248,6 +251,7 @@  int __blkmap_map_mem(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
 		.slice = {
 			.blknr = blknr,
 			.blkcnt = blkcnt,
+			.type = BLKMAP_SLICE_MEM,
 
 			.read = blkmap_mem_read,
 			.write = blkmap_mem_write,
diff --git a/include/blkmap.h b/include/blkmap.h
index d53095437fa..c7b4bf13c4e 100644
--- a/include/blkmap.h
+++ b/include/blkmap.h
@@ -9,6 +9,12 @@ 
 
 #include <dm/lists.h>
 
+/* Type of blkmap slice, Linear or Memory */
+enum blkmap_slice_type {
+	BLKMAP_SLICE_LINEAR = 1,
+	BLKMAP_SLICE_MEM,
+};
+
 /**
  * struct blkmap - Block map
  *