From 23a568240d9fb216c5f2ca9feeb3134725c9eea0 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Fri, 7 Oct 2016 14:00:51 +1100
Subject: [PATCH] esp8266: Use mp_raise_OSError helper function.

---
 esp8266/modesp.c | 10 +++-------
 esp8266/moduos.c |  2 +-
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/esp8266/modesp.c b/esp8266/modesp.c
index 9a7d4ad18..e081f57da 100644
--- a/esp8266/modesp.c
+++ b/esp8266/modesp.c
@@ -583,7 +583,7 @@ STATIC mp_obj_t esp_flash_read(mp_obj_t offset_in, mp_obj_t len_or_buf_in) {
     if (alloc_buf) {
         m_del(byte, buf, len);
     }
-    nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO)));
+    mp_raise_OSError(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO);
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_flash_read_obj, esp_flash_read);
 
@@ -598,9 +598,7 @@ STATIC mp_obj_t esp_flash_write(mp_obj_t offset_in, const mp_obj_t buf_in) {
     if (res == SPI_FLASH_RESULT_OK) {
         return mp_const_none;
     }
-    nlr_raise(mp_obj_new_exception_arg1(
-        &mp_type_OSError,
-        MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO)));
+    mp_raise_OSError(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO);
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_flash_write_obj, esp_flash_write);
 
@@ -610,9 +608,7 @@ STATIC mp_obj_t esp_flash_erase(mp_obj_t sector_in) {
     if (res == SPI_FLASH_RESULT_OK) {
         return mp_const_none;
     }
-    nlr_raise(mp_obj_new_exception_arg1(
-        &mp_type_OSError,
-        MP_OBJ_NEW_SMALL_INT(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO)));
+    mp_raise_OSError(res == SPI_FLASH_RESULT_TIMEOUT ? MP_ETIMEDOUT : MP_EIO);
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_flash_erase_obj, esp_flash_erase);
 
diff --git a/esp8266/moduos.c b/esp8266/moduos.c
index 9ac0d5602..e9c4c3e8c 100644
--- a/esp8266/moduos.c
+++ b/esp8266/moduos.c
@@ -74,7 +74,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
 #if MICROPY_VFS_FAT
 mp_obj_t vfs_proxy_call(qstr method_name, mp_uint_t n_args, const mp_obj_t *args) {
     if (MP_STATE_PORT(fs_user_mount)[0] == NULL) {
-        nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(MP_ENODEV)));
+        mp_raise_OSError(MP_ENODEV);
     }
 
     mp_obj_t meth[n_args + 2];
-- 
GitLab