@@ -249,6 +249,7 @@ static void device_reset(void)
249249 ctx .sector_cnt = m_sec_cnt ;
250250 ctx .sector_size = m_sec_size ;
251251 ctx .offset = m_fa -> fa_off ;
252+ ctx .flash_dev = m_fa -> fa_dev ;
252253}
253254
254255/** End Local functions *******************************************************/
@@ -259,8 +260,8 @@ static void test_initialize(void)
259260 flash_clear ();
260261 device_reset ();
261262
262- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
263- zassert_true (emds_flash_init (& ctx , m_fa -> fa_dev ), "Should not init more than once" );
263+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
264+ zassert_true (emds_flash_init (& ctx ), "Should not init more than once" );
264265}
265266
266267static void test_rd_wr_simple (void )
@@ -274,7 +275,7 @@ static void test_rd_wr_simple(void)
274275 flash_clear ();
275276 device_reset ();
276277
277- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
278+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
278279 zassert_false (emds_flash_prepare (& ctx , sizeof (data_in ) + ctx .ate_size ), "Prepare failed" );
279280 zassert_false (emds_flash_write (& ctx , 1 , data_in , sizeof (data_in )) < 0 , "Error when write" );
280281 zassert_false (emds_flash_read (& ctx , 1 , data_out , sizeof (data_out )) < 0 , "Error when read" );
@@ -302,7 +303,7 @@ static void test_flash_recovery(void)
302303 * ...
303304 * Expect: Normal behavior
304305 */
305- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
306+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
306307 zassert_false (ctx .force_erase , "Expected false" );
307308 zassert_equal (m_test_fd .ate_idx_start , ctx .ate_wra , "%X not equal to %X" ,
308309 m_test_fd .ate_idx_start , ctx .ate_wra );
@@ -321,7 +322,7 @@ static void test_flash_recovery(void)
321322 idx = m_test_fd .ate_idx_start ;
322323 entry_write (idx , 1 , data_in1 , sizeof (data_in1 ));
323324 idx -= sizeof (struct test_ate );
324- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
325+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
325326 zassert_true (emds_flash_read (& ctx , 1 , data_out , sizeof (data_in1 )) > 0 , "Could not read" );
326327 (void )emds_flash_read (& ctx , 1 , data_out , sizeof (data_in1 ));
327328 zassert_false (ctx .force_erase , "Expected false" );
@@ -344,7 +345,7 @@ static void test_flash_recovery(void)
344345 idx -= sizeof (struct test_ate );
345346 entry_write (idx , 2 , data_in2 , sizeof (data_in2 ));
346347 idx -= sizeof (struct test_ate );
347- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
348+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
348349 zassert_false (ctx .force_erase , "Expected false" );
349350 zassert_equal (idx , ctx .ate_wra , "Addr not equal" );
350351 zassert_true (emds_flash_read (& ctx , 2 , data_out , sizeof (data_in2 )) > 0 , "Could not read" );
@@ -365,7 +366,7 @@ static void test_flash_recovery(void)
365366 idx -= sizeof (struct test_ate );
366367 entry_write (idx , 3 , data_in3 , sizeof (data_in3 ));
367368 idx -= sizeof (struct test_ate );
368- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
369+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
369370 zassert_true (ctx .force_erase , "Expected true" );
370371 zassert_equal (idx , ctx .ate_wra , "Addr not equal" );
371372 zassert_true (emds_flash_read (& ctx , 2 , data_out , sizeof (data_in2 )) > 0 , "Could not read" );
@@ -395,7 +396,7 @@ static void test_flash_recovery(void)
395396 idx -= sizeof (struct test_ate );
396397 ate_corrupt_write (idx );
397398 idx -= sizeof (struct test_ate );
398- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
399+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
399400 zassert_true (ctx .force_erase , "Expected true" );
400401 zassert_equal (idx , ctx .ate_wra , "Addr not equal" );
401402 zassert_true (emds_flash_read (& ctx , 3 , data_out , sizeof (data_in3 )) > 0 , "Could not read" );
@@ -409,7 +410,7 @@ static void test_flash_recovery_corner_case(void)
409410
410411 /* Fill flash with garbage. Expect 0 space left and erase on prepare */
411412 corrupt_write_all ();
412- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
413+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
413414 zassert_true (ctx .force_erase , "Force erase should be true" );
414415 zassert_equal (0 , emds_flash_free_space_get (& ctx ), "Expected no free space" );
415416 device_reset ();
@@ -431,7 +432,7 @@ static void test_invalidate_on_prepare(void)
431432 idx -= sizeof (struct test_ate );
432433 }
433434
434- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
435+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
435436 zassert_false (ctx .force_erase , "Force erase should be false" );
436437 zassert_equal (idx , ctx .ate_wra , "Addr not equal" );
437438
@@ -445,7 +446,7 @@ static void test_invalidate_on_prepare(void)
445446 zassert_false (emds_flash_prepare (& ctx , 0 ), "Error when preparing" );
446447
447448 device_reset ();
448- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
449+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
449450
450451 /* Expect the free storage integrity to fail due to no valid ATE and invalid presence.
451452 * This occurs only if the user does not store any new entry after emds_flash_prepare
@@ -479,7 +480,7 @@ static void test_clear_on_strange_flash(void)
479480 * Expect: Unexpected behavior
480481 */
481482 ate_corrupt_write (m_test_fd .ate_idx_start );
482- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
483+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
483484 zassert_true (ctx .force_erase , "Force erase should be true" );
484485 zassert_false (emds_flash_prepare (& ctx , 0 ), "Error when preparing" );
485486 zassert_false (flash_cmp_const (m_test_fd .offset , 0xff , m_test_fd .size ), "Flash not cleared" );
@@ -500,7 +501,7 @@ static void test_permission(void)
500501 zassert_true (emds_flash_write (& ctx , 1 , data_in , sizeof (data_in )) == - EACCES ,
501502 "Should not be able to read" );
502503
503- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
504+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
504505
505506 zassert_true (emds_flash_write (& ctx , 1 , data_in , sizeof (data_in )) == - EACCES ,
506507 "Should not be able to read" );
@@ -523,7 +524,7 @@ static void test_overflow(void)
523524 flash_clear ();
524525 device_reset ();
525526
526- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
527+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
527528 zassert_false (emds_flash_prepare (& ctx , sizeof (data_in ) + ctx .ate_size ), "Prepare failed" );
528529
529530 uint16_t test_cnt = 0 ;
@@ -539,7 +540,7 @@ static void test_overflow(void)
539540 "Should not be able to write" );
540541
541542 device_reset ();
542- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
543+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
543544
544545 data_in [0 ] = 'D' ;
545546 for (size_t i = 0 ; i < test_cnt ; i ++ ) {
@@ -557,7 +558,7 @@ static void test_overflow(void)
557558 emds_flash_write (& ctx , 0 , data_in , sizeof (data_in ));
558559
559560 device_reset ();
560- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
561+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
561562
562563 emds_flash_read (& ctx , 0 , data_out , sizeof (data_out ));
563564 zassert_false (memcmp (data_out , data_in , sizeof (data_out )), "Retrived wrong value" );
@@ -572,7 +573,7 @@ static void test_prepare_overflow(void)
572573 flash_clear ();
573574 device_reset ();
574575
575- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
576+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
576577 zassert_true (emds_flash_prepare (& ctx , m_test_fd .size ), "Prepare should return error" );
577578 zassert_false (emds_flash_prepare (& ctx , m_test_fd .size - 16 ), "Prepare failed" );
578579 zassert_false (emds_flash_prepare (& ctx , m_test_fd .size - 24 ), "Prepare failed" );
@@ -585,7 +586,7 @@ static void test_full_corrupt_recovery(void)
585586
586587 /* Fill flash with garbage. Expect 0 space left and erase on prepare */
587588 corrupt_write_all ();
588- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
589+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
589590 zassert_true (ctx .force_erase , "Force erase should be true" );
590591 zassert_equal (0 , emds_flash_free_space_get (& ctx ), "Expected no free space" );
591592
@@ -606,7 +607,7 @@ static void test_corrupted_data(void)
606607 flash_clear ();
607608 device_reset ();
608609
609- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
610+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
610611 zassert_false (emds_flash_prepare (& ctx , sizeof (data_in ) + ctx .ate_size ), "Prepare failed" );
611612
612613 zassert_true (emds_flash_write (& ctx , 1 , data_in , sizeof (data_in )) == sizeof (data_in ),
@@ -621,7 +622,7 @@ static void test_corrupted_data(void)
621622
622623 /* Reset */
623624 device_reset ();
624- zassert_false (emds_flash_init (& ctx , m_fa -> fa_dev ), "Error when initializing" );
625+ zassert_false (emds_flash_init (& ctx ), "Error when initializing" );
625626
626627 zassert_true (emds_flash_read (& ctx , 1 , data_out , sizeof (data_in )) < 0 ,
627628 "Should not be able to read" );
@@ -647,7 +648,7 @@ static void test_write_speed(void)
647648 (void )sdc_disable ();
648649 mpsl_uninit ();
649650#endif
650- emds_flash_init (& ctx , m_fa -> fa_dev );
651+ emds_flash_init (& ctx );
651652 emds_flash_prepare (& ctx , sizeof (data_in ) + ctx .ate_size );
652653
653654 tic = k_uptime_ticks ();
0 commit comments