[U-Boot] [PATCH] MTD: Cleanup jffs2/mtdpart headers

This patch moves some MTD related defines and prototypes from a jffs2 header to an MTD header. This makes it possible to remove this jffs2 header inclusion from some files without jffs2 relevance.
Signed-off-by: Stefan Roese sr@denx.de Cc: Alexander Stein alexander.stein@systec-electronic.com --- board/sixnet/sixnet.c | 1 - common/cmd_flash.c | 11 +--------- common/cmd_jffs2.c | 2 +- common/cmd_nand.c | 10 --------- drivers/mtd/nand/nand_base.c | 4 --- include/jffs2/jffs2.h | 1 + include/jffs2/load_kernel.h | 43 ----------------------------------------- include/linux/mtd/mtd.h | 44 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 47 insertions(+), 69 deletions(-)
diff --git a/board/sixnet/sixnet.c b/board/sixnet/sixnet.c index edb5d13..b30c01b 100644 --- a/board/sixnet/sixnet.c +++ b/board/sixnet/sixnet.c @@ -24,7 +24,6 @@
#include <common.h> #include <config.h> -#include <jffs2/jffs2.h> #include <mpc8xx.h> #include <net.h> /* for eth_init() */ #include <rtc.h> diff --git a/common/cmd_flash.c b/common/cmd_flash.c index 3e6bab2..abb4a57 100644 --- a/common/cmd_flash.c +++ b/common/cmd_flash.c @@ -26,21 +26,12 @@ */ #include <common.h> #include <command.h> +#include <linux/mtd/mtd.h>
#ifdef CONFIG_HAS_DATAFLASH #include <dataflash.h> #endif
-#if defined(CONFIG_CMD_MTDPARTS) -#include <jffs2/jffs2.h> - -/* partition handling routines */ -int mtdparts_init(void); -int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num); -int find_dev_and_part(const char *id, struct mtd_device **dev, - u8 *part_num, struct part_info **part); -#endif - #ifndef CONFIG_SYS_NO_FLASH extern flash_info_t flash_info[]; /* info for FLASH chips */
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index 0e7a6b0..b599cc7 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -215,7 +215,7 @@ static int mtd_device_validate(u8 type, u8 num, u32 *size) * @param dev_num parsed device number (output) * @return 0 on success, 1 otherwise */ -static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num) +int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num) { const char *p = id;
diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 3f1d077..7e861f6 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -18,18 +18,8 @@ #include <watchdog.h> #include <malloc.h> #include <asm/byteorder.h> -#include <jffs2/jffs2.h> #include <nand.h>
-#if defined(CONFIG_CMD_MTDPARTS) - -/* partition handling routines */ -int mtdparts_init(void); -int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num); -int find_dev_and_part(const char *id, struct mtd_device **dev, - u8 *part_num, struct part_info **part); -#endif - static int nand_dump(nand_info_t *nand, ulong off, int only_oob) { int i; diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ed1c9c9..d60059c 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -75,10 +75,6 @@ #include <asm/io.h> #include <asm/errno.h>
-#ifdef CONFIG_JFFS2_NAND -#include <jffs2/jffs2.h> -#endif - /* * CONFIG_SYS_NAND_RESET_CNT is used as a timeout mechanism when resetting * a flash. NAND flash is initialized prior to interrupts so standard timers diff --git a/include/jffs2/jffs2.h b/include/jffs2/jffs2.h index 651f94c..1a7b50e 100644 --- a/include/jffs2/jffs2.h +++ b/include/jffs2/jffs2.h @@ -39,6 +39,7 @@ #define __LINUX_JFFS2_H__
#include <asm/types.h> +#include <linux/mtd/mtd.h> #include <jffs2/load_kernel.h>
#define JFFS2_SUPER_MAGIC 0x72b6 diff --git a/include/jffs2/load_kernel.h b/include/jffs2/load_kernel.h index 906eb3d..ccae2f1 100644 --- a/include/jffs2/load_kernel.h +++ b/include/jffs2/load_kernel.h @@ -25,43 +25,6 @@ * */
-#include <linux/list.h> - -/* mtd device types */ -#define MTD_DEV_TYPE_NOR 0x0001 -#define MTD_DEV_TYPE_NAND 0x0002 -#define MTD_DEV_TYPE_ONENAND 0x0004 - -#define MTD_DEV_TYPE(type) ((type == MTD_DEV_TYPE_NAND) ? "nand" : \ - (type == MTD_DEV_TYPE_ONENAND) ? "onenand" : "nor") - -struct mtd_device { - struct list_head link; - struct mtdids *id; /* parent mtd id entry */ - u16 num_parts; /* number of partitions on this device */ - struct list_head parts; /* partitions */ -}; - -struct part_info { - struct list_head link; - char *name; /* partition name */ - u8 auto_name; /* set to 1 for generated name */ - u32 size; /* total size of the partition */ - u32 offset; /* offset within device */ - void *jffs2_priv; /* used internaly by jffs2 */ - u32 mask_flags; /* kernel MTD mask flags */ - u32 sector_size; /* size of sector */ - struct mtd_device *dev; /* parent device */ -}; - -struct mtdids { - struct list_head link; - u8 type; /* device type */ - u8 num; /* device number */ - u32 size; /* device size */ - char *mtd_id; /* linux kernel device id */ -}; - #define ldr_strlen strlen #define ldr_strncmp strncmp #define ldr_memcpy memcpy @@ -74,10 +37,4 @@ struct mtdids { #define putLabeledWord(x, y) printf("%s %08x\n", x, (unsigned int)y) #define led_blink(x, y, z, a)
-/* common/cmd_jffs2.c */ -extern int mtdparts_init(void); -extern int find_dev_and_part(const char *id, struct mtd_device **dev, - u8 *part_num, struct part_info **part); -extern struct mtd_device *device_find(u8 type, u8 num); - #endif /* load_kernel_h */ diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 16556c4..c65f18d 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -9,6 +9,7 @@
#include <linux/types.h> #include <div64.h> +#include <linux/list.h> #include <linux/mtd/mtd-abi.h>
#define MTD_CHAR_MAJOR 90 @@ -23,6 +24,41 @@
#define MTD_FAIL_ADDR_UNKNOWN -1LL
+/* U-Boot mtd device types */ +#define MTD_DEV_TYPE_NOR 0x0001 +#define MTD_DEV_TYPE_NAND 0x0002 +#define MTD_DEV_TYPE_ONENAND 0x0004 + +#define MTD_DEV_TYPE(type) ((type == MTD_DEV_TYPE_NAND) ? "nand" : \ + (type == MTD_DEV_TYPE_ONENAND) ? "onenand" : "nor") + +struct mtd_device { + struct list_head link; + struct mtdids *id; /* parent mtd id entry */ + u16 num_parts; /* number of partitions on this device */ + struct list_head parts; /* partitions */ +}; + +struct part_info { + struct list_head link; + char *name; /* partition name */ + u8 auto_name; /* set to 1 for generated name */ + u32 size; /* total size of the partition */ + u32 offset; /* offset within device */ + void *jffs2_priv; /* used internaly by jffs2 */ + u32 mask_flags; /* kernel MTD mask flags */ + u32 sector_size; /* size of sector */ + struct mtd_device *dev; /* parent device */ +}; + +struct mtdids { + struct list_head link; + u8 type; /* device type */ + u8 num; /* device number */ + u32 size; /* device size */ + char *mtd_id; /* linux kernel device id */ +}; + /* * Enumeration for NAND/OneNAND flash chip state */ @@ -260,6 +296,14 @@ extern struct mtd_info *get_mtd_device_nm(const char *name);
extern void put_mtd_device(struct mtd_info *mtd);
+/* U-Boot mtdparts stuff */ +extern int mtdparts_init(void); +extern int find_dev_and_part(const char *id, struct mtd_device **dev, + u8 *part_num, struct part_info **part); +extern struct mtd_device *device_find(u8 type, u8 num); +extern int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, + u8 *dev_num); + /* XXX U-BOOT XXX */ #if 0 struct mtd_notifier {

On 2010/08/12 1:43 PM, Stefan Roese wrote:
This patch moves some MTD related defines and prototypes from a jffs2 header to an MTD header. This makes it possible to remove this jffs2 header inclusion from some files without jffs2 relevance.
Signed-off-by: Stefan Roesesr@denx.de Cc: Alexander Steinalexander.stein@systec-electronic.com
Just two comments.
+struct part_info {
- struct list_head link;
- char *name; /* partition name */
- u8 auto_name; /* set to 1 for generated name */
- u32 size; /* total size of the partition */
- u32 offset; /* offset within device */
- void *jffs2_priv; /* used internaly by jffs2 */
Should this really be in here? Seems we are mixing things up still.
/* XXX U-BOOT XXX */ #if 0 struct mtd_notifier {
What's up with "#if 0" code in the src?
Rogan
participants (2)
-
Rogan Dawes
-
Stefan Roese