diff mbox

[3/7] libflash/blocklevel: add blocklevel flags.

Message ID 1433477491-5744-4-git-send-email-cyril.bur@au1.ibm.com
State Superseded
Headers show

Commit Message

Cyril Bur June 5, 2015, 4:11 a.m. UTC
It has become apparent that communication between blocklevel and its
backend may be necessarily, at least so that the backend can inform
blocklevel as to if an erase must be done before a write.

An erase before flag isn't strictly necessary as erases can be performed
regardless of whether they need to be or not, however, the caveat with that
is that when erases don't need to be performed, this is likely due to the
backend not having erase blocks and therefore it may be impossible to set a
sane value for erase blocks which would be used to erase before write.

This flag saves backends that don't need erases before write to have to lie
about an erase block size.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 libflash/blocklevel.h | 6 ++++++
 libflash/libflash.c   | 1 +
 2 files changed, 7 insertions(+)

Comments

Alistair Popple June 12, 2015, 2:15 a.m. UTC | #1
Looks ok to me.

Reviewed-by: Alistair Popple <alistair@popple.id.au>

On Fri, 5 Jun 2015 14:11:27 Cyril Bur wrote:
> @@ -48,6 +53,7 @@ struct blocklevel_device {
>  
>  	struct bl_prot_range *write_prot;
>  	int n_write_prot;
> +

I'll be a pedant and say we don't need this change...

>  };
>  
>  int blocklevel_read(struct blocklevel_device *bl, uint32_t pos, void *buf, uint32_t len);
> diff --git a/libflash/libflash.c b/libflash/libflash.c
> index a142e17..55eafbe 100644
> --- a/libflash/libflash.c
> +++ b/libflash/libflash.c
> @@ -838,6 +838,7 @@ bail:
>  	c->bl.erase = &flash_erase;
>  	c->bl.get_info = &flash_get_info;
>  	c->bl.erase_mask = c->min_erase_mask;
> +	c->bl.flags = WRITE_NEED_ERASE;
>  
>  	*bl = &(c->bl);
>  	return 0;
>
Alistair Popple June 22, 2015, 9:16 a.m. UTC | #2
This looks the same as last time so still:

Reviewed-By: Alistair Popple <alistair@popple.id.au>

On Fri, 5 Jun 2015 14:11:27 Cyril Bur wrote:
> It has become apparent that communication between blocklevel and its
> backend may be necessarily, at least so that the backend can inform
> blocklevel as to if an erase must be done before a write.
> 
> An erase before flag isn't strictly necessary as erases can be performed
> regardless of whether they need to be or not, however, the caveat with that
> is that when erases don't need to be performed, this is likely due to the
> backend not having erase blocks and therefore it may be impossible to set a
> sane value for erase blocks which would be used to erase before write.
> 
> This flag saves backends that don't need erases before write to have to lie
> about an erase block size.
> 
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
> ---
>  libflash/blocklevel.h | 6 ++++++
>  libflash/libflash.c   | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/libflash/blocklevel.h b/libflash/blocklevel.h
> index 3a20677..d2995ce 100644
> --- a/libflash/blocklevel.h
> +++ b/libflash/blocklevel.h
> @@ -23,6 +23,10 @@ struct bl_prot_range {
>  	uint32_t len;
>  };
>  
> +enum blocklevel_flags {
> +	WRITE_NEED_ERASE = 1,
> +};
> +
>  /*
>   * libffs may be used with different backends, all should provide these for
>   * libflash to get the information it needs
> @@ -39,6 +43,7 @@ struct blocklevel_device {
>  	 * Keep the erase mask so that blocklevel_erase() can do sanity checking
>  	 */
>  	uint32_t erase_mask;
> +	enum blocklevel_flags flags;
>  
>  	struct bl_prot_range *ecc_prot;
>  	int n_ecc_prot;
> @@ -48,6 +53,7 @@ struct blocklevel_device {
>  
>  	struct bl_prot_range *write_prot;
>  	int n_write_prot;
> +
>  };
>  
>  int blocklevel_read(struct blocklevel_device *bl, uint32_t pos, void *buf, uint32_t len);
> diff --git a/libflash/libflash.c b/libflash/libflash.c
> index a142e17..55eafbe 100644
> --- a/libflash/libflash.c
> +++ b/libflash/libflash.c
> @@ -838,6 +838,7 @@ bail:
>  	c->bl.erase = &flash_erase;
>  	c->bl.get_info = &flash_get_info;
>  	c->bl.erase_mask = c->min_erase_mask;
> +	c->bl.flags = WRITE_NEED_ERASE;
>  
>  	*bl = &(c->bl);
>  	return 0;
>
diff mbox

Patch

diff --git a/libflash/blocklevel.h b/libflash/blocklevel.h
index 3a20677..d2995ce 100644
--- a/libflash/blocklevel.h
+++ b/libflash/blocklevel.h
@@ -23,6 +23,10 @@  struct bl_prot_range {
 	uint32_t len;
 };
 
+enum blocklevel_flags {
+	WRITE_NEED_ERASE = 1,
+};
+
 /*
  * libffs may be used with different backends, all should provide these for
  * libflash to get the information it needs
@@ -39,6 +43,7 @@  struct blocklevel_device {
 	 * Keep the erase mask so that blocklevel_erase() can do sanity checking
 	 */
 	uint32_t erase_mask;
+	enum blocklevel_flags flags;
 
 	struct bl_prot_range *ecc_prot;
 	int n_ecc_prot;
@@ -48,6 +53,7 @@  struct blocklevel_device {
 
 	struct bl_prot_range *write_prot;
 	int n_write_prot;
+
 };
 
 int blocklevel_read(struct blocklevel_device *bl, uint32_t pos, void *buf, uint32_t len);
diff --git a/libflash/libflash.c b/libflash/libflash.c
index a142e17..55eafbe 100644
--- a/libflash/libflash.c
+++ b/libflash/libflash.c
@@ -838,6 +838,7 @@  bail:
 	c->bl.erase = &flash_erase;
 	c->bl.get_info = &flash_get_info;
 	c->bl.erase_mask = c->min_erase_mask;
+	c->bl.flags = WRITE_NEED_ERASE;
 
 	*bl = &(c->bl);
 	return 0;