aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2011-12-23 08:25:39 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-01-09 13:25:11 -0500
commit7e1f0dc0551b99acb5e8fa161a7ac401994d57d8 (patch)
tree19108039bb082d42fbda40d4bd3ddb11a1185cd1 /include/linux/mtd
parent969e57adc2589a0a0ae5edbbe7b92062565ce70b (diff)
mtd: introduce mtd_erase interface
This patch is part of a patch-set which changes the MTD interface from 'mtd->func()' form to 'mtd_func()' form. We need this because we want to add common code to to all drivers in the mtd core level, which is impossible with the current interface when MTD clients call driver functions like 'read()' or 'write()' directly. At this point we just introduce a new inline wrapper function, but later some of them are expected to gain more code. E.g., the input parameters check should be moved to the wrappers rather than be duplicated at many drivers. This particular patch introduced the 'mtd_erase()' interface. The following patches add all the other interfaces one by one. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include/linux/mtd')
-rw-r--r--include/linux/mtd/mtd.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 9f5b312af783..201bad557047 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -171,11 +171,8 @@ struct mtd_info {
171 struct mtd_erase_region_info *eraseregions; 171 struct mtd_erase_region_info *eraseregions;
172 172
173 /* 173 /*
174 * Erase is an asynchronous operation. Device drivers are supposed 174 * Do not call via these pointers, use corresponding mtd_*()
175 * to call instr->callback() whenever the operation completes, even 175 * wrappers instead.
176 * if it completes with a failure.
177 * Callers are supposed to pass a callback function and wait for it
178 * to be called before writing to the block.
179 */ 176 */
180 int (*erase) (struct mtd_info *mtd, struct erase_info *instr); 177 int (*erase) (struct mtd_info *mtd, struct erase_info *instr);
181 178
@@ -274,6 +271,18 @@ struct mtd_info {
274 void (*put_device) (struct mtd_info *mtd); 271 void (*put_device) (struct mtd_info *mtd);
275}; 272};
276 273
274/*
275 * Erase is an asynchronous operation. Device drivers are supposed
276 * to call instr->callback() whenever the operation completes, even
277 * if it completes with a failure.
278 * Callers are supposed to pass a callback function and wait for it
279 * to be called before writing to the block.
280 */
281static inline int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
282{
283 return mtd->erase(mtd, instr);
284}
285
277static inline struct mtd_info *dev_to_mtd(struct device *dev) 286static inline struct mtd_info *dev_to_mtd(struct device *dev)
278{ 287{
279 return dev ? dev_get_drvdata(dev) : NULL; 288 return dev ? dev_get_drvdata(dev) : NULL;