Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 224767
b: refs/heads/master
c: 6a8872c
h: refs/heads/master
i:
  224765: f7f7e01
  224763: 669727f
  224759: 4118034
  224751: d9198b9
  224735: a01c6fd
  224703: 5746395
  224639: 163ec0c
  224511: 44fef57
  224255: 142e3d1
v: v3
  • Loading branch information
Ben Hutchings authored and David S. Miller committed Dec 3, 2010
1 parent fc4f87a commit 20004d2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 83 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6c88b0b6dc886e49c0e6ee21d677c2e380bde688
refs/heads/master: 6a8872c54d177abd900a0cf165b76ecb4803f052
59 changes: 0 additions & 59 deletions trunk/drivers/net/sfc/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "efx.h"
#include "filter.h"
#include "nic.h"
#include "spi.h"
#include "mdio_10g.h"

struct ethtool_string {
Expand Down Expand Up @@ -629,61 +628,6 @@ static u32 efx_ethtool_get_link(struct net_device *net_dev)
return efx->link_state.up;
}

static int efx_ethtool_get_eeprom_len(struct net_device *net_dev)
{
struct efx_nic *efx = netdev_priv(net_dev);
struct efx_spi_device *spi = efx->spi_eeprom;

if (!spi)
return 0;
return min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
min(spi->size, EFX_EEPROM_BOOTCONFIG_START);
}

static int efx_ethtool_get_eeprom(struct net_device *net_dev,
struct ethtool_eeprom *eeprom, u8 *buf)
{
struct efx_nic *efx = netdev_priv(net_dev);
struct efx_spi_device *spi = efx->spi_eeprom;
size_t len;
int rc;

rc = mutex_lock_interruptible(&efx->spi_lock);
if (rc)
return rc;
rc = falcon_spi_read(efx, spi,
eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
eeprom->len, &len, buf);
mutex_unlock(&efx->spi_lock);

eeprom->magic = EFX_ETHTOOL_EEPROM_MAGIC;
eeprom->len = len;
return rc;
}

static int efx_ethtool_set_eeprom(struct net_device *net_dev,
struct ethtool_eeprom *eeprom, u8 *buf)
{
struct efx_nic *efx = netdev_priv(net_dev);
struct efx_spi_device *spi = efx->spi_eeprom;
size_t len;
int rc;

if (eeprom->magic != EFX_ETHTOOL_EEPROM_MAGIC)
return -EINVAL;

rc = mutex_lock_interruptible(&efx->spi_lock);
if (rc)
return rc;
rc = falcon_spi_write(efx, spi,
eeprom->offset + EFX_EEPROM_BOOTCONFIG_START,
eeprom->len, &len, buf);
mutex_unlock(&efx->spi_lock);

eeprom->len = len;
return rc;
}

static int efx_ethtool_get_coalesce(struct net_device *net_dev,
struct ethtool_coalesce *coalesce)
{
Expand Down Expand Up @@ -1116,9 +1060,6 @@ const struct ethtool_ops efx_ethtool_ops = {
.set_msglevel = efx_ethtool_set_msglevel,
.nway_reset = efx_ethtool_nway_reset,
.get_link = efx_ethtool_get_link,
.get_eeprom_len = efx_ethtool_get_eeprom_len,
.get_eeprom = efx_ethtool_get_eeprom,
.set_eeprom = efx_ethtool_set_eeprom,
.get_coalesce = efx_ethtool_get_coalesce,
.set_coalesce = efx_ethtool_set_coalesce,
.get_ringparam = efx_ethtool_get_ringparam,
Expand Down
77 changes: 54 additions & 23 deletions trunk/drivers/net/sfc/mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,35 +387,66 @@ static struct efx_mtd_ops falcon_mtd_ops = {

static int falcon_mtd_probe(struct efx_nic *efx)
{
struct efx_spi_device *spi = efx->spi_flash;
struct efx_spi_device *spi;
struct efx_mtd *efx_mtd;
int rc;
int rc = -ENODEV;

ASSERT_RTNL();

if (!spi || spi->size <= FALCON_FLASH_BOOTCODE_START)
return -ENODEV;

efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
GFP_KERNEL);
if (!efx_mtd)
return -ENOMEM;

efx_mtd->spi = spi;
efx_mtd->name = "flash";
efx_mtd->ops = &falcon_mtd_ops;
spi = efx->spi_flash;
if (spi && spi->size > FALCON_FLASH_BOOTCODE_START) {
efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
GFP_KERNEL);
if (!efx_mtd)
return -ENOMEM;

efx_mtd->spi = spi;
efx_mtd->name = "flash";
efx_mtd->ops = &falcon_mtd_ops;

efx_mtd->n_parts = 1;
efx_mtd->part[0].mtd.type = MTD_NORFLASH;
efx_mtd->part[0].mtd.flags = MTD_CAP_NORFLASH;
efx_mtd->part[0].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
efx_mtd->part[0].mtd.erasesize = spi->erase_size;
efx_mtd->part[0].offset = FALCON_FLASH_BOOTCODE_START;
efx_mtd->part[0].type_name = "sfc_flash_bootrom";

rc = efx_mtd_probe_device(efx, efx_mtd);
if (rc) {
kfree(efx_mtd);
return rc;
}
}

efx_mtd->n_parts = 1;
efx_mtd->part[0].mtd.type = MTD_NORFLASH;
efx_mtd->part[0].mtd.flags = MTD_CAP_NORFLASH;
efx_mtd->part[0].mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
efx_mtd->part[0].mtd.erasesize = spi->erase_size;
efx_mtd->part[0].offset = FALCON_FLASH_BOOTCODE_START;
efx_mtd->part[0].type_name = "sfc_flash_bootrom";
spi = efx->spi_eeprom;
if (spi && spi->size > EFX_EEPROM_BOOTCONFIG_START) {
efx_mtd = kzalloc(sizeof(*efx_mtd) + sizeof(efx_mtd->part[0]),
GFP_KERNEL);
if (!efx_mtd)
return -ENOMEM;

efx_mtd->spi = spi;
efx_mtd->name = "EEPROM";
efx_mtd->ops = &falcon_mtd_ops;

efx_mtd->n_parts = 1;
efx_mtd->part[0].mtd.type = MTD_RAM;
efx_mtd->part[0].mtd.flags = MTD_CAP_RAM;
efx_mtd->part[0].mtd.size =
min(spi->size, EFX_EEPROM_BOOTCONFIG_END) -
EFX_EEPROM_BOOTCONFIG_START;
efx_mtd->part[0].mtd.erasesize = spi->erase_size;
efx_mtd->part[0].offset = EFX_EEPROM_BOOTCONFIG_START;
efx_mtd->part[0].type_name = "sfc_bootconfig";

rc = efx_mtd_probe_device(efx, efx_mtd);
if (rc) {
kfree(efx_mtd);
return rc;
}
}

rc = efx_mtd_probe_device(efx, efx_mtd);
if (rc)
kfree(efx_mtd);
return rc;
}

Expand Down

0 comments on commit 20004d2

Please sign in to comment.