From: Simon Horman <horms@kernel.org>
To: Linus Walleij <linusw@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/4] net: dsa: ks8955: Delete KSZ8864 and KSZ8795 support
Date: Wed, 21 Jan 2026 17:35:10 +0000 [thread overview]
Message-ID: <aXEOTvCiiCmG5_cN@horms.kernel.org> (raw)
In-Reply-To: <20260118-ks8995-fixups-v1-2-10a493f0339d@kernel.org>
On Sun, Jan 18, 2026 at 11:07:32PM +0100, Linus Walleij wrote:
...
> @@ -346,79 +291,37 @@ static int ks8995_reset(struct ks8995_switch *ks)
> static int ks8995_get_revision(struct ks8995_switch *ks)
> {
> int err;
> - u8 id0, id1, ksz8864_id;
> + u8 id0, id1;
>
> /* read family id */
> err = ks8995_read_reg(ks, KS8995_REG_ID0, &id0);
> - if (err) {
> - err = -EIO;
> - goto err_out;
> - }
> + if (err)
> + return -EIO;
>
> /* verify family id */
> - if (id0 != ks->chip->family_id) {
> + if (id0 != FAMILY_KS8995) {
> dev_err(&ks->spi->dev, "chip family id mismatch: expected 0x%02x but 0x%02x read\n",
> - ks->chip->family_id, id0);
> - err = -ENODEV;
> - goto err_out;
> + FAMILY_KS8995, id0);
> + return -ENODEV;
> }
>
> - switch (ks->chip->family_id) {
> - case FAMILY_KS8995:
> - /* try reading chip id at CHIP ID1 */
> - err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1);
> - if (err) {
> - err = -EIO;
> - goto err_out;
> - }
> -
> - /* verify chip id */
> - if ((get_chip_id(id1) == CHIPID_M) &&
> - (get_chip_id(id1) == ks->chip->chip_id)) {
> - /* KS8995MA */
> - ks->revision_id = get_chip_rev(id1);
> - } else if (get_chip_id(id1) != CHIPID_M) {
> - /* KSZ8864RMN */
> - err = ks8995_read_reg(ks, KS8995_REG_ID1, &ksz8864_id);
> - if (err) {
> - err = -EIO;
> - goto err_out;
> - }
> -
> - if ((ksz8864_id & 0x80) &&
> - (ks->chip->chip_id == KSZ8864_CHIP_ID)) {
> - ks->revision_id = get_chip_rev(id1);
> - }
> -
> - } else {
> - dev_err(&ks->spi->dev, "unsupported chip id for KS8995 family: 0x%02x\n",
> - id1);
> - err = -ENODEV;
> - }
> - break;
> - case FAMILY_KSZ8795:
> - /* try reading chip id at CHIP ID1 */
> - err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1);
> - if (err) {
> - err = -EIO;
> - goto err_out;
> - }
> + /* try reading chip id at CHIP ID1 */
> + err = ks8995_read_reg(ks, KS8995_REG_ID1, &id1);
> + if (err)
> + return -EIO;
>
> - if (get_chip_id(id1) == ks->chip->chip_id) {
> - ks->revision_id = get_chip_rev(id1);
> - } else {
> - dev_err(&ks->spi->dev, "unsupported chip id for KSZ8795 family: 0x%02x\n",
> - id1);
> - err = -ENODEV;
> - }
> - break;
> - default:
> - dev_err(&ks->spi->dev, "unsupported family id: 0x%02x\n", id0);
> - err = -ENODEV;
> - break;
> + /* verify chip id */
> + if ((get_chip_id(id1) == CHIPID_M) &&
> + (get_chip_id(id1) == KS8995_CHIP_ID)) {
Hi Linus,
This seems a little odd to me.
The condition can be true, but only because the constants are equal (0).
What is the intention here?
Flagged by Smatch.
> + /* KS8995MA */
> + ks->revision_id = get_chip_rev(id1);
> + } else {
> + dev_err(&ks->spi->dev, "unsupported chip id for KS8995 family: 0x%02x\n",
> + id1);
> + return -ENODEV;
> }
> -err_out:
> - return err;
> +
> + return 0;
> }
...
next prev parent reply other threads:[~2026-01-21 17:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-18 22:07 [PATCH net-next 0/4] net: dsa: ks8995: Post-move fixes Linus Walleij
2026-01-18 22:07 ` [PATCH net-next 1/4] net: dsa: ks8995: Add shutdown callback Linus Walleij
2026-01-18 22:07 ` [PATCH net-next 2/4] net: dsa: ks8955: Delete KSZ8864 and KSZ8795 support Linus Walleij
2026-01-21 17:35 ` Simon Horman [this message]
2026-01-18 22:07 ` [PATCH net-next 3/4] net: dsa: ks8995: Add stub bridge join/leave Linus Walleij
2026-01-18 22:07 ` [PATCH net-next 4/4] net: dsa: ks8995: Implement port isolation Linus Walleij
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=aXEOTvCiiCmG5_cN@horms.kernel.org \
--to=horms@kernel.org \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=woojung.huh@microchip.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox