drivers/nfc/s3fwrn5/uart.c
Source file repositories/reference/linux-study-clean/drivers/nfc/s3fwrn5/uart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/s3fwrn5/uart.c- Extension
.c- Size
- 4156 bytes
- Lines
- 177
- Domain
- Driver Families
- Bucket
- drivers/nfc
- 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.
- 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/device.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/nfc.hlinux/netdevice.hlinux/serdev.hlinux/gpio/consumer.hphy_common.h
Detected Declarations
struct s3fwrn82_uart_phyfunction s3fwrn82_uart_writefunction s3fwrn82_uart_readfunction s3fwrn82_uart_probefunction s3fwrn82_uart_remove
Annotated Snippet
struct s3fwrn82_uart_phy {
struct phy_common common;
struct serdev_device *ser_dev;
struct sk_buff *recv_skb;
};
static int s3fwrn82_uart_write(void *phy_id, struct sk_buff *out)
{
struct s3fwrn82_uart_phy *phy = phy_id;
int err;
err = serdev_device_write(phy->ser_dev,
out->data, out->len,
MAX_SCHEDULE_TIMEOUT);
if (err < 0)
return err;
return 0;
}
static const struct s3fwrn5_phy_ops uart_phy_ops = {
.set_wake = s3fwrn5_phy_set_wake,
.set_mode = s3fwrn5_phy_set_mode,
.get_mode = s3fwrn5_phy_get_mode,
.write = s3fwrn82_uart_write,
};
static size_t s3fwrn82_uart_read(struct serdev_device *serdev,
const u8 *data, size_t count)
{
struct s3fwrn82_uart_phy *phy = serdev_device_get_drvdata(serdev);
size_t i;
for (i = 0; i < count; i++) {
if (!phy->recv_skb) {
phy->recv_skb = alloc_skb(NCI_SKB_BUFF_LEN, GFP_KERNEL);
if (!phy->recv_skb)
return i;
}
skb_put_u8(phy->recv_skb, *data++);
if (phy->recv_skb->len < S3FWRN82_NCI_HEADER)
continue;
if ((phy->recv_skb->len - S3FWRN82_NCI_HEADER)
< phy->recv_skb->data[S3FWRN82_NCI_IDX])
continue;
s3fwrn5_recv_frame(phy->common.ndev, phy->recv_skb,
phy->common.mode);
phy->recv_skb = NULL;
}
return i;
}
static const struct serdev_device_ops s3fwrn82_serdev_ops = {
.receive_buf = s3fwrn82_uart_read,
.write_wakeup = serdev_device_write_wakeup,
};
static const struct of_device_id s3fwrn82_uart_of_match[] = {
{ .compatible = "samsung,s3fwrn82", },
{},
};
MODULE_DEVICE_TABLE(of, s3fwrn82_uart_of_match);
static int s3fwrn82_uart_probe(struct serdev_device *serdev)
{
struct s3fwrn82_uart_phy *phy;
int ret = -ENOMEM;
phy = devm_kzalloc(&serdev->dev, sizeof(*phy), GFP_KERNEL);
if (!phy)
goto err_exit;
phy->recv_skb = alloc_skb(NCI_SKB_BUFF_LEN, GFP_KERNEL);
if (!phy->recv_skb)
goto err_exit;
mutex_init(&phy->common.mutex);
phy->common.mode = S3FWRN5_MODE_COLD;
phy->ser_dev = serdev;
serdev_device_set_drvdata(serdev, phy);
serdev_device_set_client_ops(serdev, &s3fwrn82_serdev_ops);
ret = serdev_device_open(serdev);
if (ret) {
dev_err(&serdev->dev, "Unable to open device\n");
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/nfc.h`, `linux/netdevice.h`, `linux/serdev.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct s3fwrn82_uart_phy`, `function s3fwrn82_uart_write`, `function s3fwrn82_uart_read`, `function s3fwrn82_uart_probe`, `function s3fwrn82_uart_remove`.
- Atlas domain: Driver Families / drivers/nfc.
- 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.