drivers/net/ethernet/sfc/falcon/mtd.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/falcon/mtd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/falcon/mtd.c- Extension
.c- Size
- 2749 bytes
- Lines
- 122
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/mtd/mtd.hlinux/slab.hlinux/rtnetlink.hnet_driver.hefx.h
Detected Declarations
function ef4_mtd_erasefunction ef4_mtd_syncfunction ef4_mtd_remove_partitionfunction ef4_mtd_addfunction ef4_mtd_removefunction ef4_mtd_rename
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/****************************************************************************
* Driver for Solarflare network controllers and boards
* Copyright 2005-2006 Fen Systems Ltd.
* Copyright 2006-2013 Solarflare Communications Inc.
*/
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/slab.h>
#include <linux/rtnetlink.h>
#include "net_driver.h"
#include "efx.h"
#define to_ef4_mtd_partition(mtd) \
container_of(mtd, struct ef4_mtd_partition, mtd)
/* MTD interface */
static int ef4_mtd_erase(struct mtd_info *mtd, struct erase_info *erase)
{
struct ef4_nic *efx = mtd->priv;
return efx->type->mtd_erase(mtd, erase->addr, erase->len);
}
static void ef4_mtd_sync(struct mtd_info *mtd)
{
struct ef4_mtd_partition *part = to_ef4_mtd_partition(mtd);
struct ef4_nic *efx = mtd->priv;
int rc;
rc = efx->type->mtd_sync(mtd);
if (rc)
pr_err("%s: %s sync failed (%d)\n",
part->name, part->dev_type_name, rc);
}
static void ef4_mtd_remove_partition(struct ef4_mtd_partition *part)
{
int rc;
for (;;) {
rc = mtd_device_unregister(&part->mtd);
if (rc != -EBUSY)
break;
ssleep(1);
}
WARN_ON(rc);
list_del(&part->node);
}
int ef4_mtd_add(struct ef4_nic *efx, struct ef4_mtd_partition *parts,
size_t n_parts, size_t sizeof_part)
{
struct ef4_mtd_partition *part;
size_t i;
for (i = 0; i < n_parts; i++) {
part = (struct ef4_mtd_partition *)((char *)parts +
i * sizeof_part);
part->mtd.writesize = 1;
part->mtd.owner = THIS_MODULE;
part->mtd.priv = efx;
part->mtd.name = part->name;
part->mtd._erase = ef4_mtd_erase;
part->mtd._read = efx->type->mtd_read;
part->mtd._write = efx->type->mtd_write;
part->mtd._sync = ef4_mtd_sync;
efx->type->mtd_rename(part);
if (mtd_device_register(&part->mtd, NULL, 0))
goto fail;
/* Add to list in order - ef4_mtd_remove() depends on this */
list_add_tail(&part->node, &efx->mtd_list);
}
return 0;
fail:
while (i--) {
part = (struct ef4_mtd_partition *)((char *)parts +
i * sizeof_part);
ef4_mtd_remove_partition(part);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/mtd/mtd.h`, `linux/slab.h`, `linux/rtnetlink.h`, `net_driver.h`, `efx.h`.
- Detected declarations: `function ef4_mtd_erase`, `function ef4_mtd_sync`, `function ef4_mtd_remove_partition`, `function ef4_mtd_add`, `function ef4_mtd_remove`, `function ef4_mtd_rename`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.