<p>Marshall Dawson has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/22519">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">amd/stoneyridge/spi: Fix reads greater than 5 bytes<br><br>This corrects a bug in 918c8717 "amd/stoneyridge: Add SPI controller<br>driver".  Pass a pointer to din to the do_command() function so the<br>caller's copy is correctly updated.  The bug allowed reads <= 5 bytes<br>to work correctly (3 bytes consumed in the FIFO by the address) but<br>overwrote data in the din buffer on larger transfers.<br><br>Change-Id: I32b7752f047112849871cafc9ae33c5ea1466ee1<br>Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com><br>---<br>M src/soc/amd/stoneyridge/spi.c<br>1 file changed, 4 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/19/22519/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/soc/amd/stoneyridge/spi.c b/src/soc/amd/stoneyridge/spi.c<br>index 84b56df..7ff2676 100644<br>--- a/src/soc/amd/stoneyridge/spi.c<br>+++ b/src/soc/amd/stoneyridge/spi.c<br>@@ -114,7 +114,7 @@<br> }<br> <br> static int do_command(uint8_t cmd, const void *dout,<br>-         size_t bytesout, void *din, size_t *bytesin)<br>+         size_t bytesout, uint8_t **din, size_t *bytesin)<br> {<br>  size_t count;<br>         size_t max_in = MIN(*bytesin, SPI_FIFO_DEPTH);<br>@@ -138,8 +138,8 @@<br>   for (count = 0; count < bytesout; count++)<br>                 spi_read8(SPI_CNTRL1); /* skip the bytes we sent */<br> <br>-       for (count = 0; count < max_in; count++, din++)<br>-           *(uint8_t *)din = spi_read8(SPI_CNTRL1);<br>+     for (count = 0; count < max_in; count++, (*din)++)<br>+                **din = spi_read8(SPI_CNTRL1);<br> <br>     *bytesin -= max_in;<br>   return 0;<br>@@ -166,9 +166,8 @@<br>                                " chip driver use spi_crop_chunk()?\n");<br>            return -1;<br>    }<br>-<br>  do {<br>-         if (do_command(cmd, dout, bytesout, din, &bytesin))<br>+              if (do_command(cmd, dout, bytesout, (uint8_t **)&din, &bytesin))<br>                      return -1;<br>    } while (bytesin);<br> <br></pre><p>To view, visit <a href="https://review.coreboot.org/22519">change 22519</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/22519"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I32b7752f047112849871cafc9ae33c5ea1466ee1 </div>
<div style="display:none"> Gerrit-Change-Number: 22519 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Marshall Dawson <marshalldawson3rd@gmail.com> </div>