drivers/mailbox/cix-mailbox.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
From: Surendra Singh Chouhan <kr494167@gmail.com>
cix_mbox_startup() checked fast channel index constraints (index < 0 ||
index > CIX_MBOX_FAST_IDX) inside the channel switch block after
calling request_irq(). If validation failed, it triggered a free_irq()
cleanup path. Validating channel parameters prior to request_irq()
avoids unnecessary IRQ registration/teardown churn.
In addition, cix_mbox_probe() logged property errors referencing
"cix,mbox_dir" (with an underscore) instead of the actual DT property
name "cix,mbox-dir". Convert cix_mbox_probe() error paths to use
dev_err_probe() and fix the DT property string spelling.
Fixes: fe2aa2361ddb ("mailbox: add CIX mailbox driver")
Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
---
drivers/mailbox/cix-mailbox.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/mailbox/cix-mailbox.c b/drivers/mailbox/cix-mailbox.c
index 43c76cdab24a..24cea67c407d 100644
--- a/drivers/mailbox/cix-mailbox.c
+++ b/drivers/mailbox/cix-mailbox.c
@@ -403,6 +403,13 @@ static int cix_mbox_startup(struct mbox_chan *chan)
int index = cp->index, ret;
u32 val;
+ if (cp->type == CIX_MBOX_TYPE_FAST && priv->dir == CIX_MBOX_RX) {
+ if (index < 0 || index > CIX_MBOX_FAST_IDX) {
+ dev_err(priv->dev, "Invalid index %d\n", index);
+ return -EINVAL;
+ }
+ }
+
ret = request_irq(priv->irq, cix_mbox_isr, IRQF_NO_SUSPEND,
dev_name(priv->dev), chan);
if (ret) {
@@ -448,11 +455,6 @@ static int cix_mbox_startup(struct mbox_chan *chan)
case CIX_MBOX_TYPE_FAST:
/* Only RX channel has intterupt */
if (priv->dir == CIX_MBOX_RX) {
- if (index < 0 || index > CIX_MBOX_FAST_IDX) {
- dev_err(priv->dev, "Invalid index %d\n", index);
- ret = -EINVAL;
- goto failed;
- }
/* enable fast channel interrupt */
val = cix_mbox_read(priv, CIX_INT_ENABLE_SIDE_B);
val |= CIX_FAST_CH_INT(index);
@@ -587,19 +589,18 @@ static int cix_mbox_probe(struct platform_device *pdev)
if (priv->irq < 0)
return priv->irq;
- if (device_property_read_string(dev, "cix,mbox-dir", &dir_str)) {
- dev_err(priv->dev, "cix,mbox_dir property not found\n");
- return -EINVAL;
- }
+ if (device_property_read_string(dev, "cix,mbox-dir", &dir_str))
+ return dev_err_probe(dev, -EINVAL,
+ "cix,mbox-dir property not found\n");
if (!strcmp(dir_str, "tx"))
priv->dir = 0;
else if (!strcmp(dir_str, "rx"))
priv->dir = 1;
- else {
- dev_err(priv->dev, "cix,mbox_dir=%s is not expected\n", dir_str);
- return -EINVAL;
- }
+ else
+ return dev_err_probe(dev, -EINVAL,
+ "cix,mbox-dir=%s is not expected\n",
+ dir_str);
cix_mbox_init(priv);
@@ -613,9 +614,9 @@ static int cix_mbox_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
ret = devm_mbox_controller_register(dev, &priv->mbox);
if (ret)
- dev_err(dev, "Failed to register mailbox %d\n", ret);
+ return dev_err_probe(dev, ret, "Failed to register mailbox\n");
- return ret;
+ return 0;
}
static const struct of_device_id cix_mbox_dt_ids[] = {
--
2.55.0
© 2016 - 2026 Red Hat, Inc.