hw/i2c/bitbang_i2c: Handle NACKs from devices

If the guest attempts to talk to a nonexistent device over i2c,
the i2c_start_transfer() function will return non-zero, indicating
that the bus is signalling a NACK. Similarly, if the i2c_send()
function returns nonzero then the target device returned a NACK.
Handle this possibility in the bitbang_i2c code, by returning
the state machine to the STOPPED state and returning the NACK
bit to the guest.

This bit of missing functionality was spotted by Coverity
(it noticed that we weren't checking the return value from
i2c_start_transfer()).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1477332749-27098-1-git-send-email-peter.maydell@linaro.org
1 file changed
tree: fc0b5ad553ae5602a69816ffa980695a43311443
  1. .dir-locals.el
  2. .exrc
  3. .gitignore
  4. .gitmodules
  5. .mailmap
  6. .travis.yml
  7. CODING_STYLE
  8. COPYING
  9. COPYING.LIB
  10. Changelog
  11. HACKING
  12. LICENSE
  13. MAINTAINERS
  14. Makefile
  15. Makefile.objs
  16. Makefile.target
  17. README
  18. VERSION
  19. accel.c
  20. aio-posix.c
  21. aio-win32.c
  22. arch_init.c
  23. async.c
  24. atomic_template.h
  25. audio/
  26. backends/
  27. balloon.c
  28. block.c
  29. block/
  30. blockdev-nbd.c
  31. blockdev.c
  32. blockjob.c
  33. bootdevice.c
  34. bsd-user/
  35. bt-host.c
  36. bt-vhci.c
  37. configure
  38. contrib/
  39. cpu-exec-common.c
  40. cpu-exec.c
  41. cpus-common.c
  42. cpus.c
  43. cputlb.c
  44. crypto/
  45. default-configs/
  46. device-hotplug.c
  47. device_tree.c
  48. disas.c
  49. disas/
  50. dma-helpers.c
  51. docs/
  52. dump.c
  53. exec.c
  54. fpu/
  55. fsdev/
  56. gdb-xml/
  57. gdbstub.c
  58. hmp-commands-info.hx
  59. hmp-commands.hx
  60. hmp.c
  61. hmp.h
  62. hw/
  63. include/
  64. io/
  65. iohandler.c
  66. ioport.c
  67. iothread.c
  68. kvm-all.c
  69. kvm-stub.c
  70. libdecnumber/
  71. linux-headers/
  72. linux-user/
  73. main-loop.c
  74. memory.c
  75. memory_mapping.c
  76. migration/
  77. module-common.c
  78. monitor.c
  79. nbd/
  80. net/
  81. numa.c
  82. os-posix.c
  83. os-win32.c
  84. page_cache.c
  85. pc-bios/
  86. po/
  87. qapi-schema.json
  88. qapi/
  89. qdev-monitor.c
  90. qdict-test-data.txt
  91. qemu-bridge-helper.c
  92. qemu-char.c
  93. qemu-doc.texi
  94. qemu-ga.texi
  95. qemu-img-cmds.hx
  96. qemu-img.c
  97. qemu-img.texi
  98. qemu-io-cmds.c
  99. qemu-io.c
  100. qemu-nbd.c
  101. qemu-nbd.texi
  102. qemu-option-trace.texi
  103. qemu-options-wrapper.h
  104. qemu-options.h
  105. qemu-options.hx
  106. qemu-seccomp.c
  107. qemu-tech.texi
  108. qemu-timer.c
  109. qemu.nsi
  110. qemu.sasl
  111. qga/
  112. qmp.c
  113. qobject/
  114. qom/
  115. qtest.c
  116. replay/
  117. replication.c
  118. replication.h
  119. roms/
  120. rules.mak
  121. scripts/
  122. slirp/
  123. softmmu_template.h
  124. spice-qemu-char.c
  125. stubs/
  126. target-alpha/
  127. target-arm/
  128. target-cris/
  129. target-i386/
  130. target-lm32/
  131. target-m68k/
  132. target-microblaze/
  133. target-mips/
  134. target-moxie/
  135. target-openrisc/
  136. target-ppc/
  137. target-s390x/
  138. target-sh4/
  139. target-sparc/
  140. target-tilegx/
  141. target-tricore/
  142. target-unicore32/
  143. target-xtensa/
  144. tcg-runtime.c
  145. tcg/
  146. tci.c
  147. tests/
  148. thread-pool.c
  149. thunk.c
  150. tpm.c
  151. trace-events
  152. trace/
  153. translate-all.c
  154. translate-all.h
  155. translate-common.c
  156. ui/
  157. user-exec.c
  158. util/
  159. version.rc
  160. vl.c
  161. xen-common-stub.c
  162. xen-common.c
  163. xen-hvm-stub.c
  164. xen-hvm.c
  165. xen-mapcache.c