[U-Boot] [PATCH v4 01/34] usb: sunxi: Simplify ccm reg base code

Marek Vasut marex at denx.de
Tue Feb 6 14:37:18 UTC 2018


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 <jagan at amarulasolutions.com>
> ---
>  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


More information about the U-Boot mailing list