drivers/gnss/ubx.c
Source file repositories/reference/linux-study-clean/drivers/gnss/ubx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gnss/ubx.c- Extension
.c- Size
- 3199 bytes
- Lines
- 154
- 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.
- 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/kernel.hlinux/module.hlinux/of.hlinux/regulator/consumer.hlinux/serdev.hserial.h
Detected Declarations
struct ubx_datafunction ubx_set_activefunction ubx_set_standbyfunction ubx_set_powerfunction ubx_probefunction ubx_remove
Annotated Snippet
struct ubx_data {
struct regulator *vcc;
};
static int ubx_set_active(struct gnss_serial *gserial)
{
struct ubx_data *data = gnss_serial_get_drvdata(gserial);
int ret;
ret = regulator_enable(data->vcc);
if (ret)
return ret;
return 0;
}
static int ubx_set_standby(struct gnss_serial *gserial)
{
struct ubx_data *data = gnss_serial_get_drvdata(gserial);
int ret;
ret = regulator_disable(data->vcc);
if (ret)
return ret;
return 0;
}
static int ubx_set_power(struct gnss_serial *gserial,
enum gnss_serial_pm_state state)
{
switch (state) {
case GNSS_SERIAL_ACTIVE:
return ubx_set_active(gserial);
case GNSS_SERIAL_OFF:
case GNSS_SERIAL_STANDBY:
return ubx_set_standby(gserial);
}
return -EINVAL;
}
static const struct gnss_serial_ops ubx_gserial_ops = {
.set_power = ubx_set_power,
};
static int ubx_probe(struct serdev_device *serdev)
{
struct gnss_serial *gserial;
struct gpio_desc *safeboot;
struct gpio_desc *reset;
struct ubx_data *data;
int ret;
gserial = gnss_serial_allocate(serdev, sizeof(*data));
if (IS_ERR(gserial)) {
ret = PTR_ERR(gserial);
return ret;
}
gserial->ops = &ubx_gserial_ops;
gserial->gdev->type = GNSS_TYPE_UBX;
data = gnss_serial_get_drvdata(gserial);
data->vcc = devm_regulator_get(&serdev->dev, "vcc");
if (IS_ERR(data->vcc)) {
ret = PTR_ERR(data->vcc);
goto err_free_gserial;
}
ret = devm_regulator_get_enable_optional(&serdev->dev, "v-bckp");
if (ret < 0 && ret != -ENODEV)
goto err_free_gserial;
/* Deassert safeboot */
safeboot = devm_gpiod_get_optional(&serdev->dev, "safeboot", GPIOD_OUT_LOW);
if (IS_ERR(safeboot)) {
ret = PTR_ERR(safeboot);
goto err_free_gserial;
}
/* Deassert reset */
reset = devm_gpiod_get_optional(&serdev->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(reset)) {
ret = PTR_ERR(reset);
goto err_free_gserial;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/gnss.h`, `linux/gpio/consumer.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct ubx_data`, `function ubx_set_active`, `function ubx_set_standby`, `function ubx_set_power`, `function ubx_probe`, `function ubx_remove`.
- Atlas domain: Driver Families / drivers/gnss.
- 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.