Replace page_read() with read_kmap_page()/__read_kmap_page().  This probably
fixes behaviour on highmem systems, since page_address() was being used
without kmap().  Also eliminate the need to re-take the page lock during
writes to the page.

Signed-off-by: Nate Diller <[EMAIL PROTECTED]>

---

diff -urpN -X dontdiff linux-2.6.21-rc5-mm4/drivers/mtd/devices/block2mtd.c 
linux-2.6.21-rc5-mm4-test/drivers/mtd/devices/block2mtd.c
--- linux-2.6.21-rc5-mm4/drivers/mtd/devices/block2mtd.c        2007-04-05 
17:14:24.000000000 -0700
+++ linux-2.6.21-rc5-mm4-test/drivers/mtd/devices/block2mtd.c   2007-04-06 
01:59:19.000000000 -0700
@@ -39,12 +39,6 @@ struct block2mtd_dev {
 /* Static info about the MTD, used in cleanup_module */
 static LIST_HEAD(blkmtd_device_list);
 
-
-static struct page *page_read(struct address_space *mapping, int index)
-{
-       return read_mapping_page(mapping, index, NULL);
-}
-
 /* erase a specified part of the device */
 static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t len)
 {
@@ -56,23 +50,19 @@ static int _block2mtd_erase(struct block
        u_long *max;
 
        while (pages) {
-               page = page_read(mapping, index);
-               if (!page)
-                       return -ENOMEM;
+               page = __read_kmap_page(mapping, index);
                if (IS_ERR(page))
                        return PTR_ERR(page);
 
                max = page_address(page) + PAGE_SIZE;
                for (p=page_address(page); p<max; p++)
                        if (*p != -1UL) {
-                               lock_page(page);
                                memset(page_address(page), 0xff, PAGE_SIZE);
                                set_page_dirty(page);
-                               unlock_page(page);
                                break;
                        }
 
-               page_cache_release(page);
+               put_locked_page(page);
                pages--;
                index++;
        }
@@ -125,14 +115,12 @@ static int block2mtd_read(struct mtd_inf
                        cpylen = len;   // this page
                len = len - cpylen;
 
-               page = page_read(dev->blkdev->bd_inode->i_mapping, index);
-               if (!page)
-                       return -ENOMEM;
+               page = read_kmap_page(dev->blkdev->bd_inode->i_mapping, index);
                if (IS_ERR(page))
                        return PTR_ERR(page);
 
                memcpy(buf, page_address(page) + offset, cpylen);
-               page_cache_release(page);
+               put_kmapped_page(page);
 
                if (retlen)
                        *retlen += cpylen;
@@ -163,19 +151,15 @@ static int _block2mtd_write(struct block
                        cpylen = len;                   // this page
                len = len - cpylen;
 
-               page = page_read(mapping, index);
-               if (!page)
-                       return -ENOMEM;
+               page = __read_kmap_page(mapping, index);
                if (IS_ERR(page))
                        return PTR_ERR(page);
 
                if (memcmp(page_address(page)+offset, buf, cpylen)) {
-                       lock_page(page);
                        memcpy(page_address(page) + offset, buf, cpylen);
                        set_page_dirty(page);
-                       unlock_page(page);
                }
-               page_cache_release(page);
+               put_locked_page(page);
 
                if (retlen)
                        *retlen += cpylen;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to