Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252507
b: refs/heads/master
c: f5671ab
h: refs/heads/master
i:
  252505: d1c8b16
  252503: 3633917
v: v3
  • Loading branch information
Jamie Iles authored and David Woodhouse committed May 25, 2011
1 parent 6567c02 commit c04d377
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5fcb033159bc4f66782f13fa1e7f981f41a951ef
refs/heads/master: f5671ab3f67a10f7234de21464391c20c1ef8ebb
45 changes: 45 additions & 0 deletions trunk/drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <linux/gfp.h>

#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>

#include "mtdcore.h"
/*
Expand Down Expand Up @@ -427,6 +428,50 @@ int del_mtd_device (struct mtd_info *mtd)
return ret;
}

/**
* mtd_device_register - register an MTD device.
*
* @master: the MTD device to register
* @parts: the partitions to register - only valid if nr_parts > 0
* @nr_parts: the number of partitions in parts. If zero then the full MTD
* device is registered
*
* Register an MTD device with the system and optionally, a number of
* partitions. If nr_parts is 0 then the whole device is registered, otherwise
* only the partitions are registered. To register both the full device *and*
* the partitions, call mtd_device_register() twice, once with nr_parts == 0
* and once equal to the number of partitions.
*/
int mtd_device_register(struct mtd_info *master,
const struct mtd_partition *parts,
int nr_parts)
{
return parts ? add_mtd_partitions(master, parts, nr_parts) :
add_mtd_device(master);
}
EXPORT_SYMBOL_GPL(mtd_device_register);

/**
* mtd_device_unregister - unregister an existing MTD device.
*
* @master: the MTD device to unregister. This will unregister both the master
* and any partitions if registered.
*/
int mtd_device_unregister(struct mtd_info *master)
{
int err;

err = del_mtd_partitions(master);
if (err)
return err;

if (!device_is_registered(&master->dev))
return 0;

return del_mtd_device(master);
}
EXPORT_SYMBOL_GPL(mtd_device_unregister);

/**
* register_mtd_user - register a 'user' of MTD devices.
* @new: pointer to notifier info structure
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ static inline uint32_t mtd_mod_by_ws(uint64_t sz, struct mtd_info *mtd)
extern int add_mtd_device(struct mtd_info *mtd);
extern int del_mtd_device (struct mtd_info *mtd);

struct mtd_partition;

extern int mtd_device_register(struct mtd_info *master,
const struct mtd_partition *parts,
int nr_parts);
extern int mtd_device_unregister(struct mtd_info *master);
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
extern int __get_mtd_device(struct mtd_info *mtd);
extern void __put_mtd_device(struct mtd_info *mtd);
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/mtd/partitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Partition definition structure:
*
* An array of struct partition is passed along with a MTD object to
* add_mtd_partitions() to create them.
* mtd_device_register() to create them.
*
* For each partition, these fields are available:
* name: string that will be used to label the partition's MTD device.
Expand Down

0 comments on commit c04d377

Please sign in to comment.