2008-11-04 20:34:28 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* Driver for Solarflare Solarstorm network controllers and boards
|
|
|
|
* Copyright 2005-2006 Fen Systems Ltd.
|
2011-02-25 00:01:34 +00:00
|
|
|
* Copyright 2006-2010 Solarflare Communications Inc.
|
2008-11-04 20:34:28 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation, incorporated herein by reference.
|
|
|
|
*/
|
|
|
|
|
2009-11-29 15:15:41 +00:00
|
|
|
#include <linux/bitops.h>
|
2008-11-04 20:34:28 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mtd/mtd.h>
|
|
|
|
#include <linux/delay.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2009-11-29 15:10:44 +00:00
|
|
|
#include <linux/rtnetlink.h>
|
2008-11-04 20:34:28 +00:00
|
|
|
|
|
|
|
#include "net_driver.h"
|
|
|
|
#include "spi.h"
|
2009-02-19 01:49:50 +00:00
|
|
|
#include "efx.h"
|
2009-11-29 15:12:08 +00:00
|
|
|
#include "nic.h"
|
2009-11-29 15:15:41 +00:00
|
|
|
#include "mcdi.h"
|
|
|
|
#include "mcdi_pcol.h"
|
2008-11-04 20:34:28 +00:00
|
|
|
|
2012-11-28 04:12:41 +00:00
|
|
|
#define FALCON_SPI_VERIFY_BUF_LEN 16
|
2008-11-04 20:34:28 +00:00
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
struct efx_mtd_partition {
|
2012-11-28 04:38:10 +00:00
|
|
|
struct list_head node;
|
2008-11-04 20:34:28 +00:00
|
|
|
struct mtd_info mtd;
|
2012-11-28 04:38:10 +00:00
|
|
|
const char *dev_type_name;
|
2009-11-29 15:10:44 +00:00
|
|
|
const char *type_name;
|
2008-11-04 20:34:28 +00:00
|
|
|
char name[IFNAMSIZ + 20];
|
|
|
|
};
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
struct falcon_mtd_partition {
|
|
|
|
struct efx_mtd_partition common;
|
|
|
|
const struct falcon_spi_device *spi;
|
|
|
|
size_t offset;
|
|
|
|
};
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
struct efx_mtd_ops {
|
2012-11-28 04:38:14 +00:00
|
|
|
void (*rename)(struct efx_mtd_partition *part);
|
2009-11-29 15:10:44 +00:00
|
|
|
int (*read)(struct mtd_info *mtd, loff_t start, size_t len,
|
|
|
|
size_t *retlen, u8 *buffer);
|
|
|
|
int (*erase)(struct mtd_info *mtd, loff_t start, size_t len);
|
|
|
|
int (*write)(struct mtd_info *mtd, loff_t start, size_t len,
|
|
|
|
size_t *retlen, const u8 *buffer);
|
|
|
|
int (*sync)(struct mtd_info *mtd);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_efx_mtd_partition(mtd) \
|
|
|
|
container_of(mtd, struct efx_mtd_partition, mtd)
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
#define to_falcon_mtd_partition(mtd) \
|
|
|
|
container_of(mtd, struct falcon_mtd_partition, common.mtd)
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int falcon_mtd_probe(struct efx_nic *efx);
|
2009-11-29 15:15:41 +00:00
|
|
|
static int siena_mtd_probe(struct efx_nic *efx);
|
2009-11-29 15:10:44 +00:00
|
|
|
|
2008-11-04 20:34:28 +00:00
|
|
|
/* SPI utilities */
|
|
|
|
|
2010-06-23 11:29:24 +00:00
|
|
|
static int
|
2012-11-28 04:38:14 +00:00
|
|
|
falcon_spi_slow_wait(struct falcon_mtd_partition *part, bool uninterruptible)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
const struct falcon_spi_device *spi = part->spi;
|
|
|
|
struct efx_nic *efx = part->common.mtd.priv;
|
2008-11-04 20:34:28 +00:00
|
|
|
u8 status;
|
|
|
|
int rc, i;
|
|
|
|
|
|
|
|
/* Wait up to 4s for flash/EEPROM to finish a slow operation. */
|
|
|
|
for (i = 0; i < 40; i++) {
|
|
|
|
__set_current_state(uninterruptible ?
|
|
|
|
TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE);
|
|
|
|
schedule_timeout(HZ / 10);
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
|
2008-11-04 20:34:28 +00:00
|
|
|
&status, sizeof(status));
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
if (!(status & SPI_STATUS_NRDY))
|
|
|
|
return 0;
|
|
|
|
if (signal_pending(current))
|
|
|
|
return -EINTR;
|
|
|
|
}
|
2012-11-28 04:38:10 +00:00
|
|
|
pr_err("%s: timed out waiting for %s\n",
|
2012-11-28 04:38:14 +00:00
|
|
|
part->common.name, part->common.dev_type_name);
|
2008-11-04 20:34:28 +00:00
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int
|
2012-11-28 04:12:41 +00:00
|
|
|
falcon_spi_unlock(struct efx_nic *efx, const struct falcon_spi_device *spi)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
|
|
|
const u8 unlock_mask = (SPI_STATUS_BP2 | SPI_STATUS_BP1 |
|
|
|
|
SPI_STATUS_BP0);
|
|
|
|
u8 status;
|
|
|
|
int rc;
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_cmd(efx, spi, SPI_RDSR, -1, NULL,
|
|
|
|
&status, sizeof(status));
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
if (!(status & unlock_mask))
|
|
|
|
return 0; /* already unlocked */
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_cmd(efx, spi, SPI_SST_EWSR, -1, NULL, NULL, 0);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
status &= ~unlock_mask;
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_cmd(efx, spi, SPI_WRSR, -1, &status,
|
|
|
|
NULL, sizeof(status));
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_wait_write(efx, spi);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-23 11:29:24 +00:00
|
|
|
static int
|
2012-11-28 04:38:14 +00:00
|
|
|
falcon_spi_erase(struct falcon_mtd_partition *part, loff_t start, size_t len)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
const struct falcon_spi_device *spi = part->spi;
|
|
|
|
struct efx_nic *efx = part->common.mtd.priv;
|
2008-11-04 20:34:28 +00:00
|
|
|
unsigned pos, block_len;
|
2012-11-28 04:12:41 +00:00
|
|
|
u8 empty[FALCON_SPI_VERIFY_BUF_LEN];
|
|
|
|
u8 buffer[FALCON_SPI_VERIFY_BUF_LEN];
|
2008-11-04 20:34:28 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (len != spi->erase_size)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (spi->erase_command == 0)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-11-28 04:12:41 +00:00
|
|
|
rc = falcon_spi_unlock(efx, spi);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_cmd(efx, spi, SPI_WREN, -1, NULL, NULL, 0);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_cmd(efx, spi, spi->erase_command, start, NULL,
|
|
|
|
NULL, 0);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2012-11-28 04:12:41 +00:00
|
|
|
rc = falcon_spi_slow_wait(part, false);
|
2008-11-04 20:34:28 +00:00
|
|
|
|
|
|
|
/* Verify the entire region has been wiped */
|
|
|
|
memset(empty, 0xff, sizeof(empty));
|
|
|
|
for (pos = 0; pos < len; pos += block_len) {
|
|
|
|
block_len = min(len - pos, sizeof(buffer));
|
2009-11-29 15:10:44 +00:00
|
|
|
rc = falcon_spi_read(efx, spi, start + pos, block_len,
|
|
|
|
NULL, buffer);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
if (memcmp(empty, buffer, block_len))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
/* Avoid locking up the system */
|
|
|
|
cond_resched();
|
|
|
|
if (signal_pending(current))
|
|
|
|
return -EINTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MTD interface */
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int efx_mtd_erase(struct mtd_info *mtd, struct erase_info *erase)
|
|
|
|
{
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2009-11-29 15:10:44 +00:00
|
|
|
int rc;
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
rc = efx->mtd_ops->erase(mtd, erase->addr, erase->len);
|
2009-11-29 15:10:44 +00:00
|
|
|
if (rc == 0) {
|
|
|
|
erase->state = MTD_ERASE_DONE;
|
|
|
|
} else {
|
|
|
|
erase->state = MTD_ERASE_FAILED;
|
2012-02-12 09:13:08 +00:00
|
|
|
erase->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
mtd_erase_callback(erase);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_mtd_sync(struct mtd_info *mtd)
|
|
|
|
{
|
2010-06-23 11:29:24 +00:00
|
|
|
struct efx_mtd_partition *part = to_efx_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2009-11-29 15:10:44 +00:00
|
|
|
int rc;
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
rc = efx->mtd_ops->sync(mtd);
|
2009-11-29 15:10:44 +00:00
|
|
|
if (rc)
|
2010-06-23 11:29:24 +00:00
|
|
|
pr_err("%s: %s sync failed (%d)\n",
|
2012-11-28 04:38:10 +00:00
|
|
|
part->name, part->dev_type_name, rc);
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void efx_mtd_remove_partition(struct efx_mtd_partition *part)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
for (;;) {
|
2011-05-23 09:23:40 +00:00
|
|
|
rc = mtd_device_unregister(&part->mtd);
|
2009-11-29 15:10:44 +00:00
|
|
|
if (rc != -EBUSY)
|
|
|
|
break;
|
|
|
|
ssleep(1);
|
|
|
|
}
|
|
|
|
WARN_ON(rc);
|
2012-11-28 04:38:10 +00:00
|
|
|
list_del(&part->node);
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
static void efx_mtd_rename_partition(struct efx_mtd_partition *part)
|
2009-11-29 15:10:44 +00:00
|
|
|
{
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = part->mtd.priv;
|
2009-11-29 15:10:44 +00:00
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
efx->mtd_ops->rename(part);
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
static int efx_mtd_add(struct efx_nic *efx, struct efx_mtd_partition *parts,
|
|
|
|
size_t n_parts, size_t sizeof_part)
|
2009-11-29 15:10:44 +00:00
|
|
|
{
|
|
|
|
struct efx_mtd_partition *part;
|
2012-11-28 04:38:10 +00:00
|
|
|
size_t i;
|
2009-11-29 15:10:44 +00:00
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
for (i = 0; i < n_parts; i++) {
|
2012-11-28 04:38:14 +00:00
|
|
|
part = (struct efx_mtd_partition *)((char *)parts +
|
|
|
|
i * sizeof_part);
|
2009-11-29 15:10:44 +00:00
|
|
|
|
|
|
|
part->mtd.writesize = 1;
|
|
|
|
|
|
|
|
part->mtd.owner = THIS_MODULE;
|
2012-11-28 04:38:10 +00:00
|
|
|
part->mtd.priv = efx;
|
2009-11-29 15:10:44 +00:00
|
|
|
part->mtd.name = part->name;
|
2012-01-30 12:58:32 +00:00
|
|
|
part->mtd._erase = efx_mtd_erase;
|
2012-11-28 04:38:10 +00:00
|
|
|
part->mtd._read = efx->mtd_ops->read;
|
|
|
|
part->mtd._write = efx->mtd_ops->write;
|
2012-01-30 12:58:32 +00:00
|
|
|
part->mtd._sync = efx_mtd_sync;
|
2009-11-29 15:10:44 +00:00
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
efx_mtd_rename_partition(part);
|
|
|
|
|
2011-05-23 09:23:40 +00:00
|
|
|
if (mtd_device_register(&part->mtd, NULL, 0))
|
2009-11-29 15:10:44 +00:00
|
|
|
goto fail;
|
2012-11-28 04:38:10 +00:00
|
|
|
|
|
|
|
/* Add to list in order - efx_mtd_remove() depends on this */
|
|
|
|
list_add_tail(&part->node, &efx->mtd_list);
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
2012-11-28 04:38:14 +00:00
|
|
|
while (i--) {
|
|
|
|
part = (struct efx_mtd_partition *)((char *)parts +
|
|
|
|
i * sizeof_part);
|
|
|
|
efx_mtd_remove_partition(part);
|
|
|
|
}
|
2012-01-27 17:23:58 +00:00
|
|
|
/* Failure is unlikely here, but probably means we're out of memory */
|
2009-11-29 15:10:44 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
void efx_mtd_remove(struct efx_nic *efx)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_mtd_partition *parts, *part, *next;
|
2009-11-29 15:10:44 +00:00
|
|
|
|
|
|
|
WARN_ON(efx_dev_registered(efx));
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
if (list_empty(&efx->mtd_list))
|
|
|
|
return;
|
|
|
|
|
|
|
|
parts = list_first_entry(&efx->mtd_list, struct efx_mtd_partition,
|
|
|
|
node);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(part, next, &efx->mtd_list, node)
|
|
|
|
efx_mtd_remove_partition(part);
|
|
|
|
|
|
|
|
kfree(parts);
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void efx_mtd_rename(struct efx_nic *efx)
|
|
|
|
{
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_mtd_partition *part;
|
2009-11-29 15:10:44 +00:00
|
|
|
|
|
|
|
ASSERT_RTNL();
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
list_for_each_entry(part, &efx->mtd_list, node)
|
|
|
|
efx_mtd_rename_partition(part);
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int efx_mtd_probe(struct efx_nic *efx)
|
|
|
|
{
|
2009-11-29 15:15:41 +00:00
|
|
|
if (efx_nic_rev(efx) >= EFX_REV_SIENA_A0)
|
|
|
|
return siena_mtd_probe(efx);
|
|
|
|
else
|
|
|
|
return falcon_mtd_probe(efx);
|
2009-11-29 15:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Implementation of MTD operations for Falcon */
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
static void falcon_mtd_rename(struct efx_mtd_partition *part)
|
|
|
|
{
|
|
|
|
struct efx_nic *efx = part->mtd.priv;
|
|
|
|
|
|
|
|
snprintf(part->name, sizeof(part->name), "%s %s",
|
|
|
|
efx->name, part->type_name);
|
|
|
|
}
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int falcon_mtd_read(struct mtd_info *mtd, loff_t start,
|
|
|
|
size_t len, size_t *retlen, u8 *buffer)
|
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2010-12-02 13:47:29 +00:00
|
|
|
struct falcon_nic_data *nic_data = efx->nic_data;
|
2008-11-04 20:34:28 +00:00
|
|
|
int rc;
|
|
|
|
|
2010-12-02 13:47:29 +00:00
|
|
|
rc = mutex_lock_interruptible(&nic_data->spi_lock);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = falcon_spi_read(efx, part->spi, part->offset + start,
|
2012-11-28 04:38:10 +00:00
|
|
|
len, retlen, buffer);
|
2010-12-02 13:47:29 +00:00
|
|
|
mutex_unlock(&nic_data->spi_lock);
|
2008-11-04 20:34:28 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int falcon_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2010-12-02 13:47:29 +00:00
|
|
|
struct falcon_nic_data *nic_data = efx->nic_data;
|
2008-11-04 20:34:28 +00:00
|
|
|
int rc;
|
|
|
|
|
2010-12-02 13:47:29 +00:00
|
|
|
rc = mutex_lock_interruptible(&nic_data->spi_lock);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = falcon_spi_erase(part, part->offset + start, len);
|
2010-12-02 13:47:29 +00:00
|
|
|
mutex_unlock(&nic_data->spi_lock);
|
2008-11-04 20:34:28 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int falcon_mtd_write(struct mtd_info *mtd, loff_t start,
|
|
|
|
size_t len, size_t *retlen, const u8 *buffer)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2010-12-02 13:47:29 +00:00
|
|
|
struct falcon_nic_data *nic_data = efx->nic_data;
|
2008-11-04 20:34:28 +00:00
|
|
|
int rc;
|
|
|
|
|
2010-12-02 13:47:29 +00:00
|
|
|
rc = mutex_lock_interruptible(&nic_data->spi_lock);
|
2008-11-04 20:34:28 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = falcon_spi_write(efx, part->spi, part->offset + start,
|
|
|
|
len, retlen, buffer);
|
2010-12-02 13:47:29 +00:00
|
|
|
mutex_unlock(&nic_data->spi_lock);
|
2008-11-04 20:34:28 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int falcon_mtd_sync(struct mtd_info *mtd)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct falcon_mtd_partition *part = to_falcon_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2010-12-02 13:47:29 +00:00
|
|
|
struct falcon_nic_data *nic_data = efx->nic_data;
|
2008-11-04 20:34:28 +00:00
|
|
|
int rc;
|
|
|
|
|
2010-12-02 13:47:29 +00:00
|
|
|
mutex_lock(&nic_data->spi_lock);
|
2012-11-28 04:12:41 +00:00
|
|
|
rc = falcon_spi_slow_wait(part, true);
|
2010-12-02 13:47:29 +00:00
|
|
|
mutex_unlock(&nic_data->spi_lock);
|
2009-11-29 15:10:44 +00:00
|
|
|
return rc;
|
2008-11-04 20:34:28 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 19:05:20 +00:00
|
|
|
static const struct efx_mtd_ops falcon_mtd_ops = {
|
2012-11-28 04:38:14 +00:00
|
|
|
.rename = falcon_mtd_rename,
|
2009-11-29 15:10:44 +00:00
|
|
|
.read = falcon_mtd_read,
|
|
|
|
.erase = falcon_mtd_erase,
|
|
|
|
.write = falcon_mtd_write,
|
|
|
|
.sync = falcon_mtd_sync,
|
|
|
|
};
|
2008-11-04 20:34:28 +00:00
|
|
|
|
2009-11-29 15:10:44 +00:00
|
|
|
static int falcon_mtd_probe(struct efx_nic *efx)
|
2008-11-04 20:34:28 +00:00
|
|
|
{
|
2010-12-02 13:47:29 +00:00
|
|
|
struct falcon_nic_data *nic_data = efx->nic_data;
|
2012-11-28 04:38:14 +00:00
|
|
|
struct falcon_mtd_partition *parts;
|
2012-11-28 04:12:41 +00:00
|
|
|
struct falcon_spi_device *spi;
|
2012-11-28 04:38:10 +00:00
|
|
|
size_t n_parts;
|
2010-12-02 13:47:10 +00:00
|
|
|
int rc = -ENODEV;
|
2009-11-29 15:10:44 +00:00
|
|
|
|
|
|
|
ASSERT_RTNL();
|
2008-11-04 20:34:28 +00:00
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
efx->mtd_ops = &falcon_mtd_ops;
|
|
|
|
|
|
|
|
/* Allocate space for maximum number of partitions */
|
|
|
|
parts = kcalloc(2, sizeof(*parts), GFP_KERNEL);
|
|
|
|
n_parts = 0;
|
|
|
|
|
2010-12-02 13:47:29 +00:00
|
|
|
spi = &nic_data->spi_flash;
|
2012-11-28 04:12:41 +00:00
|
|
|
if (falcon_spi_present(spi) && spi->size > FALCON_FLASH_BOOTCODE_START) {
|
2012-11-28 04:38:14 +00:00
|
|
|
parts[n_parts].spi = spi;
|
|
|
|
parts[n_parts].offset = FALCON_FLASH_BOOTCODE_START;
|
|
|
|
parts[n_parts].common.dev_type_name = "flash";
|
|
|
|
parts[n_parts].common.type_name = "sfc_flash_bootrom";
|
|
|
|
parts[n_parts].common.mtd.type = MTD_NORFLASH;
|
|
|
|
parts[n_parts].common.mtd.flags = MTD_CAP_NORFLASH;
|
|
|
|
parts[n_parts].common.mtd.size = spi->size - FALCON_FLASH_BOOTCODE_START;
|
|
|
|
parts[n_parts].common.mtd.erasesize = spi->erase_size;
|
2012-11-28 04:38:10 +00:00
|
|
|
n_parts++;
|
2010-12-02 13:47:10 +00:00
|
|
|
}
|
2009-11-29 15:10:44 +00:00
|
|
|
|
2010-12-02 13:47:29 +00:00
|
|
|
spi = &nic_data->spi_eeprom;
|
2012-11-28 04:12:41 +00:00
|
|
|
if (falcon_spi_present(spi) && spi->size > FALCON_EEPROM_BOOTCONFIG_START) {
|
2012-11-28 04:38:14 +00:00
|
|
|
parts[n_parts].spi = spi;
|
|
|
|
parts[n_parts].offset = FALCON_EEPROM_BOOTCONFIG_START;
|
|
|
|
parts[n_parts].common.dev_type_name = "EEPROM";
|
|
|
|
parts[n_parts].common.type_name = "sfc_bootconfig";
|
|
|
|
parts[n_parts].common.mtd.type = MTD_RAM;
|
|
|
|
parts[n_parts].common.mtd.flags = MTD_CAP_RAM;
|
|
|
|
parts[n_parts].common.mtd.size =
|
2012-11-28 04:12:41 +00:00
|
|
|
min(spi->size, FALCON_EEPROM_BOOTCONFIG_END) -
|
|
|
|
FALCON_EEPROM_BOOTCONFIG_START;
|
2012-11-28 04:38:14 +00:00
|
|
|
parts[n_parts].common.mtd.erasesize = spi->erase_size;
|
2012-11-28 04:38:10 +00:00
|
|
|
n_parts++;
|
2010-12-02 13:47:10 +00:00
|
|
|
}
|
2009-11-29 15:10:44 +00:00
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
|
2012-11-28 04:38:10 +00:00
|
|
|
if (rc)
|
|
|
|
kfree(parts);
|
2009-11-29 15:10:44 +00:00
|
|
|
return rc;
|
2008-11-04 20:34:28 +00:00
|
|
|
}
|
2009-11-29 15:15:41 +00:00
|
|
|
|
|
|
|
/* Implementation of MTD operations for Siena */
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition {
|
|
|
|
struct efx_mtd_partition common;
|
|
|
|
bool updating;
|
|
|
|
u8 nvram_type;
|
|
|
|
u16 fw_subtype;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_efx_mcdi_mtd_partition(mtd) \
|
|
|
|
container_of(mtd, struct efx_mcdi_mtd_partition, common.mtd)
|
|
|
|
|
|
|
|
static void siena_mtd_rename(struct efx_mtd_partition *part)
|
|
|
|
{
|
|
|
|
struct efx_mcdi_mtd_partition *mcdi_part =
|
|
|
|
container_of(part, struct efx_mcdi_mtd_partition, common);
|
|
|
|
struct efx_nic *efx = part->mtd.priv;
|
|
|
|
|
|
|
|
snprintf(part->name, sizeof(part->name), "%s %s:%02x",
|
|
|
|
efx->name, part->type_name, mcdi_part->fw_subtype);
|
|
|
|
}
|
|
|
|
|
2009-11-29 15:15:41 +00:00
|
|
|
static int siena_mtd_read(struct mtd_info *mtd, loff_t start,
|
|
|
|
size_t len, size_t *retlen, u8 *buffer)
|
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2009-11-29 15:15:41 +00:00
|
|
|
loff_t offset = start;
|
|
|
|
loff_t end = min_t(loff_t, start + len, mtd->size);
|
|
|
|
size_t chunk;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
while (offset < end) {
|
2010-01-25 23:49:59 +00:00
|
|
|
chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX);
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = efx_mcdi_nvram_read(efx, part->nvram_type, offset,
|
2009-11-29 15:15:41 +00:00
|
|
|
buffer, chunk);
|
|
|
|
if (rc)
|
|
|
|
goto out;
|
|
|
|
offset += chunk;
|
|
|
|
buffer += chunk;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
*retlen = offset - start;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int siena_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len)
|
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2009-11-29 15:15:41 +00:00
|
|
|
loff_t offset = start & ~((loff_t)(mtd->erasesize - 1));
|
|
|
|
loff_t end = min_t(loff_t, start + len, mtd->size);
|
2012-11-28 04:38:14 +00:00
|
|
|
size_t chunk = part->common.mtd.erasesize;
|
2009-11-29 15:15:41 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
if (!part->updating) {
|
|
|
|
rc = efx_mcdi_nvram_update_start(efx, part->nvram_type);
|
2009-11-29 15:15:41 +00:00
|
|
|
if (rc)
|
|
|
|
goto out;
|
2012-11-28 04:38:14 +00:00
|
|
|
part->updating = true;
|
2009-11-29 15:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The MCDI interface can in fact do multiple erase blocks at once;
|
|
|
|
* but erasing may be slow, so we make multiple calls here to avoid
|
|
|
|
* tripping the MCDI RPC timeout. */
|
|
|
|
while (offset < end) {
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = efx_mcdi_nvram_erase(efx, part->nvram_type, offset,
|
2009-11-29 15:15:41 +00:00
|
|
|
chunk);
|
|
|
|
if (rc)
|
|
|
|
goto out;
|
|
|
|
offset += chunk;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int siena_mtd_write(struct mtd_info *mtd, loff_t start,
|
|
|
|
size_t len, size_t *retlen, const u8 *buffer)
|
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2009-11-29 15:15:41 +00:00
|
|
|
loff_t offset = start;
|
|
|
|
loff_t end = min_t(loff_t, start + len, mtd->size);
|
|
|
|
size_t chunk;
|
|
|
|
int rc = 0;
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
if (!part->updating) {
|
|
|
|
rc = efx_mcdi_nvram_update_start(efx, part->nvram_type);
|
2009-11-29 15:15:41 +00:00
|
|
|
if (rc)
|
|
|
|
goto out;
|
2012-11-28 04:38:14 +00:00
|
|
|
part->updating = true;
|
2009-11-29 15:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (offset < end) {
|
2010-01-25 23:49:59 +00:00
|
|
|
chunk = min_t(size_t, end - offset, EFX_MCDI_NVRAM_LEN_MAX);
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = efx_mcdi_nvram_write(efx, part->nvram_type, offset,
|
2009-11-29 15:15:41 +00:00
|
|
|
buffer, chunk);
|
|
|
|
if (rc)
|
|
|
|
goto out;
|
|
|
|
offset += chunk;
|
|
|
|
buffer += chunk;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
*retlen = offset - start;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int siena_mtd_sync(struct mtd_info *mtd)
|
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition *part = to_efx_mcdi_mtd_partition(mtd);
|
2012-11-28 04:38:10 +00:00
|
|
|
struct efx_nic *efx = mtd->priv;
|
2009-11-29 15:15:41 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
if (part->updating) {
|
|
|
|
part->updating = false;
|
|
|
|
rc = efx_mcdi_nvram_update_finish(efx, part->nvram_type);
|
2009-11-29 15:15:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-01-05 19:05:20 +00:00
|
|
|
static const struct efx_mtd_ops siena_mtd_ops = {
|
2012-11-28 04:38:14 +00:00
|
|
|
.rename = siena_mtd_rename,
|
2009-11-29 15:15:41 +00:00
|
|
|
.read = siena_mtd_read,
|
|
|
|
.erase = siena_mtd_erase,
|
|
|
|
.write = siena_mtd_write,
|
|
|
|
.sync = siena_mtd_sync,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct siena_nvram_type_info {
|
|
|
|
int port;
|
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
2012-01-05 19:05:20 +00:00
|
|
|
static const struct siena_nvram_type_info siena_nvram_types[] = {
|
2009-11-29 15:15:41 +00:00
|
|
|
[MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO] = { 0, "sfc_dummy_phy" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_MC_FW] = { 0, "sfc_mcfw" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_MC_FW_BACKUP] = { 0, "sfc_mcfw_backup" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT0] = { 0, "sfc_static_cfg" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_STATIC_CFG_PORT1] = { 1, "sfc_static_cfg" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT0] = { 0, "sfc_dynamic_cfg" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_DYNAMIC_CFG_PORT1] = { 1, "sfc_dynamic_cfg" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_EXP_ROM] = { 0, "sfc_exp_rom" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT0] = { 0, "sfc_exp_rom_cfg" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_EXP_ROM_CFG_PORT1] = { 1, "sfc_exp_rom_cfg" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_PHY_PORT0] = { 0, "sfc_phy_fw" },
|
|
|
|
[MC_CMD_NVRAM_TYPE_PHY_PORT1] = { 1, "sfc_phy_fw" },
|
2011-07-04 23:05:56 +00:00
|
|
|
[MC_CMD_NVRAM_TYPE_FPGA] = { 0, "sfc_fpga" },
|
2009-11-29 15:15:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int siena_mtd_probe_partition(struct efx_nic *efx,
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition *part,
|
2009-11-29 15:15:41 +00:00
|
|
|
unsigned int type)
|
|
|
|
{
|
2012-01-05 19:05:20 +00:00
|
|
|
const struct siena_nvram_type_info *info;
|
2009-11-29 15:15:41 +00:00
|
|
|
size_t size, erase_size;
|
|
|
|
bool protected;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-04 23:05:56 +00:00
|
|
|
if (type >= ARRAY_SIZE(siena_nvram_types) ||
|
|
|
|
siena_nvram_types[type].name == NULL)
|
2009-11-29 15:15:41 +00:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
info = &siena_nvram_types[type];
|
|
|
|
|
|
|
|
if (info->port != efx_port_num(efx))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
rc = efx_mcdi_nvram_info(efx, type, &size, &erase_size, &protected);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
if (protected)
|
|
|
|
return -ENODEV; /* hide it */
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
part->nvram_type = type;
|
|
|
|
part->common.dev_type_name = "Siena NVRAM manager";
|
|
|
|
part->common.type_name = info->name;
|
2009-11-29 15:15:41 +00:00
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
part->common.mtd.type = MTD_NORFLASH;
|
|
|
|
part->common.mtd.flags = MTD_CAP_NORFLASH;
|
|
|
|
part->common.mtd.size = size;
|
|
|
|
part->common.mtd.erasesize = erase_size;
|
2009-11-29 15:15:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int siena_mtd_get_fw_subtypes(struct efx_nic *efx,
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition *parts,
|
2012-11-28 04:38:10 +00:00
|
|
|
size_t n_parts)
|
2009-11-29 15:15:41 +00:00
|
|
|
{
|
2011-07-04 23:04:42 +00:00
|
|
|
uint16_t fw_subtype_list[
|
|
|
|
MC_CMD_GET_BOARD_CFG_OUT_FW_SUBTYPE_LIST_MAXNUM];
|
2012-11-28 04:38:10 +00:00
|
|
|
size_t i;
|
2009-11-29 15:15:41 +00:00
|
|
|
int rc;
|
|
|
|
|
2010-07-14 14:36:19 +00:00
|
|
|
rc = efx_mcdi_get_board_cfg(efx, NULL, fw_subtype_list, NULL);
|
2009-11-29 15:15:41 +00:00
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
for (i = 0; i < n_parts; i++)
|
2012-11-28 04:38:14 +00:00
|
|
|
parts[i].fw_subtype = fw_subtype_list[parts[i].nvram_type];
|
2009-11-29 15:15:41 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int siena_mtd_probe(struct efx_nic *efx)
|
|
|
|
{
|
2012-11-28 04:38:14 +00:00
|
|
|
struct efx_mcdi_mtd_partition *parts;
|
2009-11-29 15:15:41 +00:00
|
|
|
u32 nvram_types;
|
|
|
|
unsigned int type;
|
2012-11-28 04:38:10 +00:00
|
|
|
size_t n_parts;
|
|
|
|
int rc;
|
2009-11-29 15:15:41 +00:00
|
|
|
|
|
|
|
ASSERT_RTNL();
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
efx->mtd_ops = &siena_mtd_ops;
|
|
|
|
|
2009-11-29 15:15:41 +00:00
|
|
|
rc = efx_mcdi_nvram_types(efx, &nvram_types);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
parts = kcalloc(hweight32(nvram_types), sizeof(*parts), GFP_KERNEL);
|
|
|
|
if (!parts)
|
2009-11-29 15:15:41 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
type = 0;
|
2012-11-28 04:38:10 +00:00
|
|
|
n_parts = 0;
|
2009-11-29 15:15:41 +00:00
|
|
|
|
|
|
|
while (nvram_types != 0) {
|
|
|
|
if (nvram_types & 1) {
|
2012-11-28 04:38:10 +00:00
|
|
|
rc = siena_mtd_probe_partition(efx, &parts[n_parts],
|
|
|
|
type);
|
2009-11-29 15:15:41 +00:00
|
|
|
if (rc == 0)
|
2012-11-28 04:38:10 +00:00
|
|
|
n_parts++;
|
2009-11-29 15:15:41 +00:00
|
|
|
else if (rc != -ENODEV)
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
type++;
|
|
|
|
nvram_types >>= 1;
|
|
|
|
}
|
|
|
|
|
2012-11-28 04:38:10 +00:00
|
|
|
rc = siena_mtd_get_fw_subtypes(efx, parts, n_parts);
|
2009-11-29 15:15:41 +00:00
|
|
|
if (rc)
|
|
|
|
goto fail;
|
|
|
|
|
2012-11-28 04:38:14 +00:00
|
|
|
rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts));
|
2009-11-29 15:15:41 +00:00
|
|
|
fail:
|
|
|
|
if (rc)
|
2012-11-28 04:38:10 +00:00
|
|
|
kfree(parts);
|
2009-11-29 15:15:41 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|