Skip to content

Commit e9eceec

Browse files
glneoJassi Brar
authored andcommitted
mailbox: omap: Move fifo size check to point of use
The mbox_kfifo_size can be changed at runtime, the sanity check on it's value should be done when it is used, not only once at init time. Signed-off-by: Andrew Davis <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent 6979e8b commit e9eceec

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/mailbox/omap-mailbox.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
310310
void (*work)(struct work_struct *))
311311
{
312312
struct omap_mbox_queue *mq;
313+
unsigned int size;
313314

314315
if (!work)
315316
return NULL;
@@ -320,7 +321,10 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
320321

321322
spin_lock_init(&mq->lock);
322323

323-
if (kfifo_alloc(&mq->fifo, mbox_kfifo_size, GFP_KERNEL))
324+
/* kfifo size sanity check: alignment and minimal size */
325+
size = ALIGN(mbox_kfifo_size, sizeof(u32));
326+
size = max_t(unsigned int, size, sizeof(u32));
327+
if (kfifo_alloc(&mq->fifo, size, GFP_KERNEL))
324328
goto error;
325329

326330
INIT_WORK(&mq->work, work);
@@ -838,10 +842,6 @@ static int __init omap_mbox_init(void)
838842
if (err)
839843
return err;
840844

841-
/* kfifo size sanity check: alignment and minimal size */
842-
mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(u32));
843-
mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(u32));
844-
845845
err = platform_driver_register(&omap_mbox_driver);
846846
if (err)
847847
class_unregister(&omap_mbox_class);

0 commit comments

Comments
 (0)