-
-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rgblight.c: Prevent wasteful writing to eeprom. #4984
Conversation
tagging @drashna as he might be upset about this change. =P |
Will be upset ? really? |
Drashna is well known for destroying eeproms. It's an inside joke that it is his hobby. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
@mechmerlin LOL :D @mtei Yup. It's an inside joke. A lot of the eeprom changes to the rgblight code are because of me. I was using these for layer state indication, and probably writing to EEPROM 50+ times a day. So, anything that saves EEPROM writes, I'm all for! So I'm all for this change, as it's a great one! |
Thanks! |
The native eeprom_update_* functions that come from avr-libc already avoid rewriting identical values (which is the entire point of having them in addition to eeprom_write_*) however in the places we're reimplementing that API for ARM we've just blindly copy-and-pasted the eeprom_write_* code. I'll raise an issue to track this, ideally we should push all these checks down into eeprom_update_* and eliminate them in the rest of the code. |
I finally understood the difference between "write" and "update". And I also found that the implementation under the tmk_core/common/ directory is inconsistent. If "update" is all correctly implemented, this PR workaround will be unnecessary. |
Eeprom is currently wildly unsafe on ARM, so it doesn't hurt to avoid writes wherever possible, even if redundant checks are made. But ideally we'll fix the lower layers soon and then the entire problem will go away. |
@pelrun You're correct. It does appear that AVR will not write if the value is the same. If you are using the "update" function, and not the write function (which appears to be what we're using). However, ARM doesn't do this. So, adding checks is a good idea. @mtei for AVR this would be unnecessary, but until the ARM code is updated to do this automatically, we should leave this in place. |
Description
In order to prolong the lifetime of eeprom, write of the same value is omitted.
Types of changes
Checklist: