All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: "s.shtylyov@omp.ru" <s.shtylyov@omp.ru>,
	"davem@davemloft.net" <davem@davemloft.net>,
	 "edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	 "pabeni@redhat.com" <pabeni@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	 "linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH net-next] rswitch: Add PM ops
Date: Fri, 13 Oct 2023 11:19:15 +0200	[thread overview]
Message-ID: <CAMuHMdUNrdr8YTQBxzX=7=W+SBtK-uH6CjjUgR9VRj3CpKFh1g@mail.gmail.com> (raw)
In-Reply-To: <TYBPR01MB5341D9408B9C4EA701E5E5D1D8D2A@TYBPR01MB5341.jpnprd01.prod.outlook.com>

Hi Shimoda-san,

On Fri, Oct 13, 2023 at 10:55 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> > From: Geert Uytterhoeven, Sent: Friday, October 13, 2023 4:29 PM
> > On Fri, Oct 13, 2023 at 4:10 AM Yoshihiro Shimoda
> > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > From: Geert Uytterhoeven, Sent: Thursday, October 12, 2023 9:35 PM
> > > > On Thu, Oct 12, 2023 at 2:16 PM Yoshihiro Shimoda
> > > > <yoshihiro.shimoda.uh@renesas.com> wrote:
> > > > > Add PM ops for Suspend to Idle. When the system suspended,
> > > > > the Ethernet Serdes's clock will be stopped. So, this driver needs
> > > > > to re-initialize the Ethernet Serdes by phy_init() in
> > > > > renesas_eth_sw_resume(). Otherwise, timeout happened in phy_power_on().
> > > > >
> > > > > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

> > > > > --- a/drivers/net/ethernet/renesas/rswitch.c
> > > > > +++ b/drivers/net/ethernet/renesas/rswitch.c
> > > > > @@ -1991,11 +1993,52 @@ static void renesas_eth_sw_remove(struct platform_device *pdev)
> > > > >         platform_set_drvdata(pdev, NULL);
> > > > >  }
> > > > >
> > > > > +static int __maybe_unused renesas_eth_sw_suspend(struct device *dev)
> > > > > +{
> > > > > +       struct rswitch_private *priv = dev_get_drvdata(dev);
> > > > > +       struct net_device *ndev;
> > > > > +       int i;
> > > >
> > > > unsigned int (also below)
> > >
> > > I don't know why unsigned int is needed. Other functions use
> >
> > There's this old mantra "prefer unsigned over signed in C",
> > and a valid port array index here is always unsigned.
>
> I understood it.
>
> > > rswitch_for_each_enabled_port{_continue_reverse}() with int.
> > > Especially, rswitch_for_each_enabled_port_continue_reverse()
> > > has the following code, unsigned int will not work correctly:
> >
> > Oh, there is also a reverse variant, which indeed needs a signed
> > iterator, currently...
> >
> > > ---
> > > #define rswitch_for_each_enabled_port_continue_reverse(priv, i) \
> > >         for (i--; i >= 0; i--)                                  \
> >
> > I think this can be made to work with an unsigned iterator using
> >
> >     for (; i-- > 0; )
>
> I think that this loop cannot access index 0 :)

rswitch_for_each_enabled_port_continue_reverse() is meant to be
used in the error path, to tear down all ports that were initialized
succesfully? So i is always the index of the first port that failed to
initialize, i.e. i > 0 on entry.

See "git grep -Ww rswitch_for_each_enabled_port_continue_reverse".

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2023-10-13  9:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 12:16 [PATCH net-next] rswitch: Add PM ops Yoshihiro Shimoda
2023-10-12 12:35 ` Geert Uytterhoeven
2023-10-13  2:10   ` Yoshihiro Shimoda
2023-10-13  7:28     ` Geert Uytterhoeven
2023-10-13  8:55       ` Yoshihiro Shimoda
2023-10-13  9:19         ` Geert Uytterhoeven [this message]
2023-10-13 10:02           ` Yoshihiro Shimoda

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='CAMuHMdUNrdr8YTQBxzX=7=W+SBtK-uH6CjjUgR9VRj3CpKFh1g@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=s.shtylyov@omp.ru \
    --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 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.