From: Marek Vasut Date: Tue, 6 Feb 2018 15:37:18 +0100 Subject: [U-Boot] [PATCH v4 01/34] usb: sunxi: Simplify ccm reg base code In-Reply-To: <1517927164-18197-2-git-send-email-jagan@amarulasolutions.com> References: <1517927164-18197-1-git-send-email-jagan@amarulasolutions.com> <1517927164-18197-2-git-send-email-jagan@amarulasolutions.com> Message-ID: <36e2ef9d-3a8b-0f3d-19f0-337f302f56f7@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 02/06/2018 03:25 PM, Jagan Teki wrote: > Move struct sunxi_ccm_reg pointer to private structure > so-that accessing ccm reg base become more proper way > and avoid local initialization in each function. > > Signed-off-by: Jagan Teki > --- > drivers/usb/host/ehci-sunxi.c | 15 +++++++++------ > drivers/usb/host/ohci-sunxi.c | 19 +++++++++++-------- > drivers/usb/musb-new/sunxi.c | 34 +++++++++++++++++++++++----------- > 3 files changed, 43 insertions(+), 25 deletions(-) > > diff --git a/drivers/usb/host/ehci-sunxi.c b/drivers/usb/host/ehci-sunxi.c > index 6ecb7c4..ed9763c 100644 > --- a/drivers/usb/host/ehci-sunxi.c > +++ b/drivers/usb/host/ehci-sunxi.c > @@ -27,19 +27,23 @@ > > struct ehci_sunxi_priv { > struct ehci_ctrl ehci; > + struct sunxi_ccm_reg *ccm; > int ahb_gate_mask; /* Mask of ahb_gate0 clk gate bits for this hcd */ > int phy_index; /* Index of the usb-phy attached to this hcd */ > }; > > static int ehci_usb_probe(struct udevice *dev) > { > - struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; Keep this, so you don't have to modify every setbits()/... down below. > struct usb_platdata *plat = dev_get_platdata(dev); > struct ehci_sunxi_priv *priv = dev_get_priv(dev); > struct ehci_hccr *hccr = (struct ehci_hccr *)devfdt_get_addr(dev); > struct ehci_hcor *hcor; > int extra_ahb_gate_mask = 0; > > + priv->ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; Do priv->ccm = ccm , done . > + if (IS_ERR(priv->ccm)) > + return PTR_ERR(priv->ccm); > + > /* > * This should go away once we've moved to the driver model for > * clocks resp. phys. [...] -- Best regards, Marek Vasut