diff options
author | Jamie Iles <jamie@jamieiles.com> | 2011-05-23 12:15:46 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2011-05-24 21:12:36 -0400 |
commit | f5671ab3f67a10f7234de21464391c20c1ef8ebb (patch) | |
tree | d0de1f3605c3c9c784446dda167aad1fd4301d6a /drivers/mtd/mtdcore.c | |
parent | 5fcb033159bc4f66782f13fa1e7f981f41a951ef (diff) |
mtd: introduce mtd_device_(un)register()
To prepare for the removal of add_mtd_device and add_mtd_partitions(),
introduce mtd_device_register(). This will create partitions if they
are supplied or register the whole device if there are no partitions.
Once all drivers are converted to use mtd_device_register(),
add_mtd_device() and add_mtd_partitions() will be made internal only.
v2: move kerneldoc to implementation file and fixup some kerneldoc
warnings.
Artem: tweak comments: remove junk tabs, use dots consistently.
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>
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r-- | drivers/mtd/mtdcore.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index f3c94006ffe6..9af103bf9218 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/gfp.h> | 38 | #include <linux/gfp.h> |
39 | 39 | ||
40 | #include <linux/mtd/mtd.h> | 40 | #include <linux/mtd/mtd.h> |
41 | #include <linux/mtd/partitions.h> | ||
41 | 42 | ||
42 | #include "mtdcore.h" | 43 | #include "mtdcore.h" |
43 | /* | 44 | /* |
@@ -428,6 +429,50 @@ out_error: | |||
428 | } | 429 | } |
429 | 430 | ||
430 | /** | 431 | /** |
432 | * mtd_device_register - register an MTD device. | ||
433 | * | ||
434 | * @master: the MTD device to register | ||
435 | * @parts: the partitions to register - only valid if nr_parts > 0 | ||
436 | * @nr_parts: the number of partitions in parts. If zero then the full MTD | ||
437 | * device is registered | ||
438 | * | ||
439 | * Register an MTD device with the system and optionally, a number of | ||
440 | * partitions. If nr_parts is 0 then the whole device is registered, otherwise | ||
441 | * only the partitions are registered. To register both the full device *and* | ||
442 | * the partitions, call mtd_device_register() twice, once with nr_parts == 0 | ||
443 | * and once equal to the number of partitions. | ||
444 | */ | ||
445 | int mtd_device_register(struct mtd_info *master, | ||
446 | const struct mtd_partition *parts, | ||
447 | int nr_parts) | ||
448 | { | ||
449 | return parts ? add_mtd_partitions(master, parts, nr_parts) : | ||
450 | add_mtd_device(master); | ||
451 | } | ||
452 | EXPORT_SYMBOL_GPL(mtd_device_register); | ||
453 | |||
454 | /** | ||
455 | * mtd_device_unregister - unregister an existing MTD device. | ||
456 | * | ||
457 | * @master: the MTD device to unregister. This will unregister both the master | ||
458 | * and any partitions if registered. | ||
459 | */ | ||
460 | int mtd_device_unregister(struct mtd_info *master) | ||
461 | { | ||
462 | int err; | ||
463 | |||
464 | err = del_mtd_partitions(master); | ||
465 | if (err) | ||
466 | return err; | ||
467 | |||
468 | if (!device_is_registered(&master->dev)) | ||
469 | return 0; | ||
470 | |||
471 | return del_mtd_device(master); | ||
472 | } | ||
473 | EXPORT_SYMBOL_GPL(mtd_device_unregister); | ||
474 | |||
475 | /** | ||
431 | * register_mtd_user - register a 'user' of MTD devices. | 476 | * register_mtd_user - register a 'user' of MTD devices. |
432 | * @new: pointer to notifier info structure | 477 | * @new: pointer to notifier info structure |
433 | * | 478 | * |