All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: NeilBrown <neil@brown.name>, Greg KH <gregkh@linuxfoundation.org>,
	driverdev-devel@linuxdriverproject.org
Subject: Re: [PATCH 3/3] staging: mt7621-pci-phy: change driver to don't use child nodes
Date: Fri, 29 Mar 2019 09:02:31 +0100	[thread overview]
Message-ID: <CAMhs-H-+Gkf2ENFe5dpQeN1kB2-pRns2mx4hc=MB0DEPhWw_Ew@mail.gmail.com> (raw)
In-Reply-To: <20190329075414.GX32590@kadam>

Hi Dan,

On Fri, Mar 29, 2019 at 8:54 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Thu, Mar 28, 2019 at 06:55:31PM +0100, Sergio Paracuellos wrote:
> >  static int mt7621_pci_phy_probe(struct platform_device *pdev)
> >  {
> >       struct device *dev = &pdev->dev;
> > @@ -299,6 +315,7 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
> >       struct resource res;
> >       int port, ret;
> >       void __iomem *port_base;
> > +     u32 phy_num;
> >
> >       phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
> >       if (!phy)
> > @@ -325,8 +342,9 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
> >               return PTR_ERR(port_base);
> >       }
> >
> > -     port = 0;
> > -     for_each_child_of_node(np, child_np) {
> > +     of_property_read_u32(dev->of_node, "#phy-cells", &phy_num);
> > +
> > +     for (port = 0; port < phy_num + 1; port++) {
>                        ^^^^^^^^^^^^^^^^^^  ^^^^^^
> >               struct mt7621_pci_phy_instance *instance;
> >               struct phy *pphy;
> >
> > @@ -338,7 +356,7 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
> >
> >               phy->phys[port] = instance;
> >
> > -             pphy = devm_phy_create(dev, child_np, &mt7621_pci_phy_ops);
> > +             pphy = devm_phy_create(dev, dev->of_node, &mt7621_pci_phy_ops);
> >               if (IS_ERR(phy)) {
> >                       dev_err(dev, "failed to create phy\n");
> >                       ret = PTR_ERR(phy);
> > @@ -352,7 +370,7 @@ static int mt7621_pci_phy_probe(struct platform_device *pdev)
> >               port++;
>                 ^^^^^^
> >       }
>
> Incrementing "port" twice is probably wrong...  Or anyway, less readable
> than "port += 2".

Yes, that was a mistake in my code becase I did not delete it when the
loop was changed.

>
> To be honest, I don't know anything about device tree.  Does "phy_num"
> come from the device tree stuff that you just changed in the ealier
> patches?  (I never read those so I never learn anything about device
> tree so I am stuck in an endless doom cycle).

The first approach in v1 was to read this from #phy-cell property from
device tree. Neil points me
out this was not the correct approach and was changed to a fixed
MAX_PHYS for both phy's in v2 patches.

>
> Anyway, I am a real newbie.  Where does the plus one in
> "port < phy_num + 1" come from?  How do I verify that phy_num is less
> than phy->nphys?

In the same way, this is now a fixed port < MAX_PHYS in for loop sent
in v2 of the patches.

>
> regards,
> dan carpenter
>

Best regards,
    Sergio Paracuellos

      reply	other threads:[~2019-03-29  8:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-28 17:55 [PATCH 0/3] staging: mt7621-pci-phy: simplify driver to don't use child nodes in DT Sergio Paracuellos
2019-03-28 17:55 ` [PATCH 1/3] staging: mt7621-dts: simplify pcie phy bindings Sergio Paracuellos
2019-03-29  3:01   ` NeilBrown
2019-03-29  5:54     ` Sergio Paracuellos
2019-03-28 17:55 ` [PATCH 2/3] staging: mt7621-pci-phy: update bindings documentation Sergio Paracuellos
2019-03-28 17:55 ` [PATCH 3/3] staging: mt7621-pci-phy: change driver to don't use child nodes Sergio Paracuellos
2019-03-29  3:06   ` NeilBrown
2019-03-29  5:57     ` Sergio Paracuellos
2019-03-29  7:54   ` Dan Carpenter
2019-03-29  8:02     ` Sergio Paracuellos [this message]

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='CAMhs-H-+Gkf2ENFe5dpQeN1kB2-pRns2mx4hc=MB0DEPhWw_Ew@mail.gmail.com' \
    --to=sergio.paracuellos@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=neil@brown.name \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.