From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 26 May 2016 14:19:10 +0200 Subject: [U-Boot] [PATCH 2/5] usb: xhci: fsl: code cleanup for device tree fixup for fsl usb controllers In-Reply-To: <1464242367-314-3-git-send-email-sriram.dash@nxp.com> References: <1464242367-314-1-git-send-email-sriram.dash@nxp.com> <1464242367-314-3-git-send-email-sriram.dash@nxp.com> Message-ID: <5746E9BE.9050006@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 05/26/2016 07:59 AM, Sriram Dash wrote: Commit message, please. > Signed-off-by: Rajesh Bhagat > Signed-off-by: Sriram Dash > --- > drivers/usb/common/fsl-dt-fixup.c | 51 +++++++++++++-------------------------- > 1 file changed, 17 insertions(+), 34 deletions(-) > > diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c > index 6f31932..520130e 100644 > --- a/drivers/usb/common/fsl-dt-fixup.c > +++ b/drivers/usb/common/fsl-dt-fixup.c > @@ -99,6 +99,19 @@ static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, > return node_offset; > } > > +#define FDT_FIXUP_ERRATUM(id) \ > +do { \ > + if (has_erratum_##id()) { \ > + usb_erratum_##id##_off = fdt_fixup_usb_erratum \ > + (blob, \ > + "fsl,usb-erratum-"#id, \ > + usb_erratum_##id##_off); \ > + if (usb_erratum_##id##_off < 0) \ > + return; \ > + debug("Adding USB erratum "#id"\n"); \ > + } \ > +} while (0) Would it be difficult to turn this into a function ? You can likely implement some function like int fsl_has_erratum(const unsigned int erratum) and then do the string concatenation with snprintf(). > void fdt_fixup_dr_usb(void *blob, bd_t *bd) > { > static const char * const modes[] = { "host", "peripheral", "otg" }; > @@ -164,39 +177,9 @@ 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; > - } > - > - 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; > - } > + FDT_FIXUP_ERRATUM(a006261); > + FDT_FIXUP_ERRATUM(a007075); > + FDT_FIXUP_ERRATUM(a007792); > + FDT_FIXUP_ERRATUM(a005697); > } > } > -- Best regards, Marek Vasut