qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fix I2C slave addressing
@ 2009-06-08  6:27 Juha Riihimäki
  2009-10-29 13:36 ` Riku Voipio
  0 siblings, 1 reply; 2+ messages in thread
From: Juha Riihimäki @ 2009-06-08  6:27 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

With the recent device handling changes the I2C slave addressing code  
was broken. With current code, if a slave with the correct address is  
not found on the bus the last scanned slave on the bus will be  
addressed. This is wrong. Please find attached a patch to fix it.

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
---
diff --git a/hw/i2c.c b/hw/i2c.c
index 8a0c4d7..e1dacef 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -69,9 +69,11 @@ int i2c_start_transfer(i2c_bus *bus, int address,  
int recv)
      i2c_slave *slave = NULL;

      LIST_FOREACH(qdev, &bus->qbus.children, sibling) {
-        slave = I2C_SLAVE_FROM_QDEV(qdev);
-        if (slave->address == address)
+        i2c_slave *candidate = I2C_SLAVE_FROM_QDEV(qdev);
+        if (candidate->address == address) {
+            slave = candidate;
              break;
+        }
      }

      if (!slave)

[-- Attachment #2: i2c.diff --]
[-- Type: application/octet-stream, Size: 538 bytes --]

diff --git a/hw/i2c.c b/hw/i2c.c
index 8a0c4d7..e1dacef 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -69,9 +69,11 @@ int i2c_start_transfer(i2c_bus *bus, int address, int recv)
     i2c_slave *slave = NULL;
 
     LIST_FOREACH(qdev, &bus->qbus.children, sibling) {
-        slave = I2C_SLAVE_FROM_QDEV(qdev);
-        if (slave->address == address)
+        i2c_slave *candidate = I2C_SLAVE_FROM_QDEV(qdev);
+        if (candidate->address == address) {
+            slave = candidate;
             break;
+        }
     }
 
     if (!slave)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] fix I2C slave addressing
  2009-06-08  6:27 [Qemu-devel] [PATCH] fix I2C slave addressing Juha Riihimäki
@ 2009-10-29 13:36 ` Riku Voipio
  0 siblings, 0 replies; 2+ messages in thread
From: Riku Voipio @ 2009-10-29 13:36 UTC (permalink / raw)
  To: qemu-devel

On Mon, Jun 08, 2009 at 09:27:19AM +0300, Juha Riihimäki wrote:
> With the recent device handling changes the I2C slave addressing code  
> was broken. With current code, if a slave with the correct address is  
> not found on the bus the last scanned slave on the bus will be  
> addressed. This is wrong. Please find attached a patch to fix it.

Without this patch, n800/n810 emulation fails to boot.

Acked-by: Riku Voipio <riku.voipio@iki.fi>

> Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
> ---
> diff --git a/hw/i2c.c b/hw/i2c.c
> index 8a0c4d7..e1dacef 100644
> --- a/hw/i2c.c
> +++ b/hw/i2c.c
> @@ -69,9 +69,11 @@ int i2c_start_transfer(i2c_bus *bus, int address, int 
> recv)
>      i2c_slave *slave = NULL;
>
>      LIST_FOREACH(qdev, &bus->qbus.children, sibling) {
> -        slave = I2C_SLAVE_FROM_QDEV(qdev);
> -        if (slave->address == address)
> +        i2c_slave *candidate = I2C_SLAVE_FROM_QDEV(qdev);
> +        if (candidate->address == address) {
> +            slave = candidate;
>              break;
> +        }
>      }
>
>      if (!slave)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-29 13:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-08  6:27 [Qemu-devel] [PATCH] fix I2C slave addressing Juha Riihimäki
2009-10-29 13:36 ` Riku Voipio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).