From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: davem@davemloft.net, "Andrew Lunn" <andrew@lunn.ch>,
"Jakub Kicinski" <kuba@kernel.org>,
"Eric Dumazet" <edumazet@google.com>,
"Russell King" <linux@armlinux.org.uk>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@bootlin.com,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Köry Maincent" <kory.maincent@bootlin.com>,
"Simon Horman" <horms@kernel.org>,
"Romain Gantois" <romain.gantois@bootlin.com>,
"Antoine Tenart" <atenart@kernel.org>,
"Marek Behún" <kabel@kernel.org>,
"Sean Anderson" <sean.anderson@linux.dev>,
"Bjørn Mork" <bjorn@mork.no>
Subject: Re: [PATCH net-next v3 2/2] net: mdio: mdio-i2c: Add support for single-byte SMBus operations
Date: Fri, 21 Mar 2025 19:02:37 +0100 [thread overview]
Message-ID: <20250321190237.0a98e8b7@fedora.home> (raw)
In-Reply-To: <d86dd4a4-a56a-4d48-ad7d-182f6fed8781@redhat.com>
On Fri, 21 Mar 2025 18:53:51 +0100
Paolo Abeni <pabeni@redhat.com> wrote:
> 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...
:( You're correct, sorry not to have spotted that before... I'll fix
this for v4.
Maxime
next prev parent reply other threads:[~2025-03-21 18:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 16:23 [PATCH net-next v3 0/2] net: phy: sfp: Add single-byte SMBus SFP access Maxime Chevallier
2025-03-14 16:23 ` [PATCH net-next v3 1/2] net: phy: sfp: Add support for SMBus module access Maxime Chevallier
2025-03-21 17:50 ` Paolo Abeni
2025-03-21 18:00 ` Maxime Chevallier
2025-03-14 16:23 ` [PATCH net-next v3 2/2] net: mdio: mdio-i2c: Add support for single-byte SMBus operations Maxime Chevallier
2025-03-21 17:53 ` Paolo Abeni
2025-03-21 18:02 ` Maxime Chevallier [this message]
2025-03-21 18:15 ` Maxime Chevallier
2025-03-17 21:34 ` [PATCH net-next v3 0/2] net: phy: sfp: Add single-byte SMBus SFP access Andrew Lunn
2025-03-18 8:25 ` Maxime Chevallier
2025-03-18 12:21 ` 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=20250321190237.0a98e8b7@fedora.home \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=atenart@kernel.org \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kabel@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=romain.gantois@bootlin.com \
--cc=sean.anderson@linux.dev \
--cc=thomas.petazzoni@bootlin.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.