[PATCH] NAND: nandsim bad block injection

Artem Bityutskiy dedekind at infradead.org
Wed Dec 27 06:26:10 EST 2006


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 at 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 (Битюцкий Артём)





More information about the linux-mtd mailing list