mtd: Allow dynamic major/minor number for mtd block devices
PATCH 5/9 mtd: Allow dynamic major/minor number for mtd block devices
Allow mtd block devices to have a dynamically allocated major/minor numbers if tr->major == 0.
Signed-off-by Richard Purdie <[email protected]>
--- drivers/mtd/mtd_blkdevs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mtd/mtd_blkdevs.c +4 -1
@@ -380,13 +380,16 @@ int register_mtd_blktrans(struct mtd_blkmutex_lock (&mtd_table_mutex); ret =register_blkdev (tr->major, tr->name); -if (ret) { +if (ret <0 ) {printk (KERN_WARNING "Unable to register %s block device on major %d: %d\n" , tr->name, tr->major, ret);kfree (tr->blkcore_priv);mutex_unlock (&mtd_table_mutex);return ret; } +if (!tr->major) + tr->major = ret; +spin_lock_init (&tr->blkcore_priv->queue_lock);init_completion (&tr->blkcore_priv->thread_dead);init_waitqueue_head (&tr->blkcore_priv->thread_wq);