Lines Matching +full:smem +full:- +full:state +full:- +full:names

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
17 * struct qcom_smem_state - state context
18 * @refcount: refcount for the state
19 * @orphan: boolean indicator that this state has been unregistered
21 * @of_node: of_node to use for matching the state in DT
23 * @ops: ops for the state
38 * qcom_smem_state_update_bits() - update the masked bits in state with value
39 * @state: state handle acquired by calling qcom_smem_state_get()
45 int qcom_smem_state_update_bits(struct qcom_smem_state *state, in qcom_smem_state_update_bits() argument
49 if (state->orphan) in qcom_smem_state_update_bits()
50 return -ENXIO; in qcom_smem_state_update_bits()
52 if (!state->ops.update_bits) in qcom_smem_state_update_bits()
53 return -ENOTSUPP; in qcom_smem_state_update_bits()
55 return state->ops.update_bits(state->priv, mask, value); in qcom_smem_state_update_bits()
61 struct qcom_smem_state *state; in of_node_to_state() local
65 list_for_each_entry(state, &smem_states, list) { in of_node_to_state()
66 if (state->of_node == np) { in of_node_to_state()
67 kref_get(&state->refcount); in of_node_to_state()
71 state = ERR_PTR(-EPROBE_DEFER); in of_node_to_state()
76 return state; in of_node_to_state()
80 * qcom_smem_state_get() - acquire handle to a state
82 * @con_id: name of the state to lookup
83 * @bit: flags from the state reference, indicating which bit's affected
85 * Returns handle to the state, or ERR_PTR(). qcom_smem_state_put() must be
86 * called to release the returned state handle.
92 struct qcom_smem_state *state; in qcom_smem_state_get() local
98 index = of_property_match_string(dev->of_node, in qcom_smem_state_get()
99 "qcom,smem-state-names", in qcom_smem_state_get()
102 dev_err(dev, "missing qcom,smem-state-names\n"); in qcom_smem_state_get()
107 ret = of_parse_phandle_with_args(dev->of_node, in qcom_smem_state_get()
108 "qcom,smem-states", in qcom_smem_state_get()
109 "#qcom,smem-state-cells", in qcom_smem_state_get()
113 dev_err(dev, "failed to parse qcom,smem-states property\n"); in qcom_smem_state_get()
118 dev_err(dev, "invalid #qcom,smem-state-cells\n"); in qcom_smem_state_get()
119 return ERR_PTR(-EINVAL); in qcom_smem_state_get()
122 state = of_node_to_state(args.np); in qcom_smem_state_get()
123 if (IS_ERR(state)) in qcom_smem_state_get()
130 return state; in qcom_smem_state_get()
136 struct qcom_smem_state *state = container_of(ref, struct qcom_smem_state, refcount); in qcom_smem_state_release() local
138 list_del(&state->list); in qcom_smem_state_release()
139 kfree(state); in qcom_smem_state_release()
143 * qcom_smem_state_put() - release state handle
144 * @state: state handle to be released
146 void qcom_smem_state_put(struct qcom_smem_state *state) in qcom_smem_state_put() argument
149 kref_put(&state->refcount, qcom_smem_state_release); in qcom_smem_state_put()
155 * qcom_smem_state_register() - register a new state
164 struct qcom_smem_state *state; in qcom_smem_state_register() local
166 state = kzalloc(sizeof(*state), GFP_KERNEL); in qcom_smem_state_register()
167 if (!state) in qcom_smem_state_register()
168 return ERR_PTR(-ENOMEM); in qcom_smem_state_register()
170 kref_init(&state->refcount); in qcom_smem_state_register()
172 state->of_node = of_node; in qcom_smem_state_register()
173 state->ops = *ops; in qcom_smem_state_register()
174 state->priv = priv; in qcom_smem_state_register()
177 list_add(&state->list, &smem_states); in qcom_smem_state_register()
180 return state; in qcom_smem_state_register()
185 * qcom_smem_state_unregister() - unregister a registered state
186 * @state: state handle to be unregistered
188 void qcom_smem_state_unregister(struct qcom_smem_state *state) in qcom_smem_state_unregister() argument
190 state->orphan = true; in qcom_smem_state_unregister()
191 qcom_smem_state_put(state); in qcom_smem_state_unregister()