firmware: arm_scmi: Refactor polling helpers

Refactor polling helpers to receive scmi_desc directly as a parameter and
move all of them to common.h.

No functional change.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20230118121426.492864-3-cristian.marussi@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
Cristian Marussi 2023-01-18 12:14:11 +00:00 committed by Sudeep Holla
parent b0e924a955
commit f21c2b0ba8
2 changed files with 27 additions and 25 deletions

View File

@ -211,6 +211,24 @@ struct scmi_desc {
const bool atomic_enabled;
};
static inline bool is_polling_required(struct scmi_chan_info *cinfo,
const struct scmi_desc *desc)
{
return cinfo->no_completion_irq || desc->force_polling;
}
static inline bool is_transport_polling_capable(const struct scmi_desc *desc)
{
return desc->ops->poll_done || desc->sync_cmds_completed_on_ret;
}
static inline bool is_polling_enabled(struct scmi_chan_info *cinfo,
const struct scmi_desc *desc)
{
return is_polling_required(cinfo, desc) &&
is_transport_polling_capable(desc);
}
#ifdef CONFIG_ARM_SCMI_TRANSPORT_MAILBOX
extern const struct scmi_desc scmi_mailbox_desc;
#endif

View File

@ -748,25 +748,6 @@ static inline void scmi_clear_channel(struct scmi_info *info,
info->desc->ops->clear_channel(cinfo);
}
static inline bool is_polling_required(struct scmi_chan_info *cinfo,
struct scmi_info *info)
{
return cinfo->no_completion_irq || info->desc->force_polling;
}
static inline bool is_transport_polling_capable(struct scmi_info *info)
{
return info->desc->ops->poll_done ||
info->desc->sync_cmds_completed_on_ret;
}
static inline bool is_polling_enabled(struct scmi_chan_info *cinfo,
struct scmi_info *info)
{
return is_polling_required(cinfo, info) &&
is_transport_polling_capable(info);
}
static void scmi_handle_notification(struct scmi_chan_info *cinfo,
u32 msg_hdr, void *priv)
{
@ -1009,7 +990,8 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
struct scmi_chan_info *cinfo;
/* Check for polling request on custom command xfers at first */
if (xfer->hdr.poll_completion && !is_transport_polling_capable(info)) {
if (xfer->hdr.poll_completion &&
!is_transport_polling_capable(info->desc)) {
dev_warn_once(dev,
"Polling mode is not supported by transport.\n");
return -EINVAL;
@ -1020,7 +1002,7 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
return -EINVAL;
/* True ONLY if also supported by transport. */
if (is_polling_enabled(cinfo, info))
if (is_polling_enabled(cinfo, info->desc))
xfer->hdr.poll_completion = true;
/*
@ -1956,7 +1938,8 @@ static bool scmi_is_transport_atomic(const struct scmi_handle *handle,
bool ret;
struct scmi_info *info = handle_to_scmi_info(handle);
ret = info->desc->atomic_enabled && is_transport_polling_capable(info);
ret = info->desc->atomic_enabled &&
is_transport_polling_capable(info->desc);
if (ret && atomic_threshold)
*atomic_threshold = info->atomic_threshold;
@ -2180,8 +2163,8 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,
return ret;
}
if (tx && is_polling_required(cinfo, info)) {
if (is_transport_polling_capable(info))
if (tx && is_polling_required(cinfo, info->desc)) {
if (is_transport_polling_capable(info->desc))
dev_info(&tdev->dev,
"Enabled polling mode TX channel - prot_id:%d\n",
prot_id);
@ -2443,7 +2426,8 @@ static int scmi_probe(struct platform_device *pdev)
if (scmi_notification_init(handle))
dev_err(dev, "SCMI Notifications NOT available.\n");
if (info->desc->atomic_enabled && !is_transport_polling_capable(info))
if (info->desc->atomic_enabled &&
!is_transport_polling_capable(info->desc))
dev_err(dev,
"Transport is not polling capable. Atomic mode not supported.\n");