1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-25 11:02:26 +02:00

fix broken patch.

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13126 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
lars 2008-11-05 13:03:00 +00:00
parent 4363af719c
commit 5741f54d7d

View File

@ -373,7 +373,7 @@
return err; return err;
} }
@@ -210,7 +246,12 @@ static int block2mtd_write(struct mtd_in @@ -210,32 +246,109 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
static void block2mtd_sync(struct mtd_info *mtd) static void block2mtd_sync(struct mtd_info *mtd)
{ {
struct block2mtd_dev *dev = mtd->priv; struct block2mtd_dev *dev = mtd->priv;
@ -387,74 +387,37 @@
return; return;
} }
@@ -288,47 +288,17 @@ static void block2mtd_sync(struct mtd_info *mtd)
}
-static void block2mtd_free_device(struct block2mtd_dev *dev)
-{
- if (!dev)
- return;
-
- kfree(dev->mtd.name);
-
- if (dev->blkdev) {
- invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping,
- 0, -1);
- close_bdev_excl(dev->blkdev);
- }
-
- kfree(dev);
-}
-
-
-/* FIXME: ensure that mtd->size % erase_size == 0 */
-static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
+static int _open_bdev(struct block2mtd_dev *dev) +static int _open_bdev(struct block2mtd_dev *dev)
{ +{
struct block_device *bdev; + struct block_device *bdev;
- struct block2mtd_dev *dev; +
- struct mtd_partition *part; + /* Get a handle on the device */
- char *name;
- if (!devname)
- return NULL;
-
- dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
- if (!dev)
- return NULL;
-
/* Get a handle on the device */
- bdev = open_bdev_excl(devname, O_RDWR, NULL);
+ bdev = open_bdev_excl(dev->devname, O_RDWR, NULL); + bdev = open_bdev_excl(dev->devname, O_RDWR, NULL);
#ifndef MODULE +#ifndef MODULE
if (IS_ERR(bdev)) { + if (IS_ERR(bdev)) {
+
/* We might not have rootfs mounted at this point. Try + /* We might not have rootfs mounted at this point. Try
to resolve the device name by other means. */ + to resolve the device name by other means. */
+
- dev_t devt = name_to_dev_t(devname);
+ dev_t devt = name_to_dev_t(dev->devname); + dev_t devt = name_to_dev_t(dev->devname);
if (devt) { + if (devt) {
bdev = open_by_devnum(devt, FMODE_WRITE | FMODE_READ); + bdev = open_by_devnum(devt, FMODE_WRITE | FMODE_READ);
} + }
@@ -263,17 +295,97 @@ static struct block2mtd_dev *add_device( + }
#endif +#endif
+
if (IS_ERR(bdev)) { + if (IS_ERR(bdev)) {
- ERROR("error: cannot open device %s", devname);
- goto devinit_err;
+ ERROR("error: cannot open device %s", dev->devname); + ERROR("error: cannot open device %s", dev->devname);
+ return 1; + return 1;
} + }
dev->blkdev = bdev; + dev->blkdev = bdev;
+
if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) { + if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
ERROR("attempting to use an MTD device as a block device"); + ERROR("attempting to use an MTD device as a block device");
- goto devinit_err;
+ return 1; + return 1;
} + }
+
+ return 0; + return 0;
+} +}
+ +
@ -471,12 +434,12 @@
+ dev->blkdev = NULL; + dev->blkdev = NULL;
+} +}
+ +
+static void block2mtd_free_device(struct block2mtd_dev *dev) static void block2mtd_free_device(struct block2mtd_dev *dev)
+{ {
+ if (!dev) if (!dev)
+ return; return;
+
+ kfree(dev->mtd.name); kfree(dev->mtd.name);
+ _close_bdev(dev); + _close_bdev(dev);
+ kfree(dev); + kfree(dev);
+} +}
@ -494,7 +457,11 @@
+ +
+ /* get the device number for the whole disk */ + /* get the device number for the whole disk */
+ devt = MKDEV(MAJOR(dev->blkdev->bd_dev), 0); + devt = MKDEV(MAJOR(dev->blkdev->bd_dev), 0);
+
- if (dev->blkdev) {
- invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping,
- 0, -1);
- close_bdev_excl(dev->blkdev);
+ /* close the old block device */ + /* close the old block device */
+ _close_bdev(dev); + _close_bdev(dev);
+ +
@ -504,36 +471,64 @@
+ err = -EINVAL; + err = -EINVAL;
+ else { + else {
+ err = rescan_partitions(bdev->bd_disk, bdev); + err = rescan_partitions(bdev->bd_disk, bdev);
+ } }
+ if (bdev) + if (bdev)
+ close_bdev_excl(bdev); + close_bdev_excl(bdev);
+
- kfree(dev);
-}
+ /* try to open the partition block device again */ + /* try to open the partition block device again */
+ _open_bdev(dev); + _open_bdev(dev);
+ write_unlock(&dev->bdev_mutex); + write_unlock(&dev->bdev_mutex);
+
+ return err; + return err;
+} +}
+
+/* FIXME: ensure that mtd->size % erase_size == 0 */ /* FIXME: ensure that mtd->size % erase_size == 0 */
-static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
+static struct block2mtd_dev *add_device(char *devname, int erase_size, char *mtdname) +static struct block2mtd_dev *add_device(char *devname, int erase_size, char *mtdname)
+{ {
+ struct block2mtd_dev *dev; - struct block_device *bdev;
+ struct mtd_partition *part; struct block2mtd_dev *dev;
+ char *name; struct mtd_partition *part;
+ char *name;
+ if (!devname) @@ -243,37 +356,17 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, const cha
+ return NULL; if (!devname)
+ return NULL;
- dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct block2mtd_dev) + strlen(devname) + 1, GFP_KERNEL); + dev = kzalloc(sizeof(struct block2mtd_dev) + strlen(devname) + 1, GFP_KERNEL);
+ if (!dev) if (!dev)
+ return NULL; return NULL;
+
- /* Get a handle on the device */
- bdev = open_bdev_excl(devname, O_RDWR, NULL);
-#ifndef MODULE
- if (IS_ERR(bdev)) {
-
- /* We might not have rootfs mounted at this point. Try
- to resolve the device name by other means. */
+ strcpy(dev->devname, devname); + strcpy(dev->devname, devname);
+
- dev_t devt = name_to_dev_t(devname);
- if (devt) {
- bdev = open_by_devnum(devt, FMODE_WRITE | FMODE_READ);
- }
- }
-#endif
-
- if (IS_ERR(bdev)) {
- ERROR("error: cannot open device %s", devname);
+ if (_open_bdev(dev)) + if (_open_bdev(dev))
+ goto devinit_err; goto devinit_err;
+ - }
- dev->blkdev = bdev;
-
- if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
- ERROR("attempting to use an MTD device as a block device");
- goto devinit_err;
- }
mutex_init(&dev->write_mutex); mutex_init(&dev->write_mutex);
+ rwlock_init(&dev->bdev_mutex); + rwlock_init(&dev->bdev_mutex);