drivers/soc/microchip/mpfs-sys-controller.c
Source file repositories/reference/linux-study-clean/drivers/soc/microchip/mpfs-sys-controller.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/microchip/mpfs-sys-controller.c- Extension
.c- Size
- 7441 bytes
- Lines
- 283
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/kref.hlinux/module.hlinux/jiffies.hlinux/mtd/mtd.hlinux/spi/spi.hlinux/interrupt.hlinux/of.hlinux/mailbox_client.hlinux/platform_device.hsoc/microchip/mpfs.h
Detected Declarations
struct mpfs_sys_controllerstruct mpfs_syscon_configfunction mpfs_blocking_transactionfunction mbox_send_messagefunction mpfs_sys_controller_rx_callbackfunction mpfs_sys_controller_deletefunction mpfs_sys_controller_putfunction mpfs_sys_controller_probefunction mpfs_sys_controller_removeexport mpfs_blocking_transactionexport mpfs_sys_controller_get_flashexport mpfs_sys_controller_get
Annotated Snippet
struct mpfs_sys_controller {
struct mbox_client client;
struct mbox_chan *chan;
struct completion c;
struct mtd_info *flash;
struct kref consumers;
};
struct mpfs_syscon_config {
unsigned int nb_subdevs;
struct platform_device *subdevs;
};
int mpfs_blocking_transaction(struct mpfs_sys_controller *sys_controller, struct mpfs_mss_msg *msg)
{
unsigned long timeout = msecs_to_jiffies(MPFS_SYS_CTRL_TIMEOUT_MS);
int ret;
ret = mutex_lock_interruptible(&transaction_lock);
if (ret)
return ret;
reinit_completion(&sys_controller->c);
ret = mbox_send_message(sys_controller->chan, msg);
if (ret < 0) {
dev_warn(sys_controller->client.dev, "MPFS sys controller service timeout\n");
goto out;
}
/*
* Unfortunately, the system controller will only deliver an interrupt
* if a service succeeds. mbox_send_message() will block until the busy
* flag is gone. If the busy flag is gone but no interrupt has arrived
* to trigger the rx callback then the service can be deemed to have
* failed.
* The caller can then interrogate msg::response::resp_status to
* determine the cause of the failure.
* mbox_send_message() returns positive integers in the success path, so
* ret needs to be cleared if we do get an interrupt.
*/
if (!wait_for_completion_timeout(&sys_controller->c, timeout)) {
ret = -EBADMSG;
dev_warn(sys_controller->client.dev,
"MPFS sys controller service failed with status: %d\n",
msg->response->resp_status);
} else {
ret = 0;
}
out:
mutex_unlock(&transaction_lock);
return ret;
}
EXPORT_SYMBOL(mpfs_blocking_transaction);
static void mpfs_sys_controller_rx_callback(struct mbox_client *client, void *msg)
{
struct mpfs_sys_controller *sys_controller =
container_of(client, struct mpfs_sys_controller, client);
complete(&sys_controller->c);
}
static void mpfs_sys_controller_delete(struct kref *kref)
{
struct mpfs_sys_controller *sys_controller =
container_of(kref, struct mpfs_sys_controller, consumers);
mbox_free_channel(sys_controller->chan);
kfree(sys_controller);
}
static void mpfs_sys_controller_put(void *data)
{
struct mpfs_sys_controller *sys_controller = data;
kref_put(&sys_controller->consumers, mpfs_sys_controller_delete);
}
struct mtd_info *mpfs_sys_controller_get_flash(struct mpfs_sys_controller *mpfs_client)
{
return mpfs_client->flash;
}
EXPORT_SYMBOL(mpfs_sys_controller_get_flash);
static int mpfs_sys_controller_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/kref.h`, `linux/module.h`, `linux/jiffies.h`, `linux/mtd/mtd.h`, `linux/spi/spi.h`, `linux/interrupt.h`, `linux/of.h`.
- Detected declarations: `struct mpfs_sys_controller`, `struct mpfs_syscon_config`, `function mpfs_blocking_transaction`, `function mbox_send_message`, `function mpfs_sys_controller_rx_callback`, `function mpfs_sys_controller_delete`, `function mpfs_sys_controller_put`, `function mpfs_sys_controller_probe`, `function mpfs_sys_controller_remove`, `export mpfs_blocking_transaction`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.