Skip to content

Commit 34123b1

Browse files
glneoJassi Brar
authored andcommitted
mailbox: omap: Use mbox_controller channel list directly
The driver stores a list of omap_mbox structs so it can later use it to lookup the mailbox names in of_xlate. This same information is already available in the mbox_controller passed into of_xlate. Simply use that data and remove the extra allocation and storage of the omap_mbox list. Signed-off-by: Andrew Davis <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent 2a0fca3 commit 34123b1

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

drivers/mailbox/omap-mailbox.c

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ struct omap_mbox_device {
8585
u32 num_users;
8686
u32 num_fifos;
8787
u32 intr_type;
88-
struct omap_mbox **mboxes;
8988
};
9089

9190
struct omap_mbox {
@@ -356,25 +355,6 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
356355
mbox_queue_free(mbox->rxq);
357356
}
358357

359-
static struct omap_mbox *omap_mbox_device_find(struct omap_mbox_device *mdev,
360-
const char *mbox_name)
361-
{
362-
struct omap_mbox *_mbox, *mbox = NULL;
363-
struct omap_mbox **mboxes = mdev->mboxes;
364-
int i;
365-
366-
if (!mboxes)
367-
return NULL;
368-
369-
for (i = 0; (_mbox = mboxes[i]); i++) {
370-
if (!strcmp(_mbox->name, mbox_name)) {
371-
mbox = _mbox;
372-
break;
373-
}
374-
}
375-
return mbox;
376-
}
377-
378358
static int omap_mbox_chan_startup(struct mbox_chan *chan)
379359
{
380360
struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
@@ -539,6 +519,7 @@ static struct mbox_chan *omap_mbox_of_xlate(struct mbox_controller *controller,
539519
struct device_node *node;
540520
struct omap_mbox_device *mdev;
541521
struct omap_mbox *mbox;
522+
int i;
542523

543524
mdev = dev_get_drvdata(controller->dev);
544525
if (WARN_ON(!mdev))
@@ -551,16 +532,23 @@ static struct mbox_chan *omap_mbox_of_xlate(struct mbox_controller *controller,
551532
return ERR_PTR(-ENODEV);
552533
}
553534

554-
mbox = omap_mbox_device_find(mdev, node->name);
535+
for (i = 0; i < controller->num_chans; i++) {
536+
mbox = controller->chans[i].con_priv;
537+
if (!strcmp(mbox->name, node->name)) {
538+
of_node_put(node);
539+
return &controller->chans[i];
540+
}
541+
}
542+
555543
of_node_put(node);
556-
return mbox ? mbox->chan : ERR_PTR(-ENOENT);
544+
return ERR_PTR(-ENOENT);
557545
}
558546

559547
static int omap_mbox_probe(struct platform_device *pdev)
560548
{
561549
int ret;
562550
struct mbox_chan *chnls;
563-
struct omap_mbox **list, *mbox;
551+
struct omap_mbox *mbox;
564552
struct omap_mbox_device *mdev;
565553
struct omap_mbox_fifo *fifo;
566554
struct device_node *node = pdev->dev.of_node;
@@ -608,12 +596,6 @@ static int omap_mbox_probe(struct platform_device *pdev)
608596
if (!mdev->irq_ctx)
609597
return -ENOMEM;
610598

611-
/* allocate one extra for marking end of list */
612-
list = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*list),
613-
GFP_KERNEL);
614-
if (!list)
615-
return -ENOMEM;
616-
617599
chnls = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*chnls),
618600
GFP_KERNEL);
619601
if (!chnls)
@@ -675,15 +657,13 @@ static int omap_mbox_probe(struct platform_device *pdev)
675657
return mbox->irq;
676658
mbox->chan = &chnls[i];
677659
chnls[i].con_priv = mbox;
678-
list[i] = mbox++;
679660
}
680661

681662
mutex_init(&mdev->cfg_lock);
682663
mdev->dev = &pdev->dev;
683664
mdev->num_users = num_users;
684665
mdev->num_fifos = num_fifos;
685666
mdev->intr_type = intr_type;
686-
mdev->mboxes = list;
687667

688668
controller = devm_kzalloc(&pdev->dev, sizeof(*controller), GFP_KERNEL);
689669
if (!controller)

0 commit comments

Comments
 (0)