aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtd_blkdevs.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-11-07 22:51:47 -0500
committerJeff Garzik <jgarzik@pobox.com>2005-11-07 22:51:47 -0500
commit6b995751c2e851d2bc9c277b5884d0adb519e31d (patch)
tree7a15b41b5d8ce612915584a0773c670d5c0ab5b8 /drivers/mtd/mtd_blkdevs.c
parent6c2f4267833f453156f8f439cc32eb4c92f357b4 (diff)
parentd27ba47e7e8c466c18983a1779d611f82d6a354f (diff)
Merge branch 'master'
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r--drivers/mtd/mtd_blkdevs.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index f8d2185819e7..339cb1218eaa 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: mtd_blkdevs.c,v 1.24 2004/11/16 18:28:59 dwmw2 Exp $ 2 * $Id: mtd_blkdevs.c,v 1.27 2005/11/07 11:14:20 gleixner Exp $
3 * 3 *
4 * (C) 2003 David Woodhouse <dwmw2@infradead.org> 4 * (C) 2003 David Woodhouse <dwmw2@infradead.org>
5 * 5 *
@@ -21,7 +21,6 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <asm/semaphore.h> 22#include <asm/semaphore.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <linux/devfs_fs_kernel.h>
25 24
26static LIST_HEAD(blktrans_majors); 25static LIST_HEAD(blktrans_majors);
27 26
@@ -86,7 +85,7 @@ static int mtd_blktrans_thread(void *arg)
86 daemonize("%sd", tr->name); 85 daemonize("%sd", tr->name);
87 86
88 /* daemonize() doesn't do this for us since some kernel threads 87 /* daemonize() doesn't do this for us since some kernel threads
89 actually want to deal with signals. We can't just call 88 actually want to deal with signals. We can't just call
90 exit_sighand() since that'll cause an oops when we finally 89 exit_sighand() since that'll cause an oops when we finally
91 do exit. */ 90 do exit. */
92 spin_lock_irq(&current->sighand->siglock); 91 spin_lock_irq(&current->sighand->siglock);
@@ -95,7 +94,7 @@ static int mtd_blktrans_thread(void *arg)
95 spin_unlock_irq(&current->sighand->siglock); 94 spin_unlock_irq(&current->sighand->siglock);
96 95
97 spin_lock_irq(rq->queue_lock); 96 spin_lock_irq(rq->queue_lock);
98 97
99 while (!tr->blkcore_priv->exiting) { 98 while (!tr->blkcore_priv->exiting) {
100 struct request *req; 99 struct request *req;
101 struct mtd_blktrans_dev *dev; 100 struct mtd_blktrans_dev *dev;
@@ -158,7 +157,7 @@ static int blktrans_open(struct inode *i, struct file *f)
158 if (!try_module_get(tr->owner)) 157 if (!try_module_get(tr->owner))
159 goto out_tr; 158 goto out_tr;
160 159
161 /* FIXME: Locking. A hot pluggable device can go away 160 /* FIXME: Locking. A hot pluggable device can go away
162 (del_mtd_device can be called for it) without its module 161 (del_mtd_device can be called for it) without its module
163 being unloaded. */ 162 being unloaded. */
164 dev->mtd->usecount++; 163 dev->mtd->usecount++;
@@ -196,7 +195,7 @@ static int blktrans_release(struct inode *i, struct file *f)
196} 195}
197 196
198 197
199static int blktrans_ioctl(struct inode *inode, struct file *file, 198static int blktrans_ioctl(struct inode *inode, struct file *file,
200 unsigned int cmd, unsigned long arg) 199 unsigned int cmd, unsigned long arg)
201{ 200{
202 struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data; 201 struct mtd_blktrans_dev *dev = inode->i_bdev->bd_disk->private_data;
@@ -265,7 +264,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
265 /* Required number was free */ 264 /* Required number was free */
266 list_add_tail(&new->list, &d->list); 265 list_add_tail(&new->list, &d->list);
267 goto added; 266 goto added;
268 } 267 }
269 last_devnum = d->devnum; 268 last_devnum = d->devnum;
270 } 269 }
271 if (new->devnum == -1) 270 if (new->devnum == -1)
@@ -289,11 +288,19 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
289 gd->major = tr->major; 288 gd->major = tr->major;
290 gd->first_minor = (new->devnum) << tr->part_bits; 289 gd->first_minor = (new->devnum) << tr->part_bits;
291 gd->fops = &mtd_blktrans_ops; 290 gd->fops = &mtd_blktrans_ops;
292 291
293 snprintf(gd->disk_name, sizeof(gd->disk_name), 292 if (tr->part_bits)
294 "%s%c", tr->name, (tr->part_bits?'a':'0') + new->devnum); 293 if (new->devnum < 26)
295 snprintf(gd->devfs_name, sizeof(gd->devfs_name), 294 snprintf(gd->disk_name, sizeof(gd->disk_name),
296 "%s/%c", tr->name, (tr->part_bits?'a':'0') + new->devnum); 295 "%s%c", tr->name, 'a' + new->devnum);
296 else
297 snprintf(gd->disk_name, sizeof(gd->disk_name),
298 "%s%c%c", tr->name,
299 'a' - 1 + new->devnum / 26,
300 'a' + new->devnum % 26);
301 else
302 snprintf(gd->disk_name, sizeof(gd->disk_name),
303 "%s%d", tr->name, new->devnum);
297 304
298 /* 2.5 has capacity in units of 512 bytes while still 305 /* 2.5 has capacity in units of 512 bytes while still
299 having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ 306 having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */
@@ -307,7 +314,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
307 set_disk_ro(gd, 1); 314 set_disk_ro(gd, 1);
308 315
309 add_disk(gd); 316 add_disk(gd);
310 317
311 return 0; 318 return 0;
312} 319}
313 320
@@ -322,7 +329,7 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
322 329
323 del_gendisk(old->blkcore_priv); 330 del_gendisk(old->blkcore_priv);
324 put_disk(old->blkcore_priv); 331 put_disk(old->blkcore_priv);
325 332
326 return 0; 333 return 0;
327} 334}
328 335
@@ -361,12 +368,12 @@ static struct mtd_notifier blktrans_notifier = {
361 .add = blktrans_notify_add, 368 .add = blktrans_notify_add,
362 .remove = blktrans_notify_remove, 369 .remove = blktrans_notify_remove,
363}; 370};
364 371
365int register_mtd_blktrans(struct mtd_blktrans_ops *tr) 372int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
366{ 373{
367 int ret, i; 374 int ret, i;
368 375
369 /* Register the notifier if/when the first device type is 376 /* Register the notifier if/when the first device type is
370 registered, to prevent the link/init ordering from fucking 377 registered, to prevent the link/init ordering from fucking
371 us over. */ 378 us over. */
372 if (!blktrans_notifier.list.next) 379 if (!blktrans_notifier.list.next)
@@ -409,9 +416,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
409 kfree(tr->blkcore_priv); 416 kfree(tr->blkcore_priv);
410 up(&mtd_table_mutex); 417 up(&mtd_table_mutex);
411 return ret; 418 return ret;
412 } 419 }
413
414 devfs_mk_dir(tr->name);
415 420
416 INIT_LIST_HEAD(&tr->devs); 421 INIT_LIST_HEAD(&tr->devs);
417 list_add(&tr->list, &blktrans_majors); 422 list_add(&tr->list, &blktrans_majors);
@@ -445,7 +450,6 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
445 tr->remove_dev(dev); 450 tr->remove_dev(dev);
446 } 451 }
447 452
448 devfs_remove(tr->name);
449 blk_cleanup_queue(tr->blkcore_priv->rq); 453 blk_cleanup_queue(tr->blkcore_priv->rq);
450 unregister_blkdev(tr->major, tr->name); 454 unregister_blkdev(tr->major, tr->name);
451 455