Commit f917e69d authored by Andre Przywara's avatar Andre Przywara
Browse files

fel: Skip uploading empty image



Our FEL code does not deal very well with the upload size being 0.

Check for that before calling any USB routines, and skip the call
entirely. Mark the buffer as "const" on the way, since we have no
business other than reading from it.

That helps to properly skip dummy images later.
Signed-off-by: default avatarAndre Przywara <osp@andrep.de>
parent 7a6a2221
......@@ -214,8 +214,11 @@ void aw_fel_read(feldev_handle *dev, uint32_t offset, void *buf, size_t len)
}
/* AW_FEL_1_WRITE request */
void aw_fel_write(feldev_handle *dev, void *buf, uint32_t offset, size_t len)
void aw_fel_write(feldev_handle *dev, const void *buf, uint32_t offset, size_t len)
{
if (len == 0)
return;
aw_send_fel_request(dev, AW_FEL_1_WRITE, offset, len);
aw_usb_write(dev, buf, len, false);
aw_read_fel_status(dev);
......@@ -233,9 +236,12 @@ void aw_fel_execute(feldev_handle *dev, uint32_t offset)
* Unlike aw_fel_write() above - which is reserved for internal use - this
* routine optionally allows progress callbacks.
*/
void aw_fel_write_buffer(feldev_handle *dev, void *buf, uint32_t offset,
void aw_fel_write_buffer(feldev_handle *dev, const void *buf, uint32_t offset,
size_t len, bool progress)
{
if (len == 0)
return;
aw_send_fel_request(dev, AW_FEL_1_WRITE, offset, len);
aw_usb_write(dev, buf, len, progress);
aw_read_fel_status(dev);
......
......@@ -59,8 +59,8 @@ feldev_list_entry *list_fel_devices(size_t *count);
/* FEL functions */
void aw_fel_read(feldev_handle *dev, uint32_t offset, void *buf, size_t len);
void aw_fel_write(feldev_handle *dev, void *buf, uint32_t offset, size_t len);
void aw_fel_write_buffer(feldev_handle *dev, void *buf, uint32_t offset,
void aw_fel_write(feldev_handle *dev, const void *buf, uint32_t offset, size_t len);
void aw_fel_write_buffer(feldev_handle *dev, const void *buf, uint32_t offset,
size_t len, bool progress);
void aw_fel_execute(feldev_handle *dev, uint32_t offset);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment