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:	Tue, 08 Dec 2015 10:15:08 -0800
From:	Florian Fainelli <f.fainelli@...il.com>
To:	Russell King <rmk+kernel@....linux.org.uk>,
	Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
CC:	netdev@...r.kernel.org
Subject: Re: [PATCH RFC 10/26] phy: add I2C mdio bus

On 07/12/15 09:38, Russell King wrote:
> Add an I2C MDIO bus bridge library, to allow phylib to access PHYs which
> are connected to an I2C bus instead of the more conventional MDIO bus.
> Such PHYs can be found in SFP adapters and SFF modules.
> 
> Signed-off-by: Russell King <rmk+kernel@....linux.org.uk>
> ---
[snip]
> +static int i2c_mii_read(struct mii_bus *bus, int phy_id, int reg)
> +{
> +	struct i2c_adapter *i2c = bus->priv;
> +	struct i2c_msg msgs[2];
> +	u8 data[2], dev_addr = reg;
> +	int bus_addr, ret;
> +
> +	bus_addr = 0x40 + phy_id;
> +	if (bus_addr == 0x50 || bus_addr == 0x51)
> +		return 0xffff;

These could deserve a local definition for these specific addresses so
we know why there is such logic here.

> +
> +	msgs[0].addr = bus_addr;
> +	msgs[0].flags = 0;
> +	msgs[0].len = 1;
> +	msgs[0].buf = &dev_addr;
> +	msgs[1].addr = bus_addr;
> +	msgs[1].flags = I2C_M_RD;
> +	msgs[1].len = sizeof(data);
> +	msgs[1].buf = data;
> +
> +	ret = i2c_transfer(i2c, msgs, ARRAY_SIZE(msgs));
> +	if (ret != ARRAY_SIZE(msgs))
> +		return 0xffff;
> +
> +	return data[0] << 8 | data[1];
> +}
> +
> +static int i2c_mii_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
> +{
> +	struct i2c_adapter *i2c = bus->priv;
> +	struct i2c_msg msg;
> +	int bus_addr, ret;
> +	u8 data[3];
> +
> +	bus_addr = 0x40 + phy_id;
> +	if (bus_addr == 0x50 || bus_addr == 0x51)
> +		return 0;

Same here.
-- 
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ