diff mbox series

[v2,07/11] firmware: arm_scmi: Skip protocol initialisation for additional devices

Message ID 20191218111742.29731-8-sudeep.holla@arm.com
State Accepted
Commit 2deb267b26b5441e0e77f999ea084bf02c5c0ef1
Headers show
Series firmware: arm_scmi: Add support for multiple device per protocol | expand

Commit Message

Sudeep Holla Dec. 18, 2019, 11:17 a.m. UTC
The scmi bus now supports adding multiple devices per protocol,
and since scmi_protocol_init is called for each scmi device created,
we must avoid allocating protocol private data and initialising the
protocol itself if it is already initialised.

In order to achieve the same, we can simple replace the idr pointer
from protocol initialisation function to a dummy function.

Suggested-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

---
 drivers/firmware/arm_scmi/bus.c | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.17.1

Comments

Sudeep Holla Dec. 24, 2019, 2:33 p.m. UTC | #1
On Wed, Dec 18, 2019 at 11:19 AM Sudeep Holla <sudeep.holla@arm.com> wrote:
>

> The scmi bus now supports adding multiple devices per protocol,

> and since scmi_protocol_init is called for each scmi device created,

> we must avoid allocating protocol private data and initialising the

> protocol itself if it is already initialised.

>

> In order to achieve the same, we can simple replace the idr pointer

> from protocol initialisation function to a dummy function.

>

> Suggested-by: Cristian Marussi <cristian.marussi@arm.com>



Hi Cristian,

Are you fine with this approach ? If yes, I plan to apply this series.

--
Regards,
Sudeep
Cristian Marussi Dec. 24, 2019, 2:35 p.m. UTC | #2
Hi

On 24/12/2019 14:33, Sudeep Holla wrote:
> On Wed, Dec 18, 2019 at 11:19 AM Sudeep Holla <sudeep.holla@arm.com> wrote:

>>

>> The scmi bus now supports adding multiple devices per protocol,

>> and since scmi_protocol_init is called for each scmi device created,

>> we must avoid allocating protocol private data and initialising the

>> protocol itself if it is already initialised.

>>

>> In order to achieve the same, we can simple replace the idr pointer

>> from protocol initialisation function to a dummy function.

>>

>> Suggested-by: Cristian Marussi <cristian.marussi@arm.com>

> 

> 

> Hi Cristian,

> 

> Are you fine with this approach ? If yes, I plan to apply this series.

> 


Yes sure...forgot this was pending.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>


Cristian
> --

> Regards,

> Sudeep

>
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 3714e6307b05..db55c43a2cbd 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -60,6 +60,11 @@  static int scmi_protocol_init(int protocol_id, struct scmi_handle *handle)
 	return fn(handle);
 }
 
+static int scmi_protocol_dummy_init(struct scmi_handle *handle)
+{
+	return 0;
+}
+
 static int scmi_dev_probe(struct device *dev)
 {
 	struct scmi_driver *scmi_drv = to_scmi_driver(dev->driver);
@@ -78,6 +83,10 @@  static int scmi_dev_probe(struct device *dev)
 	if (ret)
 		return ret;
 
+	/* Skip protocol initialisation for additional devices */
+	idr_replace(&scmi_protocols, &scmi_protocol_dummy_init,
+		    scmi_dev->protocol_id);
+
 	return scmi_drv->probe(scmi_dev);
 }