drivers/char/tpm/tpm_crb_ffa.c
Source file repositories/reference/linux-study-clean/drivers/char/tpm/tpm_crb_ffa.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/tpm/tpm_crb_ffa.c- Extension
.c- Size
- 11415 bytes
- Lines
- 415
- Domain
- Driver Families
- Bucket
- drivers/char
- 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.
- 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/arm_ffa.hlinux/delay.hlinux/moduleparam.htpm_crb_ffa.h
Detected Declarations
struct tpm_crb_ffafunction tpm_crb_ffa_to_linux_errnofunction tpm_crb_ffa_initfunction __tpm_crb_ffa_try_send_receivefunction __tpm_crb_ffa_send_receivefunction tpm_crb_ffa_get_interface_versionfunction tpm_crb_ffa_startfunction tpm_crb_ffa_probefunction tpm_crb_ffa_removeexport tpm_crb_ffa_initexport tpm_crb_ffa_start
Annotated Snippet
struct tpm_crb_ffa {
struct ffa_device *ffa_dev;
u16 major_version;
u16 minor_version;
/* lock to protect sending of FF-A messages: */
struct mutex msg_data_lock;
union {
struct ffa_send_direct_data direct_msg_data;
struct ffa_send_direct_data2 direct_msg_data2;
};
};
static struct tpm_crb_ffa *tpm_crb_ffa;
static struct ffa_driver tpm_crb_ffa_driver;
static int tpm_crb_ffa_to_linux_errno(int errno)
{
int rc;
switch (errno) {
case CRB_FFA_OK:
rc = 0;
break;
case CRB_FFA_OK_RESULTS_RETURNED:
rc = 0;
break;
case CRB_FFA_NOFUNC:
rc = -ENOENT;
break;
case CRB_FFA_NOTSUP:
rc = -EPERM;
break;
case CRB_FFA_INVARG:
rc = -EINVAL;
break;
case CRB_FFA_INV_CRB_CTRL_DATA:
rc = -ENOEXEC;
break;
case CRB_FFA_ALREADY:
rc = -EEXIST;
break;
case CRB_FFA_DENIED:
rc = -EACCES;
break;
case CRB_FFA_NOMEM:
rc = -ENOMEM;
break;
default:
rc = -EINVAL;
}
return rc;
}
/**
* tpm_crb_ffa_init - called by the CRB driver to do any needed initialization
*
* This function is called by the tpm_crb driver during the tpm_crb
* driver's initialization. If the tpm_crb_ffa has not been probed
* yet, returns -ENOENT in order to force a retry. If th ffa_crb
* driver had been probed but failed with an error, returns -ENODEV
* in order to prevent further retries.
*
* Return: 0 on success, negative error code on failure.
*/
int tpm_crb_ffa_init(void)
{
int ret = 0;
if (!IS_MODULE(CONFIG_TCG_ARM_CRB_FFA)) {
ret = ffa_register(&tpm_crb_ffa_driver);
if (ret) {
tpm_crb_ffa = ERR_PTR(-ENODEV);
return ret;
}
}
if (!tpm_crb_ffa)
ret = -ENOENT;
if (IS_ERR_VALUE(tpm_crb_ffa))
ret = -ENODEV;
return ret;
}
EXPORT_SYMBOL_GPL(tpm_crb_ffa_init);
static int __tpm_crb_ffa_try_send_receive(unsigned long func_id,
unsigned long a0, unsigned long a1,
unsigned long a2)
Annotation
- Immediate include surface: `linux/arm_ffa.h`, `linux/delay.h`, `linux/moduleparam.h`, `tpm_crb_ffa.h`.
- Detected declarations: `struct tpm_crb_ffa`, `function tpm_crb_ffa_to_linux_errno`, `function tpm_crb_ffa_init`, `function __tpm_crb_ffa_try_send_receive`, `function __tpm_crb_ffa_send_receive`, `function tpm_crb_ffa_get_interface_version`, `function tpm_crb_ffa_start`, `function tpm_crb_ffa_probe`, `function tpm_crb_ffa_remove`, `export tpm_crb_ffa_init`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: integration 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.