From: Andrew Lunn <andrew@lunn.ch>
To: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@savoirfairelinux.com,
"David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Guenter Roeck <linux@roeck-us.net>,
Neil Armstrong <narmstrong@baylibre.com>
Subject: Re: [PATCH net-next] net: dsa: mv88e6xxx: lookup switch name
Date: Fri, 30 Oct 2015 21:52:58 +0100 [thread overview]
Message-ID: <20151030205258.GC10053@lunn.ch> (raw)
In-Reply-To: <1446237416-5447-1-git-send-email-vivien.didelot@savoirfairelinux.com>
On Fri, Oct 30, 2015 at 04:36:56PM -0400, Vivien Didelot wrote:
> All the mv88e6xxx drivers use the exact same code in their probe
> function to lookup the switch name given its ID.
I did consider this before. But they are not exactly the same, when
you consider the masking of the lower nibble which some drivers do,
and others not. But i see you handled that.
> +char *mv88e6xxx_lookup_name(struct device *host_dev, int sw_addr,
> + const struct mv88e6xxx_switch_id *table,
> + unsigned int num)
> +{
> + struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
> + int i, ret;
> +
> + if (!bus)
> + return NULL;
> +
> + ret = __mv88e6xxx_reg_read(bus, sw_addr, REG_PORT(0), PORT_SWITCH_ID);
> + if (ret < 0)
> + return NULL;
> +
> + /* Look up the exact switch ID */
> + for (i = 0; i < num; ++i) {
> + if (table[i].id == ret) {
> + pr_info("found switch 0x%x\n", ret);
The old code did not print anything. The core DSA will print it later
however, so we don't need to print it here.
> + return table[i].name;
> + }
> + }
> +
> + /* Look up only the product number */
> + for (i = 0; i < num; ++i) {
> + if (table[i].id == (ret & PORT_SWITCH_ID_PROD_NUM_MASK)) {
> + pr_warn("found switch 0x%x, maybe register rev %d?\n",
> + ret, ret & PORT_SWITCH_ID_REV_MASK);
I probably would not warn here. The old code did not.
Apart from these comments, a good change.
Andrew
next prev parent reply other threads:[~2015-10-30 20:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-30 20:36 [PATCH net-next] net: dsa: mv88e6xxx: lookup switch name Vivien Didelot
2015-10-30 20:52 ` Andrew Lunn [this message]
2015-10-30 21:01 ` Vivien Didelot
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=20151030205258.GC10053@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=narmstrong@baylibre.com \
--cc=netdev@vger.kernel.org \
--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 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.