天嵌 ARM开发社区

 找回密码
 注册
查看: 2701|回复: 3

nandflash 初始化 问题?

[复制链接]
guobinname_301 发表于 2012-10-30 21:08:17 | 显示全部楼层 |阅读模式
在 nandflash初始化函数中
int nand_scan (struct mtd_info *mtd, int maxchips)
{
        int i, j, nand_maf_id, nand_dev_id, busw;
        struct nand_chip *this = mtd->priv;  /* 取出struct nand_chip 结构*/

        /* Get buswidth to select the correct functions*/
        busw = this->options & NAND_BUSWIDTH_16;

        /* check for proper chip_delay setup, set 20us if not */
        if (!this->chip_delay)
                this->chip_delay = 20;

        /* check, if a user supplied command function given */
        if (this->cmdfunc == NULL)
                this->cmdfunc = nand_command;
这里面有一句if (!this->chip_delay)
this->chip_delay = 20;
chip_delay 成员在这个结构中定义struct nand_chip {
.....
.....
int   chip_delay;
.....
}
问题:if (!this->chip_delay)
this->chip_delay = 20;
这个判断语句应该是this指向的chip_delay的值为空或为0 的情况下this->chip_delay = 20。
那程序是如何判断以下成员的值是否为0或为空????
struct nand_chip {
        void  __iomem        *IO_ADDR_R;
        void  __iomem        *IO_ADDR_W;

        u_char                (*read_byte)(struct mtd_info *mtd);
        void                (*write_byte)(struct mtd_info *mtd, u_char byte);
        u16                (*read_word)(struct mtd_info *mtd);
        void                (*write_word)(struct mtd_info *mtd, u16 word);

        void                (*write_buf)(struct mtd_info *mtd, const u_char *buf, int len);
        void                (*read_buf)(struct mtd_info *mtd, u_char *buf, int len);
        int                (*verify_buf)(struct mtd_info *mtd, const u_char *buf, int len);
        void                (*select_chip)(struct mtd_info *mtd, int chip);
        int                (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip);
        int                (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
        void                (*hwcontrol)(struct mtd_info *mtd, int cmd);
        int                (*dev_ready)(struct mtd_info *mtd);
        void                (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr);
        int                (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state);
        int                (*calculate_ecc)(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
        int                (*correct_data)(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
        void                (*enable_hwecc)(struct mtd_info *mtd, int mode);
        void                (*erase_cmd)(struct mtd_info *mtd, int page);
        int                (*scan_bbt)(struct mtd_info *mtd);
        int                eccmode;
        int                eccsize;
        int                eccbytes;
        int                eccsteps;
        int                chip_delay;
#if 0
        spinlock_t        chip_lock;
        wait_queue_head_t wq;
        nand_state_t        state;
#endif
        int                page_shift;
        int                phys_erase_shift;
        int                bbt_erase_shift;
        int                chip_shift;
        u_char                *data_buf;
        u_char                *oob_buf;
        int                oobdirty;
        u_char                *data_poi;
        unsigned int        options;
        int                badblockpos;
        int                numchips;
        unsigned long        chipsize;
        int                pagemask;
        int                pagebuf;
        struct nand_oobinfo        *autooob;
        uint8_t                *bbt;
        struct nand_bbt_descr        *bbt_td;
        struct nand_bbt_descr        *bbt_md;
        struct nand_bbt_descr        *badblock_pattern;
        struct nand_hw_control        *controller;
        void                *priv;
};
embedsky_lhh 发表于 2012-10-31 09:16:23 | 显示全部楼层
没看明白网友的问题意思是啥了?
回复

使用道具 举报

 楼主| guobinname_301 发表于 2012-10-31 13:15:36 | 显示全部楼层
embedsky_lhh 发表于 2012-10-31 09:16
没看明白网友的问题意思是啥了?

就是问如果定义了一个结构体,那结构体成员的初始值在默认的情况下是NULL还是0,或者是系统残留值?
是否还存在全局,静态的区别?????
回复

使用道具 举报

embedsky_lhh 发表于 2012-10-31 14:58:56 | 显示全部楼层
guobinname_301 发表于 2012-10-31 13:15
就是问如果定义了一个结构体,那结构体成员的初始值在默认的情况下是NULL还是0,或者是系统残留值?
是否 ...

一般如果没有初始化编译器都初始化为0,这情况不一样,这个是形参是外面传进来的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2025-6-16 18:36 , Processed in 2.041339 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表