Skip to content

Commit

Permalink
mtd: convert remaining users to mtd_device_register()
Browse files Browse the repository at this point in the history
The older add_mtd_device()/add_mtd_partitions() and their removal
counterparts will soon be gone.  Replace uses with mtd_device_register()
and mtd_device_unregister().

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Jamie Iles authored and David Woodhouse committed May 25, 2011
1 parent 6b57c11 commit ee0e87b
Show file tree
Hide file tree
Showing 60 changed files with 160 additions and 150 deletions.
4 changes: 2 additions & 2 deletions drivers/mtd/devices/block2mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
dev->mtd.priv = dev;
dev->mtd.owner = THIS_MODULE;

if (add_mtd_device(&dev->mtd)) {
if (mtd_device_register(&dev->mtd, NULL, 0)) {
/* Device didn't get added, so free the entry */
goto devinit_err;
}
Expand Down Expand Up @@ -465,7 +465,7 @@ static void __devexit block2mtd_exit(void)
list_for_each_safe(pos, next, &blkmtd_device_list) {
struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list);
block2mtd_sync(&dev->mtd);
del_mtd_device(&dev->mtd);
mtd_device_unregister(&dev->mtd);
INFO("mtd%d: [%s] removed", dev->mtd.index,
dev->mtd.name + strlen("block2mtd: "));
list_del(&dev->list);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/doc2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void DoC2k_init(struct mtd_info *mtd)
doc2klist = mtd;
mtd->size = this->totlen;
mtd->erasesize = this->erasesize;
add_mtd_device(mtd);
mtd_device_register(mtd, NULL, 0);
return;
}
}
Expand Down Expand Up @@ -1185,7 +1185,7 @@ static void __exit cleanup_doc2000(void)
this = mtd->priv;
doc2klist = this->nextdoc;

del_mtd_device(mtd);
mtd_device_unregister(mtd);

iounmap(this->virtadr);
kfree(this->chips);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/doc2001.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void DoCMil_init(struct mtd_info *mtd)
this->nextdoc = docmillist;
docmillist = mtd;
mtd->size = this->totlen;
add_mtd_device(mtd);
mtd_device_register(mtd, NULL, 0);
return;
}
}
Expand Down Expand Up @@ -826,7 +826,7 @@ static void __exit cleanup_doc2001(void)
this = mtd->priv;
docmillist = this->nextdoc;

del_mtd_device(mtd);
mtd_device_unregister(mtd);

iounmap(this->virtadr);
kfree(this->chips);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/doc2001plus.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void DoCMilPlus_init(struct mtd_info *mtd)
docmilpluslist = mtd;
mtd->size = this->totlen;
mtd->erasesize = this->erasesize;
add_mtd_device(mtd);
mtd_device_register(mtd, NULL, 0);
return;
}
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ static void __exit cleanup_doc2001plus(void)
this = mtd->priv;
docmilpluslist = this->nextdoc;

del_mtd_device(mtd);
mtd_device_unregister(mtd);

iounmap(this->virtadr);
kfree(this->chips);
Expand Down
9 changes: 5 additions & 4 deletions drivers/mtd/devices/lart.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,10 @@ static int __init lart_flash_init (void)
#endif

#ifndef HAVE_PARTITIONS
result = add_mtd_device (&mtd);
result = mtd_device_register(&mtd, NULL, 0);
#else
result = add_mtd_partitions (&mtd,lart_partitions, ARRAY_SIZE(lart_partitions));
result = mtd_device_register(&mtd, lart_partitions,
ARRAY_SIZE(lart_partitions));
#endif

return (result);
Expand All @@ -695,9 +696,9 @@ static int __init lart_flash_init (void)
static void __exit lart_flash_exit (void)
{
#ifndef HAVE_PARTITIONS
del_mtd_device (&mtd);
mtd_device_unregister(&mtd);
#else
del_mtd_partitions (&mtd);
mtd_device_unregister(&mtd);
#endif
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/ms02-nv.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static int __init ms02nv_init_one(ulong addr)
mtd->writesize = 1;

ret = -EIO;
if (add_mtd_device(mtd)) {
if (mtd_device_register(mtd, NULL, 0)) {
printk(KERN_ERR
"ms02-nv: Unable to register MTD device, aborting!\n");
goto err_out_csr_res;
Expand Down Expand Up @@ -262,7 +262,7 @@ static void __exit ms02nv_remove_one(void)

root_ms02nv_mtd = mp->next;

del_mtd_device(mtd);
mtd_device_unregister(mtd);

release_resource(mp->resource.csr);
kfree(mp->resource.csr);
Expand Down
5 changes: 2 additions & 3 deletions drivers/mtd/devices/mtdram.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int ram_write(struct mtd_info *mtd, loff_t to, size_t len,
static void __exit cleanup_mtdram(void)
{
if (mtd_info) {
del_mtd_device(mtd_info);
mtd_device_unregister(mtd_info);
vfree(mtd_info->priv);
kfree(mtd_info);
}
Expand Down Expand Up @@ -133,9 +133,8 @@ int mtdram_init_device(struct mtd_info *mtd, void *mapped_address,
mtd->read = ram_read;
mtd->write = ram_write;

if (add_mtd_device(mtd)) {
if (mtd_device_register(mtd, NULL, 0))
return -EIO;
}

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/phram.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void unregister_devices(void)
struct phram_mtd_list *this, *safe;

list_for_each_entry_safe(this, safe, &phram_list, list) {
del_mtd_device(&this->mtd);
mtd_device_unregister(&this->mtd);
iounmap(this->mtd.priv);
kfree(this->mtd.name);
kfree(this);
Expand Down Expand Up @@ -153,7 +153,7 @@ static int register_device(char *name, unsigned long start, unsigned long len)
new->mtd.writesize = 1;

ret = -EAGAIN;
if (add_mtd_device(&new->mtd)) {
if (mtd_device_register(&new->mtd, NULL, 0)) {
pr_err("Failed to register new device\n");
goto out2;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/devices/pmc551.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,15 +798,15 @@ static int __init init_pmc551(void)
mtd->writesize = 1;
mtd->owner = THIS_MODULE;

if (add_mtd_device(mtd)) {
if (mtd_device_register(mtd, NULL, 0)) {
printk(KERN_NOTICE "pmc551: Failed to register new device\n");
pci_iounmap(PCI_Device, priv->start);
kfree(mtd->priv);
kfree(mtd);
break;
}

/* Keep a reference as the add_mtd_device worked */
/* Keep a reference as the mtd_device_register worked */
pci_dev_get(PCI_Device);

printk(KERN_NOTICE "Registered pmc551 memory device.\n");
Expand Down Expand Up @@ -856,7 +856,7 @@ static void __exit cleanup_pmc551(void)
pci_dev_put(priv->dev);

kfree(mtd->priv);
del_mtd_device(mtd);
mtd_device_unregister(mtd);
kfree(mtd);
found++;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/devices/slram.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
(*curmtd)->mtdinfo->erasesize = SLRAM_BLK_SZ;
(*curmtd)->mtdinfo->writesize = 1;

if (add_mtd_device((*curmtd)->mtdinfo)) {
if (mtd_device_register((*curmtd)->mtdinfo, NULL, 0)) {
E("slram: Failed to register new device\n");
iounmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
kfree((*curmtd)->mtdinfo->priv);
Expand All @@ -231,7 +231,7 @@ static void unregister_devices(void)

while (slram_mtdlist) {
nextitem = slram_mtdlist->next;
del_mtd_device(slram_mtdlist->mtdinfo);
mtd_device_unregister(slram_mtdlist->mtdinfo);
iounmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
kfree(slram_mtdlist->mtdinfo->priv);
kfree(slram_mtdlist->mtdinfo);
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/maps/amd76xrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void amd76xrom_cleanup(struct amd76xrom_window *window)
if (map->rsrc.parent) {
release_resource(&map->rsrc);
}
del_mtd_device(map->mtd);
mtd_device_unregister(map->mtd);
map_destroy(map->mtd);
list_del(&map->list);
kfree(map);
Expand Down Expand Up @@ -262,7 +262,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,

/* Now that the mtd devices is complete claim and export it */
map->mtd->owner = THIS_MODULE;
if (add_mtd_device(map->mtd)) {
if (mtd_device_register(map->mtd, NULL, 0)) {
map_destroy(map->mtd);
map->mtd = NULL;
goto out;
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/maps/autcpu12-nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static int __init init_autcpu12_sram (void)
sram_mtd->owner = THIS_MODULE;
sram_mtd->erasesize = 16;

if (add_mtd_device(sram_mtd)) {
if (mtd_device_register(sram_mtd, NULL, 0)) {
printk("NV-RAM device addition failed\n");
err = -ENOMEM;
goto out_probe;
Expand All @@ -111,7 +111,7 @@ static int __init init_autcpu12_sram (void)
static void __exit cleanup_autcpu12_maps(void)
{
if (sram_mtd) {
del_mtd_device(sram_mtd);
mtd_device_unregister(sram_mtd);
map_destroy(sram_mtd);
iounmap((void *)autcpu12_sram_map.virt);
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/maps/bcm963xx-flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ static int bcm963xx_probe(struct platform_device *pdev)
goto err_probe;
}

return add_mtd_partitions(bcm963xx_mtd_info, parsed_parts,
parsed_nr_parts);
return mtd_device_register(bcm963xx_mtd_info, parsed_parts,
parsed_nr_parts);

err_probe:
iounmap(bcm963xx_map.virt);
Expand All @@ -235,7 +235,7 @@ static int bcm963xx_probe(struct platform_device *pdev)
static int bcm963xx_remove(struct platform_device *pdev)
{
if (bcm963xx_mtd_info) {
del_mtd_partitions(bcm963xx_mtd_info);
mtd_device_unregister(bcm963xx_mtd_info);
map_destroy(bcm963xx_mtd_info);
}

Expand Down
12 changes: 6 additions & 6 deletions drivers/mtd/maps/cdb89712.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int __init init_cdb89712_flash (void)

flash_mtd->owner = THIS_MODULE;

if (add_mtd_device(flash_mtd)) {
if (mtd_device_register(flash_mtd, NULL, 0)) {
printk("FLASH device addition failed\n");
err = -ENOMEM;
goto out_probe;
Expand Down Expand Up @@ -141,7 +141,7 @@ static int __init init_cdb89712_sram (void)
sram_mtd->owner = THIS_MODULE;
sram_mtd->erasesize = 16;

if (add_mtd_device(sram_mtd)) {
if (mtd_device_register(sram_mtd, NULL, 0)) {
printk("SRAM device addition failed\n");
err = -ENOMEM;
goto out_probe;
Expand Down Expand Up @@ -209,7 +209,7 @@ static int __init init_cdb89712_bootrom (void)
bootrom_mtd->owner = THIS_MODULE;
bootrom_mtd->erasesize = 0x10000;

if (add_mtd_device(bootrom_mtd)) {
if (mtd_device_register(bootrom_mtd, NULL, 0)) {
printk("BootROM device addition failed\n");
err = -ENOMEM;
goto out_probe;
Expand Down Expand Up @@ -249,21 +249,21 @@ static int __init init_cdb89712_maps(void)
static void __exit cleanup_cdb89712_maps(void)
{
if (sram_mtd) {
del_mtd_device(sram_mtd);
mtd_device_unregister(sram_mtd);
map_destroy(sram_mtd);
iounmap((void *)cdb89712_sram_map.virt);
release_resource (&cdb89712_sram_resource);
}

if (flash_mtd) {
del_mtd_device(flash_mtd);
mtd_device_unregister(flash_mtd);
map_destroy(flash_mtd);
iounmap((void *)cdb89712_flash_map.virt);
release_resource (&cdb89712_flash_resource);
}

if (bootrom_mtd) {
del_mtd_device(bootrom_mtd);
mtd_device_unregister(bootrom_mtd);
map_destroy(bootrom_mtd);
iounmap((void *)cdb89712_bootrom_map.virt);
release_resource (&cdb89712_bootrom_resource);
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/maps/ceiva.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static void __exit clps_destroy_mtd(struct clps_info *clps, struct mtd_info *mtd
{
int i;

del_mtd_partitions(mtd);
mtd_device_unregister(mtd);

if (mtd != clps[0].mtd)
mtd_concat_destroy(mtd);
Expand Down Expand Up @@ -292,11 +292,11 @@ static void __init clps_locate_partitions(struct mtd_info *mtd)
if (nr_parts == 0) {
printk(KERN_NOTICE "clps flash: no partition info "
"available, registering whole flash\n");
add_mtd_device(mtd);
mtd_device_register(mtd, NULL, 0);
} else {
printk(KERN_NOTICE "clps flash: using %s partition "
"definition\n", part_type);
add_mtd_partitions(mtd, parsed_parts, nr_parts);
mtd_device_register(mtd, parsed_parts, nr_parts);
}

/* Always succeeds. */
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/maps/cfi_flagadm.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int __init init_flagadm(void)
mymtd = do_map_probe("cfi_probe", &flagadm_map);
if (mymtd) {
mymtd->owner = THIS_MODULE;
add_mtd_partitions(mymtd, flagadm_parts, PARTITION_COUNT);
mtd_device_register(mymtd, flagadm_parts, PARTITION_COUNT);
printk(KERN_NOTICE "FlagaDM flash device initialized\n");
return 0;
}
Expand All @@ -119,7 +119,7 @@ static int __init init_flagadm(void)
static void __exit cleanup_flagadm(void)
{
if (mymtd) {
del_mtd_partitions(mymtd);
mtd_device_unregister(mymtd);
map_destroy(mymtd);
}
if (flagadm_map.virt) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/maps/ck804xrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void ck804xrom_cleanup(struct ck804xrom_window *window)
if (map->rsrc.parent)
release_resource(&map->rsrc);

del_mtd_device(map->mtd);
mtd_device_unregister(map->mtd);
map_destroy(map->mtd);
list_del(&map->list);
kfree(map);
Expand Down Expand Up @@ -291,7 +291,7 @@ static int __devinit ck804xrom_init_one (struct pci_dev *pdev,

/* Now that the mtd devices is complete claim and export it */
map->mtd->owner = THIS_MODULE;
if (add_mtd_device(map->mtd)) {
if (mtd_device_register(map->mtd, NULL, 0)) {
map_destroy(map->mtd);
map->mtd = NULL;
goto out;
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/maps/dbox2-flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int __init init_dbox2_flash(void)
mymtd->owner = THIS_MODULE;

/* Create MTD devices for each partition. */
add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
mtd_device_register(mymtd, partition_info, NUM_PARTITIONS);

return 0;
}
Expand All @@ -105,7 +105,7 @@ static int __init init_dbox2_flash(void)
static void __exit cleanup_dbox2_flash(void)
{
if (mymtd) {
del_mtd_partitions(mymtd);
mtd_device_unregister(mymtd);
map_destroy(mymtd);
}
if (dbox2_flash_map.virt) {
Expand Down
Loading

0 comments on commit ee0e87b

Please sign in to comment.