drivers/nfc/s3fwrn5/core.c
Source file repositories/reference/linux-study-clean/drivers/nfc/s3fwrn5/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nfc/s3fwrn5/core.c- Extension
.c- Size
- 4846 bytes
- Lines
- 228
- Domain
- Driver Families
- Bucket
- drivers/nfc
- 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/module.hnet/nfc/nci_core.hs3fwrn5.hfirmware.hnci.h
Detected Declarations
function Copyrightfunction s3fwrn5_firmware_updatefunction s3fwrn5_nci_openfunction s3fwrn5_nci_closefunction s3fwrn5_nci_sendfunction s3fwrn5_nci_post_setupfunction s3fwrn5_probefunction s3fwrn5_removefunction s3fwrn5_recv_frameexport s3fwrn5_probeexport s3fwrn5_removeexport s3fwrn5_recv_frame
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* NCI based driver for Samsung S3FWRN5 NFC chip
*
* Copyright (C) 2015 Samsung Electronics
* Robert Baldyga <r.baldyga@samsung.com>
*/
#include <linux/module.h>
#include <net/nfc/nci_core.h>
#include "s3fwrn5.h"
#include "firmware.h"
#include "nci.h"
#define S3FWRN5_NFC_PROTOCOLS (NFC_PROTO_JEWEL_MASK | \
NFC_PROTO_MIFARE_MASK | \
NFC_PROTO_FELICA_MASK | \
NFC_PROTO_ISO14443_MASK | \
NFC_PROTO_ISO14443_B_MASK | \
NFC_PROTO_ISO15693_MASK)
static int s3fwrn5_firmware_init(struct s3fwrn5_info *info)
{
struct s3fwrn5_fw_info *fw_info = &info->fw_info;
int ret;
s3fwrn5_fw_init(fw_info, "sec_s3fwrn5_firmware.bin");
/* Get firmware data */
ret = s3fwrn5_fw_request_firmware(fw_info);
if (ret < 0)
dev_err(&fw_info->ndev->nfc_dev->dev,
"Failed to get fw file, ret=%02x\n", ret);
return ret;
}
static int s3fwrn5_firmware_update(struct s3fwrn5_info *info)
{
bool need_update;
int ret;
/* Update firmware */
s3fwrn5_set_wake(info, false);
s3fwrn5_set_mode(info, S3FWRN5_MODE_FW);
ret = s3fwrn5_fw_setup(&info->fw_info);
if (ret < 0)
return ret;
need_update = s3fwrn5_fw_check_version(&info->fw_info,
info->ndev->manufact_specific_info);
if (!need_update)
goto out;
dev_info(&info->ndev->nfc_dev->dev, "Detected new firmware version\n");
ret = s3fwrn5_fw_download(&info->fw_info);
if (ret < 0)
goto out;
/* Update RF configuration */
s3fwrn5_set_mode(info, S3FWRN5_MODE_NCI);
s3fwrn5_set_wake(info, true);
ret = s3fwrn5_nci_rf_configure(info, "sec_s3fwrn5_rfreg.bin");
s3fwrn5_set_wake(info, false);
out:
s3fwrn5_set_mode(info, S3FWRN5_MODE_COLD);
s3fwrn5_fw_cleanup(&info->fw_info);
return ret;
}
static int s3fwrn5_nci_open(struct nci_dev *ndev)
{
struct s3fwrn5_info *info = nci_get_drvdata(ndev);
if (s3fwrn5_get_mode(info) != S3FWRN5_MODE_COLD)
return -EBUSY;
s3fwrn5_set_mode(info, S3FWRN5_MODE_NCI);
s3fwrn5_set_wake(info, true);
return 0;
}
static int s3fwrn5_nci_close(struct nci_dev *ndev)
Annotation
- Immediate include surface: `linux/module.h`, `net/nfc/nci_core.h`, `s3fwrn5.h`, `firmware.h`, `nci.h`.
- Detected declarations: `function Copyright`, `function s3fwrn5_firmware_update`, `function s3fwrn5_nci_open`, `function s3fwrn5_nci_close`, `function s3fwrn5_nci_send`, `function s3fwrn5_nci_post_setup`, `function s3fwrn5_probe`, `function s3fwrn5_remove`, `function s3fwrn5_recv_frame`, `export s3fwrn5_probe`.
- Atlas domain: Driver Families / drivers/nfc.
- 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.