All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/5] usb: xhci: fsl: code cleanup for device tree fixup for fsl usb controllers
Date: Thu, 02 Jun 2016 14:55:23 +0200	[thread overview]
Message-ID: <57502CBB.3070909@denx.de> (raw)
In-Reply-To: <1464850458-2850-3-git-send-email-sriram.dash@nxp.com>

On 06/02/2016 08:54 AM, Sriram Dash wrote:
> Performs code cleanup for device tree fixup for fsl usb controllers by
> making functions to handle these similar errata checking code.
> 
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
> Signed-off-by: Sriram Dash <sriram.dash@nxp.com>
> ---
> Changes in v2:
>   - added patch description
>   - remove the MACRO and use fdt_fixup_erratum function instead
> 
> 
>  drivers/usb/common/fsl-dt-fixup.c | 58 +++++++++++++++++----------------------
>  1 file changed, 25 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c
> index 6f31932..cbb008b 100644
> --- a/drivers/usb/common/fsl-dt-fixup.c
> +++ b/drivers/usb/common/fsl-dt-fixup.c
> @@ -99,6 +99,23 @@ static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum,
>  	return node_offset;
>  }
>  
> +void fdt_fixup_erratum(int *usb_erratum_off, void *blob,
> +		       char *str, bool (*has_erratum)(void))
> +{
> +	char buf[32] = {0};
> +
> +	snprintf(buf, sizeof(buf), "fsl,usb-erratum-%s", str);
> +	if (has_erratum()) {

Invert the condition here so you won't have the indentation problems below:

if (!(has_erratum())
	return;
... other stuff.


> +		*usb_erratum_off =  fdt_fixup_usb_erratum
> +				   (blob,
> +				    buf,
> +				    *usb_erratum_off);
> +		if (*usb_erratum_off < 0)
> +			return;

If fdt_fixup_usb_erratum() fails, this function will return, but the
code below will continue. This changes the logic of the code to the
worse, so fix this.

> +		debug("Adding USB erratum %s\n", str);
> +	}
> +}
> +
>  void fdt_fixup_dr_usb(void *blob, bd_t *bd)
>  {
>  	static const char * const modes[] = { "host", "peripheral", "otg" };
> @@ -164,39 +181,14 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
>  		if (usb_phy_off < 0)
>  			return;
>  
> -		if (has_erratum_a006261()) {
> -			usb_erratum_a006261_off =  fdt_fixup_usb_erratum
> -						   (blob,
> -						    "fsl,usb-erratum-a006261",
> -						    usb_erratum_a006261_off);
> -			if (usb_erratum_a006261_off < 0)
> -				return;
> -		}
> -
> -		if (has_erratum_a007075()) {
> -			usb_erratum_a007075_off =  fdt_fixup_usb_erratum
> -						   (blob,
> -						    "fsl,usb-erratum-a007075",
> -						    usb_erratum_a007075_off);
> -			if (usb_erratum_a007075_off < 0)
> -				return;
> -		}
> +		fdt_fixup_erratum(&usb_erratum_a006261_off, blob,
> +				  "a006261", has_erratum_a006261);
> +		fdt_fixup_erratum(&usb_erratum_a007075_off, blob,
> +				  "a007075", has_erratum_a007075);
> +		fdt_fixup_erratum(&usb_erratum_a007792_off, blob,
> +				  "a007792", has_erratum_a007792);
> +		fdt_fixup_erratum(&usb_erratum_a005697_off, blob,
> +				  "a005697", has_erratum_a005697);

Are these usb_erratum_aNNNNNN_off variables needed at all ? Why are they
even passed into the function ? I think they can be local to the function.

> -		if (has_erratum_a007792()) {
> -			usb_erratum_a007792_off =  fdt_fixup_usb_erratum
> -						   (blob,
> -						    "fsl,usb-erratum-a007792",
> -						    usb_erratum_a007792_off);
> -			if (usb_erratum_a007792_off < 0)
> -				return;
> -		}
> -		if (has_erratum_a005697()) {
> -			usb_erratum_a005697_off =  fdt_fixup_usb_erratum
> -						   (blob,
> -						    "fsl,usb-erratum-a005697",
> -						    usb_erratum_a005697_off);
> -			if (usb_erratum_a005697_off < 0)
> -				return;
> -		}
>  	}
>  }
> 


-- 
Best regards,
Marek Vasut

  reply	other threads:[~2016-06-02 12:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02  6:54 [U-Boot] [PATCH v2 0/5] Supporting ARM v8 USB errata for FSL Sriram Dash
2016-06-02  6:54 ` [U-Boot] [PATCH v2 1/5] arm64: fsl-layerscape: add get_svr and IS_SVR_REV helper Sriram Dash
2016-06-02 12:47   ` Marek Vasut
2016-06-06  4:21     ` Sriram Dash
2016-06-06 12:51       ` Marek Vasut
2016-06-08  4:12         ` Sriram Dash
2016-06-08 14:11           ` Marek Vasut
2016-06-02 12:48   ` Marek Vasut
2016-06-06  4:22     ` Sriram Dash
2016-06-02  6:54 ` [U-Boot] [PATCH v2 2/5] usb: xhci: fsl: code cleanup for device tree fixup for fsl usb controllers Sriram Dash
2016-06-02 12:55   ` Marek Vasut [this message]
2016-06-06  4:23     ` Sriram Dash
2016-06-02  6:54 ` [U-Boot] [PATCH v2 3/5] fsl: usb: make errata function common for PPC and ARM Sriram Dash
2016-06-02  6:54 ` [U-Boot] [PATCH v2 4/5] armv8/ls2080: Remove workaround for erratum A008751 Sriram Dash
2016-06-02 12:57   ` Marek Vasut
2016-06-06  4:23     ` Sriram Dash
2016-06-06 12:25       ` Marek Vasut
2016-06-02  6:54 ` [U-Boot] [PATCH v2 5/5] usb: xhci: fsl: Add workaround for USB erratum A-008751 Sriram Dash
2016-06-02 13:00   ` Marek Vasut
2016-06-06  4:24     ` Sriram Dash
2016-06-06 12:45       ` Marek Vasut
2016-06-08  4:12         ` Sriram Dash

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57502CBB.3070909@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.