Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions drivers/firmware/scmi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,31 @@ int scmi_send_message(struct scmi_protocol *proto, struct scmi_message *msg,
}
}

int scmi_read_message(struct scmi_protocol *proto, struct scmi_message *msg)
{
int ret;

if (!proto->rx) {
return -ENODEV;
}

if (!proto->rx->ready) {
return -EINVAL;
}

/* read message from platform, such as notification event
*
* Unlike scmi_send_message, reading messages with scmi_read_message is not currently
* required in the PRE_KERNEL stage. The interrupt-based logic is used here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a

if (k_is_pre_kernel()) {
    return -EINVAL;
}

check here then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, added it now

*/
if (k_is_pre_kernel()) {
return -EINVAL;
}

ret = scmi_transport_read_message(proto->transport, proto->rx, msg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for ret here. Judt directly return scmi_transport_read_message.


return ret;
}
static int scmi_core_protocol_setup(const struct device *transport)
{
int ret;
Expand Down
12 changes: 12 additions & 0 deletions include/zephyr/drivers/firmware/scmi/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,16 @@ int scmi_send_message(struct scmi_protocol *proto,
struct scmi_message *msg, struct scmi_message *reply,
bool use_polling);

/**
* @brief Read an SCMI message
*
* Blocking function used to read an SCMI message over a given channel
*
* @param proto pointer to SCMI protocol
* @param msg pointer to SCMI message to read
*
* @retval 0 if successful
* @retval negative errno if failure
*/
int scmi_read_message(struct scmi_protocol *proto, struct scmi_message *msg);
#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_PROTOCOL_H_ */