<p>Arthur Heymans has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/20879">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">[WIP] sb/intel/common: limit smbus block read bytes according to slave<br><br>Should it also limit to 32?<br>Should it report to the user if slave bytes is less than function<br>input?<br><br>Change-Id: If9e5d24255a0a03039b52d2863bc278d0eefc311<br>Signed-off-by: Arthur Heymans <arthur@aheymans.xyz><br>---<br>M src/southbridge/intel/common/smbus.c<br>1 file changed, 7 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/79/20879/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/southbridge/intel/common/smbus.c b/src/southbridge/intel/common/smbus.c<br>index cac9ba7..cb884dc 100644<br>--- a/src/southbridge/intel/common/smbus.c<br>+++ b/src/southbridge/intel/common/smbus.c<br>@@ -193,13 +193,14 @@<br> }<br> <br> int do_smbus_block_read(unsigned int smbus_base, u8 device, u8 cmd,<br>-                   unsigned int bytes, u8 *buf)<br>+                 unsigned int max_bytes, u8 *buf)<br> {<br>  u8 status;<br>    int bytes_read = 0;<br>   unsigned int loops = SMBUS_TIMEOUT;<br>   if (smbus_wait_until_ready(smbus_base) < 0)<br>                return SMBUS_WAIT_UNTIL_READY_TIMEOUT;<br>+       u8 slave_bytes;<br> <br>    /* Set up transaction */<br>      /* Disable interrupts */<br>@@ -223,6 +224,10 @@<br>        if (smbus_wait_until_active(smbus_base) < 0)<br>               return SMBUS_WAIT_UNTIL_ACTIVE_TIMEOUT;<br> <br>+   slave_bytes = inb(smbus_base + SMBHSTDAT0);<br>+  if (slave_bytes < max_bytes)<br>+              max_bytes = slave_bytes;<br>+<br>   /* Poll for transaction completion */<br>         do {<br>          loops--;<br>@@ -236,7 +241,7 @@<br>                         *buf = inb(smbus_base + SMBBLKDAT);<br>                   buf++;<br>                        bytes_read++;<br>-                        if (--bytes == 1) {<br>+                  if (--max_bytes == 1) {<br>                               /* indicate that next byte is the last one */<br>                                 outb(inb(smbus_base + SMBHSTCTL)<br>                                      | SMBHSTCNT_LAST_BYTE,<br></pre><p>To view, visit <a href="https://review.coreboot.org/20879">change 20879</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/20879"/><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: If9e5d24255a0a03039b52d2863bc278d0eefc311 </div>
<div style="display:none"> Gerrit-Change-Number: 20879 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz> </div>