Exemplo n.º 1
0
Arquivo: debug.c Projeto: 0xBADCA7/lk
// Ensure that (sub)sector erase work.
static bool sub_erase_test(bdev_t *device, uint32_t n_samples)
{
    printf("Sampling the device %d times.\n", n_samples);
    for (uint32_t i = 0; i < n_samples; i++) {
        bnum_t block_addr = rand() % device->block_count;
        if (!test_erase_block(device, block_addr)) {
            return false;
        }
    }
    return true;
}
static int test_write_block(const char *val, struct kernel_param *kp)
{
	int i;
	int err;
/* LGE_CHANGE_S [[email protected]] 2010-08-22, merge First Boot Complete Test from VS660 */
	unsigned char *test_string;
	unsigned long flag=0;
	// LGE_CHANGE [[email protected]] 2010-08-23, do something after cold boot
	struct diagcmd_dev *diagpdev;

	flag = simple_strtoul(val,NULL,10);
	if(5 == flag)
		test_string="FACT_RESET_5";
	else if(6 == flag)
		test_string="FACT_RESET_6";
	// LGE_CHANGE [[email protected]] 2010-09-04, for RTN and Factory reset
	else if (3 == flag)
		test_string="FACT_RESET_3";
	else
		return -1;
	
	test_init();
	test_erase_block();
	printk(KERN_INFO"%s: writing block: flag = %lu\n", __func__, flag);
/* LGE_CHANGE_E [[email protected]] 2010-08-22, merge First Boot Complete Test from VS660 */
	
	for (i = 0; i < ebcnt; i++) {
		if (bbt[i])
			continue;
		else
			break;
	}
#ifdef LGE_RETRY_MTD_DIRECT_ACCESS
	err = lge_retry_write_block(i, test_string, strlen(test_string));
#else
	err = lge_write_block(i, test_string, strlen(test_string));
#endif
	if (err) {
		printk(KERN_INFO"%s: write %u block fail\n", __func__, i);
		return err;
	}
	
	printk(KERN_INFO"%s: write %u block\n", __func__, i);
	
	// LGE_CHANGE [[email protected]] 2010-08-23, do something after cold boot
	if (flag == 5) {
		diagpdev = diagcmd_get_dev();	
		if (diagpdev != NULL) {
			update_diagcmd_state(diagpdev, "ADBSET", 0);
		}
	}
	
	return 0;
}