From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Sun, 11 Feb 2018 12:24:02 +0100 Subject: [U-Boot] [PATCH v4 01/34] usb: sunxi: Simplify ccm reg base code In-Reply-To: References: <1517927164-18197-1-git-send-email-jagan@amarulasolutions.com> <1517927164-18197-2-git-send-email-jagan@amarulasolutions.com> <36e2ef9d-3a8b-0f3d-19f0-337f302f56f7@denx.de> Message-ID: 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/11/2018 11:39 AM, Jagan Teki wrote: > On Tue, Feb 6, 2018 at 8:07 PM, Marek Vasut wrote: >> 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. > > I'm keeping ccm base in priv, so-that resigning base in remove can > avoid and use the priv->ccm where ever possible. This just grows the patch size and requires more typing in case someone decides to add another register access. I don't see any benefit for this, so keep the local variable, it costs nothing and makes the code easier. >>> 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 . > > Will update. > -- Best regards, Marek Vasut