From: Artem Bityutskiy <dedekind1@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: Heinz.Egger@linutronix.de, tglx@linutronix.de,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
tim.bird@am.sony.com
Subject: Re: [PATCH] [RFC] UBI: Implement Fastmap support
Date: Tue, 22 May 2012 16:43:04 +0300 [thread overview]
Message-ID: <1337694184.2483.186.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1337608916-49771-2-git-send-email-richard@nod.at>
[-- Attachment #1: Type: text/plain, Size: 2725 bytes --]
Uhh, too many helpers.
On Mon, 2012-05-21 at 16:01 +0200, Richard Weinberger wrote:
> /**
> - * ubi_attach - attach an MTD device.
> - * @ubi: UBI device descriptor
> + * scan_fastmap - attach MTD device using fastmap.
> + * @ubi: UBI device description object
> *
> - * This function returns zero in case of success and a negative error code in
> - * case of failure.
> + * This function attaches a MTD device using a fastmap and returns complete
> + * information about it in form of a "struct ubi_attach_info" object. In case
> + * of failure, an error code is returned.
> */
> -int ubi_attach(struct ubi_device *ubi)
> +static struct ubi_attach_info *scan_fastmap(struct ubi_device *ubi)
> +{
> + int fm_start;
> +
> + fm_start = ubi_find_fastmap(ubi);
> + if (fm_start < 0)
> + return ERR_PTR(-ENOENT);
> +
> + return ubi_read_fastmap(ubi, fm_start);
> +}
This helper which does not do anything useful should not exist - just
teach 'ubi_read_fastmap()' to return 1 if the fastmap is not found, and
< 0 on error, and 0 on success. No one in attach.c should be interested
in fm_start. So this helper should die. See below as well.
> +
> +static int do_attach(struct ubi_device *ubi, bool fullscan)
> {
> int err;
> struct ubi_attach_info *ai;
>
> - ai = scan_all(ubi);
> + if (fullscan)
> + ai = scan_all(ubi);
> + else
> + ai = scan_fastmap(ubi);
> +
> if (IS_ERR(ai))
> return PTR_ERR(ai);
>
> @@ -1256,6 +1277,31 @@ out_ai:
> }
Another useless helper function, should die, see below.
>
> /**
> + * ubi_attach - attach an MTD device.
> + * @ubi: UBI device descriptor
> + *
> + * This function returns zero in case of success and a negative error code in
> + * case of failure.
> + */
> +int ubi_attach(struct ubi_device *ubi)
> +{
> + int err;
> +
> + err = do_attach(ubi, false);
> + if (err) {
> + if (err != -ENOENT)
> + ubi_err("Attach by fastmap failed! " \
> + "Falling back to attach by scanning. " \
> + "error = %i\n", err);
> +
> + ubi->attached_by_scanning = true;
> + err = do_attach(ubi, true);
> + }
> +
> + return err;
> +}
Just add this code to this function:
err = ubi_read_fastmap();
if (err < 0)
return err;
if (err == 2)
return scan_all();
... rest of the common nitializations (EBA, WL)...
return err;
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-05-22 13:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-21 14:01 [RFC v6] UBI: Fastmap support (aka checkpointing) Richard Weinberger
2012-05-21 14:01 ` [PATCH] [RFC] UBI: Implement Fastmap support Richard Weinberger
2012-05-22 13:43 ` Artem Bityutskiy [this message]
2012-05-22 15:01 ` Shmulik Ladkani
2012-05-22 16:55 ` Richard Weinberger
2012-05-22 18:18 ` Shmulik Ladkani
2012-05-22 18:57 ` Richard Weinberger
2012-05-23 6:18 ` Shmulik Ladkani
2012-05-23 7:43 ` Richard Weinberger
2012-05-22 20:11 ` Richard Weinberger
2012-05-24 8:19 ` Artem Bityutskiy
2012-05-24 8:26 ` Richard Weinberger
2012-05-24 9:21 ` Artem Bityutskiy
2012-05-24 8:17 ` Artem Bityutskiy
2012-05-24 9:56 ` Shmulik Ladkani
2012-05-24 10:03 ` Richard Weinberger
2012-05-24 20:07 ` Shmulik Ladkani
2012-05-24 8:22 ` Artem Bityutskiy
2012-05-24 8:24 ` Richard Weinberger
-- strict thread matches above, loose matches on Subject: below --
2012-05-23 11:06 [RFC v7] UBI: Fastmap support (aka checkpointing) Richard Weinberger
2012-05-23 11:06 ` [PATCH] [RFC] UBI: Implement Fastmap support Richard Weinberger
2012-05-26 13:22 ` Artem Bityutskiy
2012-05-31 10:37 ` Adrian Hunter
2012-05-31 13:31 ` Richard Weinberger
2012-06-01 5:47 ` Adrian Hunter
2012-06-01 8:00 ` Richard Weinberger
2012-06-01 8:10 ` Artem Bityutskiy
2012-06-01 8:10 ` Richard Weinberger
2012-06-01 8:47 ` Adrian Hunter
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=1337694184.2483.186.camel@sauron.fi.intel.com \
--to=dedekind1@gmail.com \
--cc=Heinz.Egger@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=tglx@linutronix.de \
--cc=tim.bird@am.sony.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).