summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firmware/arm_scmi/common.h3
-rw-r--r--drivers/firmware/arm_scmi/driver.c17
2 files changed, 18 insertions, 2 deletions
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
index 049607280ea5..bf3883f169e3 100644
--- a/drivers/firmware/arm_scmi/common.h
+++ b/drivers/firmware/arm_scmi/common.h
@@ -157,6 +157,8 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
/**
* struct scmi_chan_info - Structure representing a SCMI channel information
*
+ * @id: An identifier for this channel: this matches the protocol number
+ * used to initialize this channel
* @dev: Reference to device in the SCMI hierarchy corresponding to this
* channel
* @rx_timeout_ms: The configured RX timeout in milliseconds.
@@ -168,6 +170,7 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
* @transport_info: Transport layer related information
*/
struct scmi_chan_info {
+ int id;
struct device *dev;
unsigned int rx_timeout_ms;
struct scmi_handle *handle;
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index fefa01dbf9ee..af34324e923b 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -39,6 +39,8 @@
#define CREATE_TRACE_POINTS
#include <trace/events/scmi.h>
+static DEFINE_IDA(scmi_id);
+
static DEFINE_IDR(scmi_protocols);
static DEFINE_SPINLOCK(protocol_lock);
@@ -98,6 +100,7 @@ struct scmi_protocol_instance {
/**
* struct scmi_info - Structure representing a SCMI instance
*
+ * @id: A sequence number starting from zero identifying this instance
* @dev: Device pointer
* @desc: SoC description for this instance
* @version: SCMI revision information containing protocol version,
@@ -131,6 +134,7 @@ struct scmi_protocol_instance {
* @devreq_mtx: A mutex to serialize device creation for this SCMI instance
*/
struct scmi_info {
+ int id;
struct device *dev;
const struct scmi_desc *desc;
struct scmi_revision_info version;
@@ -2270,6 +2274,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,
}
of_node_get(of_node);
+ cinfo->id = prot_id;
cinfo->dev = &tdev->dev;
ret = info->desc->ops->chan_setup(cinfo, info->dev, tx);
if (ret) {
@@ -2486,6 +2491,10 @@ static int scmi_probe(struct platform_device *pdev)
if (!info)
return -ENOMEM;
+ info->id = ida_alloc_min(&scmi_id, 0, GFP_KERNEL);
+ if (info->id < 0)
+ return info->id;
+
info->dev = dev;
info->desc = desc;
info->bus_nb.notifier_call = scmi_bus_notifier;
@@ -2518,13 +2527,13 @@ static int scmi_probe(struct platform_device *pdev)
if (desc->ops->link_supplier) {
ret = desc->ops->link_supplier(dev);
if (ret)
- return ret;
+ goto clear_ida;
}
/* Setup all channels described in the DT at first */
ret = scmi_channels_setup(info);
if (ret)
- return ret;
+ goto clear_ida;
ret = bus_register_notifier(&scmi_bus_type, &info->bus_nb);
if (ret)
@@ -2604,6 +2613,8 @@ clear_bus_notifier:
bus_unregister_notifier(&scmi_bus_type, &info->bus_nb);
clear_txrx_setup:
scmi_cleanup_txrx_channels(info);
+clear_ida:
+ ida_free(&scmi_id, info->id);
return ret;
}
@@ -2637,6 +2648,8 @@ static int scmi_remove(struct platform_device *pdev)
/* Safe to free channels since no more users */
scmi_cleanup_txrx_channels(info);
+ ida_free(&scmi_id, info->id);
+
return 0;
}