From: Andrew Lunn <andrew@lunn.ch>
To: sean.wang@mediatek.com
Cc: f.fainelli@gmail.com, vivien.didelot@savoirfairelinux.com,
matthias.bgg@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com,
devicetree@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
davem@davemloft.net, Landen.Chao@mediatek.com,
keyhaede@gmail.com, objelf@gmail.com
Subject: Re: [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch
Date: Thu, 30 Mar 2017 01:12:51 +0200 [thread overview]
Message-ID: <20170329231251.GH28922@lunn.ch> (raw)
In-Reply-To: <1490780303-18598-6-git-send-email-sean.wang@mediatek.com>
> +static struct mt7530_priv *lpriv;
Hi Sean
Why do you need this global variable? What if somebody has two
switches connected?
> +static void mt7530_port_disable(struct dsa_switch *ds, int port,
> + struct phy_device *phy);
> +static int mt7530_cpu_port_enable(struct mt7530_priv *priv,
> + int port);
It is better to move the functions around than have forward
declarations.
> +static u32
> +_mt7530_read(u32 reg)
> +{
> + struct mt7530_priv *priv = lpriv;
> + struct mii_bus *bus = priv->bus;
> + u32 val;
> +
> + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
> +
> + val = mt7530_mii_read(priv, reg);
> +
> + mutex_unlock(&bus->mdio_lock);
> +
> + return val;
> +}
> +
> +static u32
> +mt7530_read(struct mt7530_priv *priv, u32 reg)
> +{
> + return _mt7530_read(reg);
> +}
So here you would pass priv to _mt7530_read().
> +static int
> +mt7530_fdb_cmd(struct mt7530_priv *priv, enum mt7530_fdb_cmd cmd, u32 *rsp)
> +{
> + u32 val;
> + int ret;
> +
> + /* Set the command operating upon the MAC address entries */
> + val = ATC_BUSY | ATC_MAT(0) | cmd;
> + mt7530_write(priv, MT7530_ATC, val);
> +
> + ret = readx_poll_timeout(_mt7530_read, MT7530_ATC, val,
> + !(val & ATC_BUSY), 20, 20000);
This is where your need for lpriv comes, you can only pass a single
argument. But you can work around it. readx_poll_timeout is a
#define. So there is no type check for _mt7530_read, or the arg passed
to it. So pass a struct containing the address and priv.
I think you can then kill of your global lpriv.
Andrew
next prev parent reply other threads:[~2017-03-29 23:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 9:38 [PATCH net-next v3 0/5] net-next: dsa: add Mediatek MT7530 support sean.wang
2017-03-29 9:38 ` [PATCH net-next v3 1/5] dt-bindings: net: dsa: add Mediatek MT7530 binding sean.wang
2017-03-29 9:38 ` [PATCH net-next v3 2/5] net-next: dsa: add Mediatek tag RX/TX handler sean.wang
2017-03-29 9:38 ` [PATCH net-next v3 3/5] net-next: ethernet: mediatek: add CDM able to recognize the tag for DSA sean.wang
2017-03-29 9:38 ` [PATCH net-next v3 4/5] net-next: ethernet: mediatek: add device_node of GMAC pointing into the netdev instance sean.wang
2017-03-29 9:38 ` [PATCH net-next v3 5/5] net-next: dsa: add dsa support for Mediatek MT7530 switch sean.wang
2017-03-29 23:12 ` Andrew Lunn [this message]
2017-04-03 1:16 ` kbuild test robot
2017-04-03 5:06 ` kbuild test robot
2017-05-24 11:17 ` Andrey Jr. Melnikov
2017-05-24 13:20 ` Andrew Lunn
2017-05-24 14:44 ` Andrey Melnikov
2017-05-26 5:54 ` Florian Fainelli
2017-05-29 10:44 ` Andrey Melnikov
2017-05-29 15:29 ` Andrew Lunn
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=20170329231251.GH28922@lunn.ch \
--to=andrew@lunn.ch \
--cc=Landen.Chao@mediatek.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=keyhaede@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=objelf@gmail.com \
--cc=robh+dt@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=vivien.didelot@savoirfairelinux.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
Powered by JetHome