Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nand: update the documentation to reflect framework changes

The MTD device is now directly embedded in the nand_chip struct. Update the
mtdnand documentation to mention this aspect and fix the different
examples.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Boris BREZILLON and committed by
Brian Norris
3eb064e4 960823a2

+15 -16
+15 -16
Documentation/DocBook/mtdnand.tmpl
··· 162 162 <sect1 id="Basic_defines"> 163 163 <title>Basic defines</title> 164 164 <para> 165 - At least you have to provide a mtd structure and 166 - a storage for the ioremap'ed chip address. 167 - You can allocate the mtd structure using kmalloc 168 - or you can allocate it statically. 169 - In case of static allocation you have to allocate 170 - a nand_chip structure too. 165 + At least you have to provide a nand_chip structure 166 + and a storage for the ioremap'ed chip address. 167 + You can allocate the nand_chip structure using 168 + kmalloc or you can allocate it statically. 169 + The NAND chip structure embeds an mtd structure 170 + which will be registered to the MTD subsystem. 171 + You can extract a pointer to the mtd structure 172 + from a nand_chip pointer using the nand_to_mtd() 173 + helper. 171 174 </para> 172 175 <para> 173 176 Kmalloc based example ··· 183 180 Static example 184 181 </para> 185 182 <programlisting> 186 - static struct mtd_info board_mtd; 187 183 static struct nand_chip board_chip; 188 184 static void __iomem *baseaddr; 189 185 </programlisting> ··· 276 274 int err = 0; 277 275 278 276 /* Allocate memory for MTD device structure and private data */ 279 - board_mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); 280 - if (!board_mtd) { 277 + this = kzalloc(sizeof(struct nand_chip), GFP_KERNEL); 278 + if (!this) { 281 279 printk ("Unable to allocate NAND MTD device structure.\n"); 282 280 err = -ENOMEM; 283 281 goto out; 284 282 } 283 + 284 + board_mtd = nand_to_mtd(this); 285 285 286 286 /* map physical address */ 287 287 baseaddr = ioremap(CHIP_PHYSICAL_ADDRESS, 1024); ··· 292 288 err = -EIO; 293 289 goto out_mtd; 294 290 } 295 - 296 - /* Get pointer to private data */ 297 - this = (struct nand_chip *) (); 298 - /* Link the private data with the MTD structure */ 299 - board_mtd->priv = this; 300 291 301 292 /* Set address of NAND IO lines */ 302 293 this->IO_ADDR_R = baseaddr; ··· 316 317 out_ior: 317 318 iounmap(baseaddr); 318 319 out_mtd: 319 - kfree (board_mtd); 320 + kfree (this); 320 321 out: 321 322 return err; 322 323 } ··· 342 343 iounmap(baseaddr); 343 344 344 345 /* Free the MTD device structure */ 345 - kfree (board_mtd); 346 + kfree (mtd_to_nand(board_mtd)); 346 347 } 347 348 module_exit(board_cleanup); 348 349 #endif