Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e907a1cc authored by Santosh Mardi's avatar Santosh Mardi Committed by Gerrit - the friendly Code Review server
Browse files

arm_scmi: cleanup the mailbox channels upon errors



During probe failure current implementation returns with
error without cleaning the mailbox channels.
Update the probe function to cleanup the mail box
channels for scmi tx and rx paths.

Change-Id: Iafd370638cad586c47ff8191ed12a0933bf4dbf3
Signed-off-by: default avatarSantosh Mardi <gsantosh@codeaurora.org>
parent c0a8ba67
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -174,6 +174,8 @@ static const int scmi_linux_errmap[] = {
	-EPROTO,		/* SCMI_ERR_PROTOCOL */
};

static int scmi_mbox_free_channel(int id, void *p, void *data);

static inline int scmi_to_linux_errno(int errno)
{
	if (errno < SCMI_SUCCESS && errno > SCMI_ERR_MAX)
@@ -824,6 +826,21 @@ scmi_create_protocol_device(struct device_node *np, struct scmi_info *info,
	scmi_set_handle(sdev);
}

static void scmi_cleanup_mbox_channels(struct scmi_info *info)
{
	struct idr *idr;

	/* free tx channels */
	idr = &info->tx_idr;
	idr_for_each(idr, scmi_mbox_free_channel, idr);
	idr_destroy(&info->tx_idr);

	/* free rx channels */
	idr = &info->rx_idr;
	idr_for_each(idr, scmi_mbox_free_channel, idr);
	idr_destroy(&info->rx_idr);
}

static int scmi_probe(struct platform_device *pdev)
{
	int ret;
@@ -870,6 +887,7 @@ static int scmi_probe(struct platform_device *pdev)
	ret = scmi_base_protocol_init(handle);
	if (ret) {
		dev_err(dev, "unable to communicate with SCMI(%d)\n", ret);
		scmi_cleanup_mbox_channels(info);
		return ret;
	}