devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
To: "Rafał Miłecki" <rafal@milecki.pl>
Cc: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Russell King <linux@armlinux.org.uk>,
	Scott Branden <sbranden@broadcom.com>,
	Ray Jui <rjui@broadcom.com>,
	Srinath Mannam <srinath.mannam@broadcom.com>,
	Jon Mason <jonmason@broadcom.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Raviteja Garimella <raviteja.garimella@broadcom.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	bcm-kernel-feedback-list <bcm-kernel-feedback-list@broadcom.com>
Subject: Re: [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller
Date: Tue, 24 Oct 2017 12:11:00 +0530	[thread overview]
Message-ID: <CAAFb_vo-M=2sSCCvzesDiOT9F-RN0HfwwijKXWDvKYL1OdWqmA@mail.gmail.com> (raw)
In-Reply-To: <e1b26a08cc999ddfabd0e1fedd5d772d@milecki.pl>

On Tue, Oct 24, 2017 at 11:16 AM, Rafał Miłecki <rafal@milecki.pl> wrote:
> On 2017-10-24 06:37, Raveendra Padasalagi wrote:
>>
>> Add driver for Broadcom's USB phy controller's used in Cygnus
>> familyof SoC. Cygnus has three USB phy controller's, port 0,
>> port 1 provides USB host functionality and port 2 can be configured
>> for host/device role.
>>
>> Configuration of host/device role for port 2 is achieved based on
>> the extcon events, the driver registers to extcon framework to get
>> appropriate connect events for Host/Device cables connect/disconnect
>> states based on VBUS and ID interrupts.
>
>
> Minor issues commented inline.
>
>
>> +#define USB2_IDM_IDM_IO_CONTROL_DIRECT_OFFSET          0x0408
>> +#define USB2_IDM_IDM_IO_CONTROL_DIRECT_CLK_ENABLE      BIT(0)
>
>
> Here you define reg bits using BIT(n).
>
>
>> +#define SUSPEND_OVERRIDE_0                             13
>> +#define SUSPEND_OVERRIDE_1                             14
>> +#define SUSPEND_OVERRIDE_2                             15
>> +#define USB2_IDM_IDM_RESET_CONTROL_OFFSET              0x0800
>> +#define USB2_IDM_IDM_RESET_CONTROL__RESET              0
>
>
> And here without BIT(n). Either is fine but it may be better to be
> consistent about it.

Thanks, will fix it in the next version of the patch.

>
>
>> +static int cygnus_phy_probe(struct platform_device *pdev)
>> +{
>> +       struct resource *res;
>> +       struct cygnus_phy_driver *phy_driver;
>> +       struct phy_provider *phy_provider;
>> +       int i, ret;
>> +       u32 reg_val;
>> +       struct device *dev = &pdev->dev;
>> +       struct device_node *node = dev->of_node;
>> +
>> +       /* allocate memory for each phy instance */
>> +       phy_driver = devm_kzalloc(dev, sizeof(struct cygnus_phy_driver),
>> +                                 GFP_KERNEL);
>> +       if (!phy_driver)
>> +               return -ENOMEM;
>> +
>> +       phy_driver->num_phys = of_get_child_count(node);
>> +
>> +       if (phy_driver->num_phys == 0) {
>> +               dev_err(dev, "PHY no child node\n");
>> +               return -ENODEV;
>> +       }
>> +
>> +       phy_driver->instances = devm_kcalloc(dev, phy_driver->num_phys,
>> +                                            sizeof(struct
>> cygnus_phy_instance),
>> +                                            GFP_KERNEL);
>
>
> I don't think kcalloc is safe here. E.g. In cygnus_phy_shutdown you
> iterate over all instances reading the .power value. If
> cygnus_phy_shutdown gets called before having each instance powered up,
> you'll read random memory as .power value.

Yes, Need to use devm_kzalloc() to make sure contents of
phy_driver->instances is zero initialized.
Will fix it in the next patch.

  reply	other threads:[~2017-10-24  6:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-24  4:36 [PATCH 0/3] Add driver for Broadcom Cygnus USB phy controller Raveendra Padasalagi
2017-10-24  4:37 ` [PATCH 1/3] Documentation: DT: Add Cygnus usb phy binding Raveendra Padasalagi
     [not found]   ` <1508819822-29956-2-git-send-email-raveendra.padasalagi-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-10-27  3:39     ` Rob Herring
2017-10-27  5:17       ` Raveendra Padasalagi
     [not found] ` <1508819822-29956-1-git-send-email-raveendra.padasalagi-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-10-24  4:37   ` [PATCH 2/3] drivers: phy: broadcom: Add driver for Cygnus USB phy controller Raveendra Padasalagi
2017-10-24  5:46     ` Rafał Miłecki
2017-10-24  6:41       ` Raveendra Padasalagi [this message]
     [not found]     ` <1508819822-29956-3-git-send-email-raveendra.padasalagi-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
2017-10-27  8:35       ` Kishon Vijay Abraham I
     [not found]         ` <bc03bbcf-c487-9da6-a138-136a36537626-l0cyMroinI0@public.gmane.org>
2017-10-30  0:02           ` Chanwoo Choi
2017-10-30  5:02             ` Raveendra Padasalagi
     [not found]               ` <CAAFb_vqiA6fdqKjxLFVg705TFiO6rspbS8E3-Opqzw=09TMB_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-30  6:58                 ` Chanwoo Choi
2017-10-30  4:26           ` Raveendra Padasalagi
2017-10-24  4:37   ` [PATCH 3/3] ARM: dts: Add dt node for Broadcom Cygnus USB phy Raveendra Padasalagi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAFb_vo-M=2sSCCvzesDiOT9F-RN0HfwwijKXWDvKYL1OdWqmA@mail.gmail.com' \
    --to=raveendra.padasalagi@broadcom.com \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=jonmason@broadcom.com \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=rafal@milecki.pl \
    --cc=raviteja.garimella@broadcom.com \
    --cc=rjui@broadcom.com \
    --cc=robh+dt@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=srinath.mannam@broadcom.com \
    --cc=viresh.kumar@linaro.org \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).