FROMLIST: firmware: arm_scmi: add devm_acquire_protocol helper

Add a method to get hold of a protocol, causing it to be initialized and
its resource accounting updated, without getting access to its operations
and handle.

Some protocols, like SCMI SystemPower, do not expose any protocol ops to
the Kernel OSPM agent but still need to be at least initialized: this
helper avoids the need to invoke a full devm_get_protocol() only to get
the protocol initialized while throwing away unused the protocol ops and
handle.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>

Bug: 171409184
Link: https://lore.kernel.org/linux-arm-kernel/20210202221555.41167-1-cristian.marussi@arm.com/
Change-Id: Ic40ef47b4133e761db8eb3e93d00ab6b7c3c2fb8
Signed-off-by: Rishabh Bhatnagar <quic_rishabhb@quicinc.com>
This commit is contained in:
Cristian Marussi
2021-02-02 22:15:22 +00:00
committed by Todd Kjos
parent bfacf9cff5
commit 4225eb5ab1
2 changed files with 66 additions and 18 deletions

View File

@@ -595,9 +595,15 @@ struct scmi_notify_ops {
* @sensor_ops: pointer to set of sensor protocol operations
* @reset_ops: pointer to set of reset protocol operations
* @voltage_ops: pointer to set of voltage protocol operations
* @devm_get_protocol: devres managed method to acquire a protocol and get specific
* operations and a dedicated protocol handler
* @devm_put_protocol: devres managed method to release a protocol
* @devm_acquire_protocol: devres managed method to get hold of a protocol,
* causing its initialization and related resource
* accounting
* @devm_get_protocol: devres managed method to acquire a protocol, causing
* its initialization and resource accounting, while getting
* protocol specific operations and a dedicated protocol
* handler
* @devm_put_protocol: devres managed method to release a protocol acquired
* with devm_acquire/get_protocol
* @notify_ops: pointer to set of notifications related operations
* @perf_priv: pointer to private data structure specific to performance
* protocol(for internal use only)
@@ -624,6 +630,8 @@ struct scmi_handle {
const struct scmi_reset_ops *reset_ops;
const struct scmi_voltage_ops *voltage_ops;
int __must_check (*devm_acquire_protocol)(struct scmi_device *sdev,
u8 proto);
const void __must_check *
(*devm_get_protocol)(struct scmi_device *sdev, u8 proto,
struct scmi_protocol_handle **ph);