/** * struct qcom_smem_state - state context * @refcount: refcount for the state * @orphan: boolean indicator that this state has been unregistered * @list: entry in smem_states list * @of_node: of_node to use for matching the state in DT * @priv: implementation private data * @ops: ops for the state
*/ struct qcom_smem_state { struct kref refcount; bool orphan;
/** * 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;
/** * 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, constchar *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); goto put;
}
state = of_node_to_state(args.np); if (IS_ERR(state)) goto put;
/** * devm_qcom_smem_state_get() - acquire handle to a devres managed 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() is called * automatically when @dev is removed.
*/ struct qcom_smem_state *devm_qcom_smem_state_get(struct device *dev, constchar *con_id, unsigned *bit)
{ struct qcom_smem_state **ptr, *state;
ptr = devres_alloc(devm_qcom_smem_state_release, sizeof(*ptr), GFP_KERNEL); if (!ptr) return ERR_PTR(-ENOMEM);
state = qcom_smem_state_get(dev, con_id, bit); if (!IS_ERR(state)) {
*ptr = state;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.