public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind@infradead.org>
To: Vijay Kumar <vijaykumar@bravegnu.org>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] NAND: nandsim bad block injection
Date: Wed, 27 Dec 2006 13:26:10 +0200	[thread overview]
Message-ID: <1167218770.4217.12.camel@sauron> (raw)
In-Reply-To: <17806.31709.360587.895943@vaishnavi.localdomain>

Hello Vijay,

On Sun, 2006-12-24 at 18:38 +0530, Vijay Kumar wrote:
> Adds support for bad block creation on block erase and page program,
> by returning erase/program failed in the status byte. The probability
> of fault occurrence can be specified through module parameters.
> 
> Signed-off-by: Vijay Kumar <vijaykumar@bravegnu.org>

Looks useful.
 
> +#define PROB_SCALE_FACTOR         1000
> +#define PROB_SCALE_FACTOR_STR     "1000"
Use __stringify(PROB_SCALE_FACTOR) instead.

> +static int inject_fault_with_prob(int prob)
> +{
> +	int rnd;
> +
> +	rnd = random32() % PROB_SCALE_FACTOR;
> +
> +	if (rnd < prob)
> +		return 1;
> +	else
> +		return 0;
> +}
> +
> +static inline int inject_erase_fault(void)
> +{
> +	return inject_fault_with_prob(erase_fail_prob);
> +}
I think there is no need in having 'inject_fault_with_prob()' function
at all. Just use

int rnd = random32() % PROB_SCALE_FACTOR;
return rnd < prob;

> +
> +static inline int inject_prog_fault(void)
> +{
> +	return inject_fault_with_prob(prog_fail_prob);
> +}
Ditto.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

  reply	other threads:[~2006-12-27 11:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-24 13:08 [PATCH] NAND: nandsim bad block injection Vijay Kumar
2006-12-27 11:26 ` Artem Bityutskiy [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-12-27 15:24 Vijay Kumar
2006-12-28 10:22 ` Artem Bityutskiy

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=1167218770.4217.12.camel@sauron \
    --to=dedekind@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=vijaykumar@bravegnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox