Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332753
b: refs/heads/master
c: c092b43
h: refs/heads/master
i:
  332751: 037f87e
v: v3
  • Loading branch information
Akinobu Mita authored and David Woodhouse committed Sep 29, 2012
1 parent e361650 commit 868f71f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3cf06f4f85aea715e8caf8540760faff2fbf86d6
refs/heads/master: c092b43906098a6879d0fa9f74e5141516b9b856
18 changes: 16 additions & 2 deletions trunk/drivers/mtd/tests/mtd_nandecctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,25 @@

#if defined(CONFIG_MTD_NAND) || defined(CONFIG_MTD_NAND_MODULE)

/*
* The reason for this __change_bit_le() instead of __change_bit() is to inject
* bit error properly within the region which is not a multiple of
* sizeof(unsigned long) on big-endian systems
*/
#ifdef __LITTLE_ENDIAN
#define __change_bit_le(nr, addr) __change_bit(nr, addr)
#elif defined(__BIG_ENDIAN)
#define __change_bit_le(nr, addr) \
__change_bit((nr) ^ ((BITS_PER_LONG - 1) & ~0x7), addr)
#else
#error "Unknown byte order"
#endif

static void inject_single_bit_error(void *data, size_t size)
{
unsigned long offset = random32() % (size * BITS_PER_BYTE);
unsigned int offset = random32() % (size * BITS_PER_BYTE);

__change_bit(offset, data);
__change_bit_le(offset, data);
}

static void dump_data_ecc(void *error_data, void *error_ecc, void *correct_data,
Expand Down

0 comments on commit 868f71f

Please sign in to comment.