// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2015, Sony Mobile Communications Inc. * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. */ #include <linux/device.h> #include <linux/list.h> #include <linux/module.h> #include <linux/of.h> #include <linux/slab.h> #include <linux/soc/qcom/smem_state.h> static LIST_HEAD(smem_states); static DEFINE_MUTEX(list_lock); /** * 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 { … }; /** * 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) { … } EXPORT_SYMBOL_GPL(…); static struct qcom_smem_state *of_node_to_state(struct device_node *np) { … } /** * 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) { … } EXPORT_SYMBOL_GPL(…); static void qcom_smem_state_release(struct kref *ref) { … } /** * qcom_smem_state_put() - release state handle * @state: state handle to be released */ void qcom_smem_state_put(struct qcom_smem_state *state) { … } EXPORT_SYMBOL_GPL(…); static void devm_qcom_smem_state_release(struct device *dev, void *res) { … } /** * 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, const char *con_id, unsigned *bit) { … } EXPORT_SYMBOL_GPL(…); /** * qcom_smem_state_register() - register a new state * @of_node: of_node used for matching client lookups * @ops: implementation ops * @priv: implementation specific private data */ struct qcom_smem_state *qcom_smem_state_register(struct device_node *of_node, const struct qcom_smem_state_ops *ops, void *priv) { … } EXPORT_SYMBOL_GPL(…); /** * qcom_smem_state_unregister() - unregister a registered state * @state: state handle to be unregistered */ void qcom_smem_state_unregister(struct qcom_smem_state *state) { … } EXPORT_SYMBOL_GPL(…);