aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-02-08 09:37:14 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:32:29 -0400
commitde3cac9357b5aa9f9f02520e5f2567b06f3f75a7 (patch)
tree4775c9b137c10bdd9b9ed51651e8ff281987f727 /include/linux/mtd
parentbcb1d238716d138c9e16347fc32b3c1ae006339e (diff)
mtd: check for zero length in OTP functions
This patch changes all the OTP functions like 'mtd_get_fact_prot_info()' and makes them return zero immediately if the input 'len' parameter is 0. This is not really needed currently, but most of the other functions do this, and it is just consistent to do the same in the OTP functions. This patch also moves the OTP functions from the header file to mtdcore.c because they become a bit too big for being inlined. 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.h70
1 files changed, 11 insertions, 59 deletions
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index fa20a8f0463a..726c2d1b2589 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -273,65 +273,17 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
273 return mtd->_write_oob(mtd, to, ops); 273 return mtd->_write_oob(mtd, to, ops);
274} 274}
275 275
276/* 276int mtd_get_fact_prot_info(struct mtd_info *mtd, struct otp_info *buf,
277 * Method to access the protection register area, present in some flash 277 size_t len);
278 * devices. The user data is one time programmable but the factory data is read 278int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
279 * only. 279 size_t *retlen, u_char *buf);
280 */ 280int mtd_get_user_prot_info(struct mtd_info *mtd, struct otp_info *buf,
281static inline int mtd_get_fact_prot_info(struct mtd_info *mtd, 281 size_t len);
282 struct otp_info *buf, size_t len) 282int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len,
283{ 283 size_t *retlen, u_char *buf);
284 if (!mtd->_get_fact_prot_info) 284int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to, size_t len,
285 return -EOPNOTSUPP; 285 size_t *retlen, u_char *buf);
286 return mtd->_get_fact_prot_info(mtd, buf, len); 286int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, size_t len);
287}
288
289static inline int mtd_read_fact_prot_reg(struct mtd_info *mtd, loff_t from,
290 size_t len, size_t *retlen,
291 u_char *buf)
292{
293 *retlen = 0;
294 if (!mtd->_read_fact_prot_reg)
295 return -EOPNOTSUPP;
296 return mtd->_read_fact_prot_reg(mtd, from, len, retlen, buf);
297}
298
299static inline int mtd_get_user_prot_info(struct mtd_info *mtd,
300 struct otp_info *buf,
301 size_t len)
302{
303 if (!mtd->_get_user_prot_info)
304 return -EOPNOTSUPP;
305 return mtd->_get_user_prot_info(mtd, buf, len);
306}
307
308static inline int mtd_read_user_prot_reg(struct mtd_info *mtd, loff_t from,
309 size_t len, size_t *retlen,
310 u_char *buf)
311{
312 *retlen = 0;
313 if (!mtd->_read_user_prot_reg)
314 return -EOPNOTSUPP;
315 return mtd->_read_user_prot_reg(mtd, from, len, retlen, buf);
316}
317
318static inline int mtd_write_user_prot_reg(struct mtd_info *mtd, loff_t to,
319 size_t len, size_t *retlen,
320 u_char *buf)
321{
322 *retlen = 0;
323 if (!mtd->_write_user_prot_reg)
324 return -EOPNOTSUPP;
325 return mtd->_write_user_prot_reg(mtd, to, len, retlen, buf);
326}
327
328static inline int mtd_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
329 size_t len)
330{
331 if (!mtd->_lock_user_prot_reg)
332 return -EOPNOTSUPP;
333 return mtd->_lock_user_prot_reg(mtd, from, len);
334}
335 287
336int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, 288int mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
337 unsigned long count, loff_t to, size_t *retlen); 289 unsigned long count, loff_t to, size_t *retlen);