Skip to content

Commit e8bc38f

Browse files
cris-magregkh
authored andcommitted
firmware: arm_scmi: Add a common helper to check if a message is supported
commit 637b6d6cae9c42db5a9525da67c991294924d2cd upstream. A common helper is provided to check if a specific protocol message is supported or not. Signed-off-by: Cristian Marussi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sudeep Holla <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9672e0b commit e8bc38f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

drivers/firmware/arm_scmi/driver.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,10 +1450,44 @@ static void scmi_common_fastchannel_db_ring(struct scmi_fc_db_info *db)
14501450
#endif
14511451
}
14521452

1453+
/**
1454+
* scmi_protocol_msg_check - Check protocol message attributes
1455+
*
1456+
* @ph: A reference to the protocol handle.
1457+
* @message_id: The ID of the message to check.
1458+
* @attributes: A parameter to optionally return the retrieved message
1459+
* attributes, in case of Success.
1460+
*
1461+
* An helper to check protocol message attributes for a specific protocol
1462+
* and message pair.
1463+
*
1464+
* Return: 0 on SUCCESS
1465+
*/
1466+
static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph,
1467+
u32 message_id, u32 *attributes)
1468+
{
1469+
int ret;
1470+
struct scmi_xfer *t;
1471+
1472+
ret = xfer_get_init(ph, PROTOCOL_MESSAGE_ATTRIBUTES,
1473+
sizeof(__le32), 0, &t);
1474+
if (ret)
1475+
return ret;
1476+
1477+
put_unaligned_le32(message_id, t->tx.buf);
1478+
ret = do_xfer(ph, t);
1479+
if (!ret && attributes)
1480+
*attributes = get_unaligned_le32(t->rx.buf);
1481+
xfer_put(ph, t);
1482+
1483+
return ret;
1484+
}
1485+
14531486
static const struct scmi_proto_helpers_ops helpers_ops = {
14541487
.extended_name_get = scmi_common_extended_name_get,
14551488
.iter_response_init = scmi_iterator_init,
14561489
.iter_response_run = scmi_iterator_run,
1490+
.protocol_msg_check = scmi_protocol_msg_check,
14571491
.fastchannel_init = scmi_common_fastchannel_init,
14581492
.fastchannel_db_ring = scmi_common_fastchannel_db_ring,
14591493
};

drivers/firmware/arm_scmi/protocols.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ struct scmi_fc_info {
243243
* provided in @ops.
244244
* @iter_response_run: A common helper to trigger the run of a previously
245245
* initialized iterator.
246+
* @protocol_msg_check: A common helper to check is a specific protocol message
247+
* is supported.
246248
* @fastchannel_init: A common helper used to initialize FC descriptors by
247249
* gathering FC descriptions from the SCMI platform server.
248250
* @fastchannel_db_ring: A common helper to ring a FC doorbell.
@@ -255,6 +257,8 @@ struct scmi_proto_helpers_ops {
255257
unsigned int max_resources, u8 msg_id,
256258
size_t tx_size, void *priv);
257259
int (*iter_response_run)(void *iter);
260+
int (*protocol_msg_check)(const struct scmi_protocol_handle *ph,
261+
u32 message_id, u32 *attributes);
258262
void (*fastchannel_init)(const struct scmi_protocol_handle *ph,
259263
u8 describe_id, u32 message_id,
260264
u32 valid_size, u32 domain,

0 commit comments

Comments
 (0)