From: "stanley.miao" <stanley.miao@windriver.com>
To: Joakim Tjernlund <joakim.tjernlund@transmode.se>
Cc: Artem.Bityutskiy@nokia.com, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 2/3] Discard the legacy interface MEMGETOOBSEL in flash_eraseall
Date: Fri, 11 Jun 2010 18:36:08 +0800 [thread overview]
Message-ID: <4C121198.5030807@windriver.com> (raw)
In-Reply-To: <OF17604B8E.95B0C75E-ONC125773F.00361B51-C125773F.00365BD5@transmode.se>
Joakim Tjernlund wrote:
> Joakim Tjernlund/Transmode wrote on 2010/06/11 11:44:27:
>
>>> The "struct nand_oobinfo" is able to record only 32 ECC code positions,which
>>> is not enough for many big NAND chips. Therefore, this structure is replaced
>>> by "struct nand_ecclayout" in linux kernel from the version 2.6.17.
>>> Consequently, the ioctl command changed from MEMGETOOBSEL to ECCGETLAYOUT.
>>>
>>> Now update flash_eraseall to use the new ioctl command ECCGETLAYOUT. In order
>>> to keep compatible with the old linux kernel, a linux version detection
>>> function is added.
>>>
>>> Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
>>> ---
>>> flash_eraseall.c | 71 ++++++++++++++++++++++++++++++++----------------------
>>> 1 files changed, 42 insertions(+), 29 deletions(-)
>>>
>>> diff --git a/flash_eraseall.c b/flash_eraseall.c
>>> index a22fc49..4e2108b 100644
>>> --- a/flash_eraseall.c
>>> +++ b/flash_eraseall.c
>>> @@ -43,6 +43,8 @@
>>> #define PROGRAM "flash_eraseall"
>>> #define VERSION "$Revision: 1.22 $"
>>>
>>> +#define LINUX_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
>>> +
>>> static const char *exe_name;
>>> static const char *mtd_device;
>>> static int quiet; /* true -- don't output progress */
>>> @@ -55,6 +57,21 @@ static void display_version (void);
>>> static struct jffs2_unknown_node cleanmarker;
>>> int target_endian = __BYTE_ORDER;
>>>
>>> +static int get_linux_version(void)
>>> +{
>>> + FILE *fd;
>>> + int a = 0, b = 0, c = 0;
>>> +
>>> + fd = fopen("/proc/version", "r");
>>> + if (fd) {
>>> + fscanf(fd, "Linux version %d.%d.%d", &a, &b, &c);
>>> + fclose(fd);
>>> + }
>>> +
>>> + return LINUX_VERSION(a, b, c);
>>> +}
>>> +
>>> +
>>>
>> The fopen could fail and if it does, I think you should default to "assume
>> latest kernel"
>> Same goes for fscanf, you should at least test the return value.
>>
I am not sure what kernel version the proc file "version" began to exist.
If the fopen failed, it must be a old kernel, so I set the default to
the old kernel.
It is the same with the current mtd-utils.
>
> Forgot, use uname(2) instead of /proc/version
>
Why ?
> Does the above scanf work on "2.6.31-gentoo-r6"?
>
I didn't do the test on all the platforms. Is there any reason that
cause it not to work ?
Thanks
Stanley.
> Jocke
>
>
>
next prev parent reply other threads:[~2010-06-11 10:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-11 9:36 Fix mtd-utils bugs Stanley.Miao
2010-06-11 9:36 ` [PATCH 1/3] clean up the legacy interfaces in nandwrite.c Stanley.Miao
2010-06-11 9:36 ` [PATCH 2/3] Discard the legacy interface MEMGETOOBSEL in flash_eraseall Stanley.Miao
2010-06-11 9:36 ` [PATCH 3/3] Place the cleanmarker in OOB area according to the mode MTD_OOB_AUTO Stanley.Miao
2010-06-11 9:44 ` [PATCH 2/3] Discard the legacy interface MEMGETOOBSEL in flash_eraseall Joakim Tjernlund
[not found] ` <OFDBEF7A42.BA0205E8-ONC125773F.0034F62C-C125773F.00358229@LocalDomain>
2010-06-11 9:53 ` Joakim Tjernlund
2010-06-11 10:36 ` stanley.miao [this message]
2010-06-11 10:44 ` Joakim Tjernlund
2010-06-11 12:11 ` Joakim Tjernlund
2010-06-13 9:51 ` Fix mtd-utils bugs Artem Bityutskiy
2010-06-13 10:14 ` Artem Bityutskiy
2010-06-17 4:10 ` stanley.miao
2010-06-18 8:16 ` stanley.miao
2010-06-18 10:24 ` Artem Bityutskiy
2010-06-20 12:21 ` stanley.miao
-- strict thread matches above, loose matches on Subject: below --
2010-06-10 9:09 The "struct nand_oobinfo" is able to record only 32 ECC code positions, which Stanley.Miao
2010-06-10 9:09 ` [PATCH 1/3] clean up the legacy interfaces in nandwrite.c Stanley.Miao
2010-06-10 9:09 ` [PATCH 2/3] Discard the legacy interface MEMGETOOBSEL in flash_eraseall Stanley.Miao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C121198.5030807@windriver.com \
--to=stanley.miao@windriver.com \
--cc=Artem.Bityutskiy@nokia.com \
--cc=joakim.tjernlund@transmode.se \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.