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]
Message-ID: <d86dd4a4-a56a-4d48-ad7d-182f6fed8781@redhat.com>
Date: Fri, 21 Mar 2025 18:53:51 +0100
From: Paolo Abeni <pabeni@...hat.com>
To: Maxime Chevallier <maxime.chevallier@...tlin.com>, davem@...emloft.net,
 Andrew Lunn <andrew@...n.ch>, Jakub Kicinski <kuba@...nel.org>,
 Eric Dumazet <edumazet@...gle.com>, Russell King <linux@...linux.org.uk>,
 Heiner Kallweit <hkallweit1@...il.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
 thomas.petazzoni@...tlin.com, Florian Fainelli <f.fainelli@...il.com>,
 Köry Maincent <kory.maincent@...tlin.com>,
 Simon Horman <horms@...nel.org>, Romain Gantois
 <romain.gantois@...tlin.com>, Antoine Tenart <atenart@...nel.org>,
 Marek Behún <kabel@...nel.org>,
 Sean Anderson <sean.anderson@...ux.dev>, Bjørn Mork
 <bjorn@...k.no>
Subject: Re: [PATCH net-next v3 2/2] net: mdio: mdio-i2c: Add support for
 single-byte SMBus operations

On 3/14/25 5:23 PM, Maxime Chevallier wrote:
> diff --git a/drivers/net/mdio/mdio-i2c.c b/drivers/net/mdio/mdio-i2c.c
> index da2001ea1f99..202f486e71f1 100644
> --- a/drivers/net/mdio/mdio-i2c.c
> +++ b/drivers/net/mdio/mdio-i2c.c
> @@ -106,6 +106,62 @@ static int i2c_mii_write_default_c22(struct mii_bus *bus, int phy_id, int reg,
>  	return i2c_mii_write_default_c45(bus, phy_id, -1, reg, val);
>  }
>  
> +static int smbus_byte_mii_read_default_c22(struct mii_bus *bus, int phy_id,
> +					   int reg)
> +{
> +	struct i2c_adapter *i2c = bus->priv;
> +	union i2c_smbus_data smbus_data;
> +	int val = 0, ret;
> +
> +	if (!i2c_mii_valid_phy_id(phy_id))
> +		return 0;
> +
> +	ret = i2c_smbus_xfer(i2c, i2c_mii_phy_addr(phy_id), 0,
> +			     I2C_SMBUS_READ, reg,
> +			     I2C_SMBUS_BYTE_DATA, &smbus_data);
> +	if (ret < 0)
> +		return ret;
> +
> +	val = ((smbus_data.byte & 0xff) << 8);

External brackets not needed.

> +
> +	ret = i2c_smbus_xfer(i2c, i2c_mii_phy_addr(phy_id), 0,
> +			     I2C_SMBUS_READ, reg,
> +			     I2C_SMBUS_BYTE_DATA, &smbus_data);
> +	if (ret < 0)
> +		return ret;
> +
> +	val |= (smbus_data.byte & 0xff);

same here.

> +
> +	return val;
> +}
> +
> +static int smbus_byte_mii_write_default_c22(struct mii_bus *bus, int phy_id,
> +					    int reg, u16 val)
> +{
> +	struct i2c_adapter *i2c = bus->priv;
> +	union i2c_smbus_data smbus_data;
> +	int ret;
> +
> +	if (!i2c_mii_valid_phy_id(phy_id))
> +		return 0;
> +
> +	smbus_data.byte = ((val & 0xff00) >> 8);

and here.

> +
> +	ret = i2c_smbus_xfer(i2c, i2c_mii_phy_addr(phy_id), 0,
> +			     I2C_SMBUS_WRITE, reg,
> +			     I2C_SMBUS_BYTE_DATA, &smbus_data);
> +	if (ret < 0)
> +		return ret;
> +
> +	smbus_data.byte = val & 0xff;

I would not have noted the above if even this one carried additional
brackets...

Cheers,

Paolo


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ