firmware: arm_scmi: Simplify chan_available transport operation
authorCristian Marussi <cristian.marussi@arm.com>
Thu, 22 Dec 2022 18:50:41 +0000 (18:50 +0000)
committerSudeep Holla <sudeep.holla@arm.com>
Thu, 19 Jan 2023 09:41:39 +0000 (09:41 +0000)
SCMI transport operation .chan_available determines in a transport
specific way if an SCMI channel is still available and to be configured.
Such information is derived by analyzing bits of device node in a
transport specific way, all it needs is a device node to operate up on,
not necessarily a full blown device.

Simplify the helper to receive in input a reference to a device_node
instead of a device carrying a pointer to such device_node.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20221222185049.737625-2-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
drivers/firmware/arm_scmi/mailbox.c
drivers/firmware/arm_scmi/optee.c
drivers/firmware/arm_scmi/smc.c
drivers/firmware/arm_scmi/virtio.c

index a1c0154c31c6fadde69b2a65e45440a795747a23..16db1e177123d08476c0adab6f8f5f8fb74dffa2 100644 (file)
@@ -153,7 +153,7 @@ struct scmi_chan_info {
  */
 struct scmi_transport_ops {
        int (*link_supplier)(struct device *dev);
-       bool (*chan_available)(struct device *dev, int idx);
+       bool (*chan_available)(struct device_node *of_node, int idx);
        int (*chan_setup)(struct scmi_chan_info *cinfo, struct device *dev,
                          bool tx);
        int (*chan_free)(int id, void *p, void *data);
index ffdad59ec81fcb5e438061aba98accede1cf7d5a..f1ebadffdfe4c32fd931492180814ee880256777 100644 (file)
@@ -2003,7 +2003,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device *dev,
        if (cinfo)
                return 0;
 
-       if (!info->desc->ops->chan_available(dev, idx)) {
+       if (!info->desc->ops->chan_available(dev->of_node, idx)) {
                cinfo = idr_find(idr, SCMI_PROTOCOL_BASE);
                if (unlikely(!cinfo)) /* Possible only if platform has no Rx */
                        return -EINVAL;
index 1e40cb035044dff2ecec998bb11a20ef9812d7ee..c33dcadafea86b75b08053b35d754fc7788bdca8 100644 (file)
@@ -46,9 +46,9 @@ static void rx_callback(struct mbox_client *cl, void *m)
        scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem), NULL);
 }
 
-static bool mailbox_chan_available(struct device *dev, int idx)
+static bool mailbox_chan_available(struct device_node *of_node, int idx)
 {
-       return !of_parse_phandle_with_args(dev->of_node, "mboxes",
+       return !of_parse_phandle_with_args(of_node, "mboxes",
                                           "#mbox-cells", idx, NULL);
 }
 
index 2a7aeab40e543537cad593de8b026dcf8ed1db3d..5a11091c72da3f71b69180f8f8745d0db206fde8 100644 (file)
@@ -328,11 +328,11 @@ static int scmi_optee_link_supplier(struct device *dev)
        return 0;
 }
 
-static bool scmi_optee_chan_available(struct device *dev, int idx)
+static bool scmi_optee_chan_available(struct device_node *of_node, int idx)
 {
        u32 channel_id;
 
-       return !of_property_read_u32_index(dev->of_node, "linaro,optee-channel-id",
+       return !of_property_read_u32_index(of_node, "linaro,optee-channel-id",
                                           idx, &channel_id);
 }
 
index 87a7b13cf868b2b53189105c8011b638856f71c7..122128d56d2f27ef2733b5f5aef43a1f1f9fe459 100644 (file)
@@ -52,9 +52,9 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)
        return IRQ_HANDLED;
 }
 
-static bool smc_chan_available(struct device *dev, int idx)
+static bool smc_chan_available(struct device_node *of_node, int idx)
 {
-       struct device_node *np = of_parse_phandle(dev->of_node, "shmem", 0);
+       struct device_node *np = of_parse_phandle(of_node, "shmem", 0);
        if (!np)
                return false;
 
index 1db975c08896983f994be90fea6a361cc3099389..a917eca7d902401bda9a8105a23ebe45fc3eaeab 100644 (file)
@@ -385,7 +385,7 @@ static int virtio_link_supplier(struct device *dev)
        return 0;
 }
 
-static bool virtio_chan_available(struct device *dev, int idx)
+static bool virtio_chan_available(struct device_node *of_node, int idx)
 {
        struct scmi_vio_channel *channels, *vioch = NULL;