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

Marek Vasut marex at denx.de
Sun Feb 11 11:24:02 UTC 2018


On 02/11/2018 11:39 AM, Jagan Teki wrote:
> On Tue, Feb 6, 2018 at 8:07 PM, Marek Vasut <marex at denx.de> 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 <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.
> 
> 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


More information about the U-Boot mailing list