Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: rmk+kernel@arm.linux.org.uk
Cc: linux-hwmon@vger.kernel.org
Subject: [bug report] sfp: add SFP module support
Date: Mon, 18 Jul 2022 16:00:55 +0300	[thread overview]
Message-ID: <YtVZh357cANVAxey@kili> (raw)

Hi Russell,

The patch 73970055450e: "sfp: add SFP module support" from Jul 25,
2017, leads to the following Smatch static checker warnings:

drivers/net/phy/sfp.c:474 sfp_soft_get_state() warn: passing zero to 'ERR_PTR'
drivers/net/phy/sfp.c:1710 sfp_sm_mod_hpower() warn: passing zero to 'ERR_PTR'
drivers/net/phy/sfp.c:1728 sfp_sm_mod_hpower() warn: passing zero to 'ERR_PTR'
drivers/net/phy/sfp.c:1781 sfp_cotsworks_fixup_check() warn: passing zero to 'ERR_PTR'
drivers/net/phy/sfp.c:1794 sfp_cotsworks_fixup_check() warn: passing zero to 'ERR_PTR'
drivers/net/phy/sfp.c:1827 sfp_sm_mod_probe() warn: passing zero to 'ERR_PTR'
drivers/net/phy/sfp.c:1854 sfp_sm_mod_probe() warn: passing zero to 'ERR_PTR'
drivers/net/phy/sfp.c:1903 sfp_sm_mod_probe() warn: passing zero to 'ERR_PTR'

drivers/net/phy/sfp.c
    1767 static int sfp_cotsworks_fixup_check(struct sfp *sfp, struct sfp_eeprom_id *id)
    1768 {
    1769         u8 check;
    1770         int err;
    1771 
    1772         if (id->base.phys_id != SFF8024_ID_SFF_8472 ||
    1773             id->base.phys_ext_id != SFP_PHYS_EXT_ID_SFP ||
    1774             id->base.connector != SFF8024_CONNECTOR_LC) {
    1775                 dev_warn(sfp->dev, "Rewriting fiber module EEPROM with corrected values\n");
    1776                 id->base.phys_id = SFF8024_ID_SFF_8472;
    1777                 id->base.phys_ext_id = SFP_PHYS_EXT_ID_SFP;
    1778                 id->base.connector = SFF8024_CONNECTOR_LC;
    1779                 err = sfp_write(sfp, false, SFP_PHYS_ID, &id->base, 3);
    1780                 if (err != 3) {
    1781                         dev_err(sfp->dev,
    1782                                 "Failed to rewrite module EEPROM: %pe\n",
    1783                                 ERR_PTR(err));

The sfp_i2c_read/write() functions return negatives for errors, zero for
partial read/writes and len (3 in this case) for success.  If we have
to bail out at this point, the I feel we should return a negative error
code instead of success.

    1784                         return err;
    1785                 }
    1786 
    1787                 /* Cotsworks modules have been found to require a delay between write operations. */
    1788                 mdelay(50);
    1789 
    1790                 /* Update base structure checksum */
    1791                 check = sfp_check(&id->base, sizeof(id->base) - 1);
    1792                 err = sfp_write(sfp, false, SFP_CC_BASE, &check, 1);
    1793                 if (err != 1) {
--> 1794                         dev_err(sfp->dev,
    1795                                 "Failed to update base structure checksum in fiber module EEPROM: %pe\n",
    1796                                 ERR_PTR(err));
    1797                         return err;
    1798                 }
    1799         }
    1800         return 0;
    1801 }

regards,
dan carpenter

             reply	other threads:[~2022-07-18 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 13:00 Dan Carpenter [this message]
2022-07-18 13:09 ` [bug report] sfp: add SFP module support Russell King (Oracle)

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=YtVZh357cANVAxey@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=rmk+kernel@arm.linux.org.uk \
    /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