Merge git://git.infradead.org/mtd-2.6

* git://git.infradead.org/mtd-2.6:
jffs2: Fix return value from jffs2_do_readpage_nolock()
mtd: mtdblock: introduce mtdblks_lock
mtd: remove 'SBC8240 Wind River' Device Driver Code
mtd: OneNAND: OMAP2/3: free GPMC CS on module removal
mtd: OneNAND: fix incorrect bufferram offset
mtd: blkdevs: do not forget to get MTD devices
mtd: fix the conversion from dev to mtd_info
mtd: let include/linux/mtd/partitions.h stand on its own

+28 -268
-7
drivers/mtd/maps/Kconfig
··· 284 284 285 285 BE VERY CAREFUL. 286 286 287 - config MTD_SBC8240 288 - tristate "Flash device on SBC8240" 289 - depends on MTD_JEDECPROBE && 8260 290 - help 291 - Flash access on the SBC8240 board from Wind River. See 292 - <http://www.windriver.com/products/sbc8240/> 293 - 294 287 config MTD_TQM8XXL 295 288 tristate "CFI Flash device mapped on TQM8XXL" 296 289 depends on MTD_CFI && TQM8xxL
-1
drivers/mtd/maps/Makefile
··· 50 50 obj-$(CONFIG_MTD_NETtel) += nettel.o 51 51 obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o 52 52 obj-$(CONFIG_MTD_H720X) += h720x-flash.o 53 - obj-$(CONFIG_MTD_SBC8240) += sbc8240.o 54 53 obj-$(CONFIG_MTD_IXP4XX) += ixp4xx.o 55 54 obj-$(CONFIG_MTD_IXP2000) += ixp2000.o 56 55 obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o
-250
drivers/mtd/maps/sbc8240.c
··· 1 - /* 2 - * Handle mapping of the flash memory access routines on the SBC8240 board. 3 - * 4 - * Carolyn Smith, Tektronix, Inc. 5 - * 6 - * This code is GPLed 7 - */ 8 - 9 - /* 10 - * The SBC8240 has 2 flash banks. 11 - * Bank 0 is a 512 KiB AMD AM29F040B; 8 x 64 KiB sectors. 12 - * It contains the U-Boot code (7 sectors) and the environment (1 sector). 13 - * Bank 1 is 4 x 1 MiB AMD AM29LV800BT; 15 x 64 KiB sectors, 1 x 32 KiB sector, 14 - * 2 x 8 KiB sectors, 1 x 16 KiB sectors. 15 - * Both parts are JEDEC compatible. 16 - */ 17 - 18 - #include <linux/module.h> 19 - #include <linux/types.h> 20 - #include <linux/kernel.h> 21 - #include <asm/io.h> 22 - 23 - #include <linux/mtd/mtd.h> 24 - #include <linux/mtd/map.h> 25 - #include <linux/mtd/cfi.h> 26 - 27 - #ifdef CONFIG_MTD_PARTITIONS 28 - #include <linux/mtd/partitions.h> 29 - #endif 30 - 31 - #define DEBUG 32 - 33 - #ifdef DEBUG 34 - # define debugk(fmt,args...) printk(fmt ,##args) 35 - #else 36 - # define debugk(fmt,args...) 37 - #endif 38 - 39 - 40 - #define WINDOW_ADDR0 0xFFF00000 /* 512 KiB */ 41 - #define WINDOW_SIZE0 0x00080000 42 - #define BUSWIDTH0 1 43 - 44 - #define WINDOW_ADDR1 0xFF000000 /* 4 MiB */ 45 - #define WINDOW_SIZE1 0x00400000 46 - #define BUSWIDTH1 8 47 - 48 - #define MSG_PREFIX "sbc8240:" /* prefix for our printk()'s */ 49 - #define MTDID "sbc8240-%d" /* for mtdparts= partitioning */ 50 - 51 - 52 - static struct map_info sbc8240_map[2] = { 53 - { 54 - .name = "sbc8240 Flash Bank #0", 55 - .size = WINDOW_SIZE0, 56 - .bankwidth = BUSWIDTH0, 57 - }, 58 - { 59 - .name = "sbc8240 Flash Bank #1", 60 - .size = WINDOW_SIZE1, 61 - .bankwidth = BUSWIDTH1, 62 - } 63 - }; 64 - 65 - #define NUM_FLASH_BANKS ARRAY_SIZE(sbc8240_map) 66 - 67 - /* 68 - * The following defines the partition layout of SBC8240 boards. 69 - * 70 - * See include/linux/mtd/partitions.h for definition of the 71 - * mtd_partition structure. 72 - * 73 - * The *_max_flash_size is the maximum possible mapped flash size 74 - * which is not necessarily the actual flash size. It must correspond 75 - * to the value specified in the mapping definition defined by the 76 - * "struct map_desc *_io_desc" for the corresponding machine. 77 - */ 78 - 79 - #ifdef CONFIG_MTD_PARTITIONS 80 - 81 - static struct mtd_partition sbc8240_uboot_partitions [] = { 82 - /* Bank 0 */ 83 - { 84 - .name = "U-boot", /* U-Boot Firmware */ 85 - .offset = 0, 86 - .size = 0x00070000, /* 7 x 64 KiB sectors */ 87 - .mask_flags = MTD_WRITEABLE, /* force read-only */ 88 - }, 89 - { 90 - .name = "environment", /* U-Boot environment */ 91 - .offset = 0x00070000, 92 - .size = 0x00010000, /* 1 x 64 KiB sector */ 93 - }, 94 - }; 95 - 96 - static struct mtd_partition sbc8240_fs_partitions [] = { 97 - { 98 - .name = "jffs", /* JFFS filesystem */ 99 - .offset = 0, 100 - .size = 0x003C0000, /* 4 * 15 * 64KiB */ 101 - }, 102 - { 103 - .name = "tmp32", 104 - .offset = 0x003C0000, 105 - .size = 0x00020000, /* 4 * 32KiB */ 106 - }, 107 - { 108 - .name = "tmp8a", 109 - .offset = 0x003E0000, 110 - .size = 0x00008000, /* 4 * 8KiB */ 111 - }, 112 - { 113 - .name = "tmp8b", 114 - .offset = 0x003E8000, 115 - .size = 0x00008000, /* 4 * 8KiB */ 116 - }, 117 - { 118 - .name = "tmp16", 119 - .offset = 0x003F0000, 120 - .size = 0x00010000, /* 4 * 16KiB */ 121 - } 122 - }; 123 - 124 - /* trivial struct to describe partition information */ 125 - struct mtd_part_def 126 - { 127 - int nums; 128 - unsigned char *type; 129 - struct mtd_partition* mtd_part; 130 - }; 131 - 132 - static struct mtd_info *sbc8240_mtd[NUM_FLASH_BANKS]; 133 - static struct mtd_part_def sbc8240_part_banks[NUM_FLASH_BANKS]; 134 - 135 - 136 - #endif /* CONFIG_MTD_PARTITIONS */ 137 - 138 - 139 - static int __init init_sbc8240_mtd (void) 140 - { 141 - static struct _cjs { 142 - u_long addr; 143 - u_long size; 144 - } pt[NUM_FLASH_BANKS] = { 145 - { 146 - .addr = WINDOW_ADDR0, 147 - .size = WINDOW_SIZE0 148 - }, 149 - { 150 - .addr = WINDOW_ADDR1, 151 - .size = WINDOW_SIZE1 152 - }, 153 - }; 154 - 155 - int devicesfound = 0; 156 - int i,j; 157 - 158 - for (i = 0; i < NUM_FLASH_BANKS; i++) { 159 - printk (KERN_NOTICE MSG_PREFIX 160 - "Probing 0x%08lx at 0x%08lx\n", pt[i].size, pt[i].addr); 161 - 162 - sbc8240_map[i].map_priv_1 = 163 - (unsigned long) ioremap (pt[i].addr, pt[i].size); 164 - if (!sbc8240_map[i].map_priv_1) { 165 - printk (MSG_PREFIX "failed to ioremap\n"); 166 - for (j = 0; j < i; j++) { 167 - iounmap((void *) sbc8240_map[j].map_priv_1); 168 - sbc8240_map[j].map_priv_1 = 0; 169 - } 170 - return -EIO; 171 - } 172 - simple_map_init(&sbc8240_mtd[i]); 173 - 174 - sbc8240_mtd[i] = do_map_probe("jedec_probe", &sbc8240_map[i]); 175 - 176 - if (sbc8240_mtd[i]) { 177 - sbc8240_mtd[i]->module = THIS_MODULE; 178 - devicesfound++; 179 - } else { 180 - if (sbc8240_map[i].map_priv_1) { 181 - iounmap((void *) sbc8240_map[i].map_priv_1); 182 - sbc8240_map[i].map_priv_1 = 0; 183 - } 184 - } 185 - } 186 - 187 - if (!devicesfound) { 188 - printk(KERN_NOTICE MSG_PREFIX 189 - "No suppported flash chips found!\n"); 190 - return -ENXIO; 191 - } 192 - 193 - #ifdef CONFIG_MTD_PARTITIONS 194 - sbc8240_part_banks[0].mtd_part = sbc8240_uboot_partitions; 195 - sbc8240_part_banks[0].type = "static image"; 196 - sbc8240_part_banks[0].nums = ARRAY_SIZE(sbc8240_uboot_partitions); 197 - sbc8240_part_banks[1].mtd_part = sbc8240_fs_partitions; 198 - sbc8240_part_banks[1].type = "static file system"; 199 - sbc8240_part_banks[1].nums = ARRAY_SIZE(sbc8240_fs_partitions); 200 - 201 - for (i = 0; i < NUM_FLASH_BANKS; i++) { 202 - 203 - if (!sbc8240_mtd[i]) continue; 204 - if (sbc8240_part_banks[i].nums == 0) { 205 - printk (KERN_NOTICE MSG_PREFIX 206 - "No partition info available, registering whole device\n"); 207 - add_mtd_device(sbc8240_mtd[i]); 208 - } else { 209 - printk (KERN_NOTICE MSG_PREFIX 210 - "Using %s partition definition\n", sbc8240_part_banks[i].mtd_part->name); 211 - add_mtd_partitions (sbc8240_mtd[i], 212 - sbc8240_part_banks[i].mtd_part, 213 - sbc8240_part_banks[i].nums); 214 - } 215 - } 216 - #else 217 - printk(KERN_NOTICE MSG_PREFIX 218 - "Registering %d flash banks at once\n", devicesfound); 219 - 220 - for (i = 0; i < devicesfound; i++) { 221 - add_mtd_device(sbc8240_mtd[i]); 222 - } 223 - #endif /* CONFIG_MTD_PARTITIONS */ 224 - 225 - return devicesfound == 0 ? -ENXIO : 0; 226 - } 227 - 228 - static void __exit cleanup_sbc8240_mtd (void) 229 - { 230 - int i; 231 - 232 - for (i = 0; i < NUM_FLASH_BANKS; i++) { 233 - if (sbc8240_mtd[i]) { 234 - del_mtd_device (sbc8240_mtd[i]); 235 - map_destroy (sbc8240_mtd[i]); 236 - } 237 - if (sbc8240_map[i].map_priv_1) { 238 - iounmap ((void *) sbc8240_map[i].map_priv_1); 239 - sbc8240_map[i].map_priv_1 = 0; 240 - } 241 - } 242 - } 243 - 244 - module_init (init_sbc8240_mtd); 245 - module_exit (cleanup_sbc8240_mtd); 246 - 247 - MODULE_LICENSE ("GPL"); 248 - MODULE_AUTHOR ("Carolyn Smith <carolyn.smith@tektronix.com>"); 249 - MODULE_DESCRIPTION ("MTD map driver for SBC8240 boards"); 250 -
+3 -3
drivers/mtd/mtd_blkdevs.c
··· 144 144 struct mtd_blktrans_ops *tr = dev->tr; 145 145 int ret = -ENODEV; 146 146 147 - if (!try_module_get(dev->mtd->owner)) 147 + if (!get_mtd_device(NULL, dev->mtd->index)) 148 148 goto out; 149 149 150 150 if (!try_module_get(tr->owner)) ··· 158 158 ret = 0; 159 159 if (tr->open && (ret = tr->open(dev))) { 160 160 dev->mtd->usecount--; 161 - module_put(dev->mtd->owner); 161 + put_mtd_device(dev->mtd); 162 162 out_tr: 163 163 module_put(tr->owner); 164 164 } ··· 177 177 178 178 if (!ret) { 179 179 dev->mtd->usecount--; 180 - module_put(dev->mtd->owner); 180 + put_mtd_device(dev->mtd); 181 181 module_put(tr->owner); 182 182 } 183 183
+15 -1
drivers/mtd/mtdblock.c
··· 29 29 enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state; 30 30 } *mtdblks[MAX_MTD_DEVICES]; 31 31 32 + static struct mutex mtdblks_lock; 33 + 32 34 /* 33 35 * Cache stuff... 34 36 * ··· 272 270 273 271 DEBUG(MTD_DEBUG_LEVEL1,"mtdblock_open\n"); 274 272 273 + mutex_lock(&mtdblks_lock); 275 274 if (mtdblks[dev]) { 276 275 mtdblks[dev]->count++; 276 + mutex_unlock(&mtdblks_lock); 277 277 return 0; 278 278 } 279 279 280 280 /* OK, it's not open. Create cache info for it */ 281 281 mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); 282 - if (!mtdblk) 282 + if (!mtdblk) { 283 + mutex_unlock(&mtdblks_lock); 283 284 return -ENOMEM; 285 + } 284 286 285 287 mtdblk->count = 1; 286 288 mtdblk->mtd = mtd; ··· 297 291 } 298 292 299 293 mtdblks[dev] = mtdblk; 294 + mutex_unlock(&mtdblks_lock); 300 295 301 296 DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); 302 297 ··· 311 304 312 305 DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); 313 306 307 + mutex_lock(&mtdblks_lock); 308 + 314 309 mutex_lock(&mtdblk->cache_mutex); 315 310 write_cached_data(mtdblk); 316 311 mutex_unlock(&mtdblk->cache_mutex); ··· 325 316 vfree(mtdblk->cache_data); 326 317 kfree(mtdblk); 327 318 } 319 + 320 + mutex_unlock(&mtdblks_lock); 321 + 328 322 DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); 329 323 330 324 return 0; ··· 388 376 389 377 static int __init init_mtdblock(void) 390 378 { 379 + mutex_init(&mtdblks_lock); 380 + 391 381 return register_mtd_blktrans(&mtdblock_tr); 392 382 } 393 383
+4 -3
drivers/mtd/mtdcore.c
··· 65 65 static int mtd_cls_suspend(struct device *dev, pm_message_t state) 66 66 { 67 67 struct mtd_info *mtd = dev_to_mtd(dev); 68 - 69 - if (mtd->suspend) 68 + 69 + if (mtd && mtd->suspend) 70 70 return mtd->suspend(mtd); 71 71 else 72 72 return 0; ··· 76 76 { 77 77 struct mtd_info *mtd = dev_to_mtd(dev); 78 78 79 - if (mtd->resume) 79 + if (mtd && mtd->resume) 80 80 mtd->resume(mtd); 81 81 return 0; 82 82 } ··· 298 298 mtd->dev.class = &mtd_class; 299 299 mtd->dev.devt = MTD_DEVT(i); 300 300 dev_set_name(&mtd->dev, "mtd%d", i); 301 + dev_set_drvdata(&mtd->dev, mtd); 301 302 if (device_register(&mtd->dev) != 0) { 302 303 mtd_table[i] = NULL; 303 304 break;
+2 -1
drivers/mtd/onenand/omap2.c
··· 266 266 267 267 if (ONENAND_CURRENT_BUFFERRAM(this)) { 268 268 if (area == ONENAND_DATARAM) 269 - return mtd->writesize; 269 + return this->writesize; 270 270 if (area == ONENAND_SPARERAM) 271 271 return mtd->oobsize; 272 272 } ··· 770 770 } 771 771 iounmap(c->onenand.base); 772 772 release_mem_region(c->phys_base, ONENAND_IO_SIZE); 773 + gpmc_cs_free(c->gpmc_cs); 773 774 kfree(c); 774 775 775 776 return 0;
+1 -1
fs/jffs2/file.c
··· 99 99 kunmap(pg); 100 100 101 101 D2(printk(KERN_DEBUG "readpage finished\n")); 102 - return 0; 102 + return ret; 103 103 } 104 104 105 105 int jffs2_do_readpage_unlock(struct inode *inode, struct page *pg)
+1 -1
include/linux/mtd/mtd.h
··· 251 251 252 252 static inline struct mtd_info *dev_to_mtd(struct device *dev) 253 253 { 254 - return dev ? container_of(dev, struct mtd_info, dev) : NULL; 254 + return dev ? dev_get_drvdata(dev) : NULL; 255 255 } 256 256 257 257 static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
+2
include/linux/mtd/partitions.h
··· 47 47 #define MTDPART_SIZ_FULL (0) 48 48 49 49 50 + struct mtd_info; 51 + 50 52 int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); 51 53 int del_mtd_partitions(struct mtd_info *); 52 54