drivers/char/tpm/st33zp24/st33zp24.c
Source file repositories/reference/linux-study-clean/drivers/char/tpm/st33zp24/st33zp24.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/tpm/st33zp24/st33zp24.c- Extension
.c- Size
- 13305 bytes
- Lines
- 591
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/acpi.hlinux/module.hlinux/fs.hlinux/kernel.hlinux/delay.hlinux/wait.hlinux/freezer.hlinux/string.hlinux/interrupt.hlinux/gpio/consumer.hlinux/sched.hlinux/uaccess.hlinux/io.hlinux/slab.h../tpm.hst33zp24.h
Detected Declarations
enum st33zp24_accessenum st33zp24_statusenum st33zp24_int_flagsenum tis_defaultsfunction clear_interruptionfunction st33zp24_cancelfunction st33zp24_statusfunction check_localityfunction request_localityfunction release_localityfunction get_burstcountfunction wait_for_tpm_stat_condfunction wait_for_statfunction recv_datafunction tpm_ioserirq_handlerfunction st33zp24_sendfunction st33zp24_recvfunction st33zp24_req_canceledfunction st33zp24_probefunction st33zp24_removefunction st33zp24_pm_suspendfunction st33zp24_pm_resumeexport st33zp24_probeexport st33zp24_removeexport st33zp24_pm_suspendexport st33zp24_pm_resume
Annotated Snippet
if (ret >= 0 && condition) {
if (canceled)
return -ECANCELED;
return 0;
}
} while (ret == -ERESTARTSYS && freezing(current));
disable_irq_nosync(tpm_dev->irq);
} else {
do {
msleep(TPM_TIMEOUT);
status = chip->ops->status(chip);
if ((status & mask) == mask)
return 0;
} while (time_before(jiffies, stop));
}
return -ETIME;
}
static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
{
struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
int size = 0, burstcnt, len, ret;
while (size < count &&
wait_for_stat(chip,
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
chip->timeout_c,
&tpm_dev->read_queue, true) == 0) {
burstcnt = get_burstcount(chip);
if (burstcnt < 0)
return burstcnt;
len = min_t(int, burstcnt, count - size);
ret = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_DATA_FIFO,
buf + size, len);
if (ret < 0)
return ret;
size += len;
}
return size;
}
static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
{
struct tpm_chip *chip = dev_id;
struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
tpm_dev->intrs++;
wake_up_interruptible(&tpm_dev->read_queue);
disable_irq_nosync(tpm_dev->irq);
return IRQ_HANDLED;
}
/*
* send TPM commands through the I2C bus.
*/
static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
size_t bufsiz, size_t len)
{
struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u32 status, i, size, ordinal;
int burstcnt = 0;
int ret;
u8 data;
if (len < TPM_HEADER_SIZE)
return -EBUSY;
ret = request_locality(chip);
if (ret < 0)
return ret;
status = st33zp24_status(chip);
if ((status & TPM_STS_COMMAND_READY) == 0) {
st33zp24_cancel(chip);
if (wait_for_stat
(chip, TPM_STS_COMMAND_READY, chip->timeout_b,
&tpm_dev->read_queue, false) < 0) {
ret = -ETIME;
goto out_err;
}
}
for (i = 0; i < len - 1;) {
burstcnt = get_burstcount(chip);
if (burstcnt < 0) {
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/module.h`, `linux/fs.h`, `linux/kernel.h`, `linux/delay.h`, `linux/wait.h`, `linux/freezer.h`, `linux/string.h`.
- Detected declarations: `enum st33zp24_access`, `enum st33zp24_status`, `enum st33zp24_int_flags`, `enum tis_defaults`, `function clear_interruption`, `function st33zp24_cancel`, `function st33zp24_status`, `function check_locality`, `function request_locality`, `function release_locality`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.