lkml.org 
[lkml]   [2021]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 240/421] e100: handle eeprom as little endian
    Date
    From: Jesse Brandeburg <jesse.brandeburg@intel.com>

    [ Upstream commit d4ef55288aa2e1b76033717242728ac98ddc4721 ]

    Sparse tool was warning on some implicit conversions from
    little endian data read from the EEPROM on the e100 cards.

    Fix these by being explicit about the conversions using
    le16_to_cpu().

    Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/intel/e100.c | 12 ++++++------
    1 file changed, 6 insertions(+), 6 deletions(-)

    diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
    index 78b44d787638..bf64fab38385 100644
    --- a/drivers/net/ethernet/intel/e100.c
    +++ b/drivers/net/ethernet/intel/e100.c
    @@ -1398,7 +1398,7 @@ static int e100_phy_check_without_mii(struct nic *nic)
    u8 phy_type;
    int without_mii;

    - phy_type = (nic->eeprom[eeprom_phy_iface] >> 8) & 0x0f;
    + phy_type = (le16_to_cpu(nic->eeprom[eeprom_phy_iface]) >> 8) & 0x0f;

    switch (phy_type) {
    case NoSuchPhy: /* Non-MII PHY; UNTESTED! */
    @@ -1518,7 +1518,7 @@ static int e100_phy_init(struct nic *nic)
    mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr);
    } else if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) &&
    (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) &&
    - (nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) {
    + (le16_to_cpu(nic->eeprom[eeprom_cnfg_mdix]) & eeprom_mdix_enabled))) {
    /* enable/disable MDI/MDI-X auto-switching. */
    mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG,
    nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH);
    @@ -2264,9 +2264,9 @@ static int e100_asf(struct nic *nic)
    {
    /* ASF can be enabled from eeprom */
    return (nic->pdev->device >= 0x1050) && (nic->pdev->device <= 0x1057) &&
    - (nic->eeprom[eeprom_config_asf] & eeprom_asf) &&
    - !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) &&
    - ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE);
    + (le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_asf) &&
    + !(le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_gcl) &&
    + ((le16_to_cpu(nic->eeprom[eeprom_smbus_addr]) & 0xFF) != 0xFE);
    }

    static int e100_up(struct nic *nic)
    @@ -2922,7 +2922,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

    /* Wol magic packet can be enabled from eeprom */
    if ((nic->mac >= mac_82558_D101_A4) &&
    - (nic->eeprom[eeprom_id] & eeprom_id_wol)) {
    + (le16_to_cpu(nic->eeprom[eeprom_id]) & eeprom_id_wol)) {
    nic->flags |= wol_magic;
    device_set_wakeup_enable(&pdev->dev, true);
    }
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-07-19 18:40    [W:4.991 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site