drivers/gnss/sirf.c
Source file repositories/reference/linux-study-clean/drivers/gnss/sirf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gnss/sirf.c- Extension
.c- Size
- 12277 bytes
- Lines
- 582
- Domain
- Driver Families
- Bucket
- drivers/gnss
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/errno.hlinux/gnss.hlinux/gpio/consumer.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/of.hlinux/pm.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/sched.hlinux/serdev.hlinux/slab.hlinux/wait.h
Detected Declarations
struct sirf_datafunction sirf_serdev_openfunction sirf_serdev_closefunction sirf_openfunction sirf_closefunction sirf_write_rawfunction sirf_receive_buffunction sirf_wakeup_handlerfunction sirf_wait_for_power_state_nowakeupfunction sirf_wait_for_power_statefunction sirf_pulse_on_offfunction sirf_set_activefunction sirf_runtime_suspendfunction sirf_runtime_resumefunction sirf_suspendfunction sirf_resumefunction sirf_parse_dtfunction sirf_probefunction sirf_remove
Annotated Snippet
struct sirf_data {
struct gnss_device *gdev;
struct serdev_device *serdev;
speed_t speed;
struct regulator *vcc;
struct regulator *lna;
struct gpio_desc *on_off;
struct gpio_desc *wakeup;
int irq;
bool active;
struct mutex gdev_mutex;
bool open;
struct mutex serdev_mutex;
int serdev_count;
wait_queue_head_t power_wait;
};
static int sirf_serdev_open(struct sirf_data *data)
{
int ret = 0;
mutex_lock(&data->serdev_mutex);
if (++data->serdev_count == 1) {
ret = serdev_device_open(data->serdev);
if (ret) {
data->serdev_count--;
goto out_unlock;
}
serdev_device_set_baudrate(data->serdev, data->speed);
serdev_device_set_flow_control(data->serdev, false);
}
out_unlock:
mutex_unlock(&data->serdev_mutex);
return ret;
}
static void sirf_serdev_close(struct sirf_data *data)
{
mutex_lock(&data->serdev_mutex);
if (--data->serdev_count == 0)
serdev_device_close(data->serdev);
mutex_unlock(&data->serdev_mutex);
}
static int sirf_open(struct gnss_device *gdev)
{
struct sirf_data *data = gnss_get_drvdata(gdev);
struct serdev_device *serdev = data->serdev;
int ret;
mutex_lock(&data->gdev_mutex);
data->open = true;
mutex_unlock(&data->gdev_mutex);
ret = sirf_serdev_open(data);
if (ret) {
mutex_lock(&data->gdev_mutex);
data->open = false;
mutex_unlock(&data->gdev_mutex);
return ret;
}
ret = pm_runtime_get_sync(&serdev->dev);
if (ret < 0) {
dev_err(&gdev->dev, "failed to runtime resume: %d\n", ret);
pm_runtime_put_noidle(&serdev->dev);
goto err_close;
}
return 0;
err_close:
sirf_serdev_close(data);
mutex_lock(&data->gdev_mutex);
data->open = false;
mutex_unlock(&data->gdev_mutex);
return ret;
}
static void sirf_close(struct gnss_device *gdev)
{
struct sirf_data *data = gnss_get_drvdata(gdev);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/gnss.h`, `linux/gpio/consumer.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct sirf_data`, `function sirf_serdev_open`, `function sirf_serdev_close`, `function sirf_open`, `function sirf_close`, `function sirf_write_raw`, `function sirf_receive_buf`, `function sirf_wakeup_handler`, `function sirf_wait_for_power_state_nowakeup`, `function sirf_wait_for_power_state`.
- Atlas domain: Driver Families / drivers/gnss.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.