You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/07/27 06:52:41 UTC

[GitHub] mkiiskila commented on a change in pull request #1297: Fix some issues with the L1/L0 flash driver

mkiiskila commented on a change in pull request #1297: Fix some issues with the L1/L0 flash driver
URL: https://github.com/apache/mynewt-core/pull/1297#discussion_r205681950
 
 

 ##########
 File path: hw/mcu/stm/stm32l1xx/src/hal_flash.c
 ##########
 @@ -65,31 +65,44 @@ static int
 stm32l1_flash_write(const struct hal_flash *dev, uint32_t address,
         const void *src, uint32_t num_bytes)
 {
-    const uint32_t *sptr;
+    uint32_t val;
     uint32_t i;
     int rc;
+    uint8_t align;
     uint32_t num_words;
 
     if (!num_bytes) {
         return -1;
     }
 
+    align = dev->hf_align;
+    num_words = ((num_bytes - 1) / dev->hf_align) + 1;
 
 Review comment:
   Divide is expensive, bitwise operations are cheap. I would use those rather, given that alignment is a power of 2.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services