lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 30 Oct 2015 21:52:58 +0100
From:	Andrew Lunn <andrew@...n.ch>
To:	Vivien Didelot <vivien.didelot@...oirfairelinux.com>
Cc:	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel@...oirfairelinux.com,
	"David S. Miller" <davem@...emloft.net>,
	Florian Fainelli <f.fainelli@...il.com>,
	Guenter Roeck <linux@...ck-us.net>,
	Neil Armstrong <narmstrong@...libre.com>
Subject: Re: [PATCH net-next] net: dsa: mv88e6xxx: lookup switch name

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ