drivers/soc/qcom/smem_state.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/smem_state.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/smem_state.c- Extension
.c- Size
- 5549 bytes
- Lines
- 228
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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/cleanup.hlinux/device.hlinux/list.hlinux/module.hlinux/of.hlinux/slab.hlinux/soc/qcom/smem_state.h
Detected Declarations
struct qcom_smem_statefunction qcom_smem_state_update_bitsfunction list_for_each_entryfunction qcom_smem_state_getfunction qcom_smem_state_releasefunction qcom_smem_state_putfunction devm_qcom_smem_state_releasefunction devm_qcom_smem_state_getfunction qcom_smem_state_registerfunction qcom_smem_state_unregisterexport qcom_smem_state_update_bitsexport qcom_smem_state_getexport qcom_smem_state_putexport devm_qcom_smem_state_getexport qcom_smem_state_registerexport qcom_smem_state_unregister
Annotated Snippet
struct qcom_smem_state {
struct kref refcount;
bool orphan;
struct list_head list;
struct device_node *of_node;
void *priv;
struct qcom_smem_state_ops ops;
};
/**
* qcom_smem_state_update_bits() - update the masked bits in state with value
* @state: state handle acquired by calling qcom_smem_state_get()
* @mask: bit mask for the change
* @value: new value for the masked bits
*
* Returns 0 on success, otherwise negative errno.
*/
int qcom_smem_state_update_bits(struct qcom_smem_state *state,
u32 mask,
u32 value)
{
if (state->orphan)
return -ENXIO;
if (!state->ops.update_bits)
return -ENOTSUPP;
return state->ops.update_bits(state->priv, mask, value);
}
EXPORT_SYMBOL_GPL(qcom_smem_state_update_bits);
static struct qcom_smem_state *of_node_to_state(struct device_node *np)
{
struct qcom_smem_state *state;
guard(mutex)(&list_lock);
list_for_each_entry(state, &smem_states, list) {
if (state->of_node == np) {
kref_get(&state->refcount);
return state;
}
}
return ERR_PTR(-EPROBE_DEFER);
}
/**
* qcom_smem_state_get() - acquire handle to a state
* @dev: client device pointer
* @con_id: name of the state to lookup
* @bit: flags from the state reference, indicating which bit's affected
*
* Returns handle to the state, or ERR_PTR(). qcom_smem_state_put() must be
* called to release the returned state handle.
*/
struct qcom_smem_state *qcom_smem_state_get(struct device *dev,
const char *con_id,
unsigned *bit)
{
struct qcom_smem_state *state;
struct of_phandle_args args;
int index = 0;
int ret;
if (con_id) {
index = of_property_match_string(dev->of_node,
"qcom,smem-state-names",
con_id);
if (index < 0) {
dev_err(dev, "missing qcom,smem-state-names\n");
return ERR_PTR(index);
}
}
ret = of_parse_phandle_with_args(dev->of_node,
"qcom,smem-states",
"#qcom,smem-state-cells",
index,
&args);
if (ret) {
dev_err(dev, "failed to parse qcom,smem-states property\n");
return ERR_PTR(ret);
}
if (args.args_count != 1) {
dev_err(dev, "invalid #qcom,smem-state-cells\n");
state = ERR_PTR(-EINVAL);
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/device.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`, `linux/slab.h`, `linux/soc/qcom/smem_state.h`.
- Detected declarations: `struct qcom_smem_state`, `function qcom_smem_state_update_bits`, `function list_for_each_entry`, `function qcom_smem_state_get`, `function qcom_smem_state_release`, `function qcom_smem_state_put`, `function devm_qcom_smem_state_release`, `function devm_qcom_smem_state_get`, `function qcom_smem_state_register`, `function qcom_smem_state_unregister`.
- Atlas domain: Driver Families / drivers/soc.
- 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.