drivers/hwspinlock/qcom_hwspinlock.c
Source file repositories/reference/linux-study-clean/drivers/hwspinlock/qcom_hwspinlock.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwspinlock/qcom_hwspinlock.c- Extension
.c- Size
- 6445 bytes
- Lines
- 261
- Domain
- Driver Families
- Bucket
- drivers/hwspinlock
- 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/hwspinlock.hlinux/io.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_device.hlinux/platform_device.hlinux/regmap.hhwspinlock_internal.h
Detected Declarations
struct qcom_hwspinlock_of_datafunction qcom_hwspinlock_trylockfunction qcom_hwspinlock_unlockfunction qcom_hwspinlock_bustfunction qcom_hwspinlock_probefunction qcom_hwspinlock_initfunction qcom_hwspinlock_exit
Annotated Snippet
struct qcom_hwspinlock_of_data {
u32 offset;
u32 stride;
const struct regmap_config *regmap_config;
};
static int qcom_hwspinlock_trylock(struct hwspinlock *lock)
{
struct regmap_field *field = lock->priv;
u32 lock_owner;
int ret;
ret = regmap_field_write(field, QCOM_MUTEX_APPS_PROC_ID);
if (ret)
return ret;
ret = regmap_field_read(field, &lock_owner);
if (ret)
return ret;
return lock_owner == QCOM_MUTEX_APPS_PROC_ID;
}
static void qcom_hwspinlock_unlock(struct hwspinlock *lock)
{
struct regmap_field *field = lock->priv;
u32 lock_owner;
int ret;
ret = regmap_field_read(field, &lock_owner);
if (ret) {
pr_err("%s: unable to query spinlock owner\n", __func__);
return;
}
if (lock_owner != QCOM_MUTEX_APPS_PROC_ID) {
pr_err("%s: spinlock not owned by us (actual owner is %d)\n",
__func__, lock_owner);
}
ret = regmap_field_write(field, 0);
if (ret)
pr_err("%s: failed to unlock spinlock\n", __func__);
}
static int qcom_hwspinlock_bust(struct hwspinlock *lock, unsigned int id)
{
struct regmap_field *field = lock->priv;
u32 owner;
int ret;
ret = regmap_field_read(field, &owner);
if (ret) {
dev_err(lock->bank->dev, "unable to query spinlock owner\n");
return ret;
}
if (owner != id)
return 0;
ret = regmap_field_write(field, 0);
if (ret) {
dev_err(lock->bank->dev, "failed to bust spinlock\n");
return ret;
}
return 0;
}
static const struct hwspinlock_ops qcom_hwspinlock_ops = {
.trylock = qcom_hwspinlock_trylock,
.unlock = qcom_hwspinlock_unlock,
.bust = qcom_hwspinlock_bust,
};
static const struct regmap_config sfpb_mutex_config = {
.reg_bits = 32,
.reg_stride = 4,
.val_bits = 32,
.max_register = 0x100,
.fast_io = true,
};
static const struct qcom_hwspinlock_of_data of_sfpb_mutex = {
.offset = 0x4,
.stride = 0x4,
.regmap_config = &sfpb_mutex_config,
};
static const struct regmap_config tcsr_msm8226_mutex_config = {
Annotation
- Immediate include surface: `linux/hwspinlock.h`, `linux/io.h`, `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/of_device.h`, `linux/platform_device.h`.
- Detected declarations: `struct qcom_hwspinlock_of_data`, `function qcom_hwspinlock_trylock`, `function qcom_hwspinlock_unlock`, `function qcom_hwspinlock_bust`, `function qcom_hwspinlock_probe`, `function qcom_hwspinlock_init`, `function qcom_hwspinlock_exit`.
- Atlas domain: Driver Families / drivers/hwspinlock.
- 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.