aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mtd/mtd.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/mtd/mtd.h')
-rw-r--r--include/linux/mtd/mtd.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 3aa5d77c2cdb..5675b63a0631 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -11,6 +11,7 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/uio.h> 12#include <linux/uio.h>
13#include <linux/notifier.h> 13#include <linux/notifier.h>
14#include <linux/device.h>
14 15
15#include <linux/mtd/compatmac.h> 16#include <linux/mtd/compatmac.h>
16#include <mtd/mtd-abi.h> 17#include <mtd/mtd-abi.h>
@@ -162,6 +163,20 @@ struct mtd_info {
162 /* We probably shouldn't allow XIP if the unpoint isn't a NULL */ 163 /* We probably shouldn't allow XIP if the unpoint isn't a NULL */
163 void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len); 164 void (*unpoint) (struct mtd_info *mtd, loff_t from, size_t len);
164 165
166 /* Allow NOMMU mmap() to directly map the device (if not NULL)
167 * - return the address to which the offset maps
168 * - return -ENOSYS to indicate refusal to do the mapping
169 */
170 unsigned long (*get_unmapped_area) (struct mtd_info *mtd,
171 unsigned long len,
172 unsigned long offset,
173 unsigned long flags);
174
175 /* Backing device capabilities for this device
176 * - provides mmap capabilities
177 */
178 struct backing_dev_info *backing_dev_info;
179
165 180
166 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); 181 int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
167 int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); 182 int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
@@ -223,6 +238,7 @@ struct mtd_info {
223 void *priv; 238 void *priv;
224 239
225 struct module *owner; 240 struct module *owner;
241 struct device dev;
226 int usecount; 242 int usecount;
227 243
228 /* If the driver is something smart, like UBI, it may need to maintain 244 /* If the driver is something smart, like UBI, it may need to maintain
@@ -233,6 +249,11 @@ struct mtd_info {
233 void (*put_device) (struct mtd_info *mtd); 249 void (*put_device) (struct mtd_info *mtd);
234}; 250};
235 251
252static inline struct mtd_info *dev_to_mtd(struct device *dev)
253{
254 return dev ? container_of(dev, struct mtd_info, dev) : NULL;
255}
256
236static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) 257static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
237{ 258{
238 if (mtd->erasesize_shift) 259 if (mtd->erasesize_shift)