Re: [PATCH v4 4/6] libfdt: Add support for disabling rollback handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Tue, Nov 12, 2019 at 06:54:20PM -0700, Simon Glass wrote:
> Allow enabling FDT_ASSUME_NO_ROLLBACK to disable rolling back after a
> failed operation.
> 
> Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx>

Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>

> ---
> 
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
> 
>  libfdt/fdt_rw.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
> index 1dd9cf0..fe61e63 100644
> --- a/libfdt/fdt_rw.c
> +++ b/libfdt/fdt_rw.c
> @@ -116,6 +116,15 @@ static int fdt_splice_string_(void *fdt, int newlen)
>  	return 0;
>  }
>  
> +/**
> + * fdt_find_add_string_() - Find or allocate a string
> + *
> + * @fdt: pointer to the device tree to check/adjust
> + * @s: string to find/add
> + * @allocated: Set to 0 if the string was found, 1 if not found and so
> + *	allocated. Ignored if can_assume(NO_ROLLBACK)
> + * @return offset of string in the string table (whether found or added)
> + */
>  static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
>  {
>  	char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
> @@ -124,7 +133,8 @@ static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
>  	int len = strlen(s) + 1;
>  	int err;
>  
> -	*allocated = 0;
> +	if (!can_assume(NO_ROLLBACK))
> +		*allocated = 0;
>  
>  	p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s);
>  	if (p)
> @@ -136,7 +146,8 @@ static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
>  	if (err)
>  		return err;
>  
> -	*allocated = 1;
> +	if (!can_assume(NO_ROLLBACK))
> +		*allocated = 1;
>  
>  	memcpy(new, s, len);
>  	return (new - strtab);
> @@ -210,7 +221,8 @@ static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
>  
>  	err = fdt_splice_struct_(fdt, *prop, 0, proplen);
>  	if (err) {
> -		if (allocated)
> +		/* Delete the string if we failed to add it */
> +		if (!can_assume(NO_ROLLBACK) && allocated)
>  			fdt_del_last_string_(fdt, name);
>  		return err;
>  	}

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux