firmware: arm_scmi: Refactor polling helpers
authorCristian Marussi <cristian.marussi@arm.com>
Wed, 18 Jan 2023 12:14:11 +0000 (12:14 +0000)
committerSudeep Holla <sudeep.holla@arm.com>
Fri, 20 Jan 2023 11:40:32 +0000 (11:40 +0000)
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>
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c

index 80f63fc8ca1483baaa58d427746264ad7a4715df..f785f0ff2090e1c284c2991e03f72ead2e139e30 100644 (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
index 3400bd124a38096d2837f9b605a48cc56972a11d..d7f21e81bd11c606771188a845f26de6be85e749 100644 (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");