linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>
To: sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org
Cc: f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	vivien.didelot-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	Landen.Chao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org,
	keyhaede-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	objelf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>

> +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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-03-29 23:12 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
     [not found] ` <1490780303-18598-1-git-send-email-sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2017-03-29  9:38   ` [PATCH net-next v3 2/5] net-next: dsa: add Mediatek tag RX/TX handler sean.wang-NuS5LvNUpcJWk0Htik3J/w
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-04-03  1:16   ` kbuild test robot
     [not found]   ` <1490780303-18598-6-git-send-email-sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2017-03-29 23:12     ` Andrew Lunn [this message]
2017-04-03  5:06     ` kbuild test robot
2017-05-24 11:17   ` Andrey Jr. Melnikov
2017-05-24 13:20     ` Andrew Lunn
     [not found]       ` <20170524132049.GB24980-g2DYL2Zd6BY@public.gmane.org>
2017-05-24 14:44         ` Andrey Melnikov
     [not found]     ` <hn6gvd-qp1.ln1-f2MyMQbBE8IG/9ncUZ6upg@public.gmane.org>
2017-05-26  5:54       ` Florian Fainelli
     [not found]         ` <043CDC76-3C57-4F54-97B6-896591A11CB3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-29 10:44           ` Andrey Melnikov
     [not found]             ` <CA+PODjoZpYLVKCXveUGvu8MXX4YVmE-bKm241o_3OT3P5pkieQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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-g2dyl2zd6by@public.gmane.org \
    --cc=Landen.Chao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=keyhaede-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=objelf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
    --cc=vivien.didelot-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org \
    /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).