All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org, BALATON Zoltan <balaton@eik.bme.hu>
Cc: "Corey Minyard" <cminyard@mvista.com>,
	qemu-ppc@nongnu.org, "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: [PATCH v2 2/3] i2c: Make i2c_start_transfer() direction argument a boolean
Date: Tue, 23 Jun 2020 08:31:22 +0200	[thread overview]
Message-ID: <20200623063123.20776-3-f4bug@amsat.org> (raw)
In-Reply-To: <20200623063123.20776-1-f4bug@amsat.org>

From: BALATON Zoltan <balaton@eik.bme.hu>

Make the argument representing the direction of the transfer a
boolean type.
Rename the boolean argument as 'is_recv' to match i2c_recv_send().
Document the function prototype.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-Id: <20200621145235.9E241745712@zero.eik.bme.hu>
[PMD: Split patch, added docstring]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/i2c/i2c.h | 11 ++++++++++-
 hw/i2c/core.c        |  4 ++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index bc70c5b43d..a9e725bd6f 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -72,7 +72,16 @@ struct I2CBus {
 I2CBus *i2c_init_bus(DeviceState *parent, const char *name);
 void i2c_set_slave_address(I2CSlave *dev, uint8_t address);
 int i2c_bus_busy(I2CBus *bus);
-int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv);
+/**
+ * i2c_start_transfer: start a transfer on an I2C bus.
+ *
+ * @bus: #I2CBus to be used
+ * @address: address of the slave
+ * @is_recv: indicates the transfer direction
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv);
 void i2c_end_transfer(I2CBus *bus);
 void i2c_nack(I2CBus *bus);
 /**
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index b83c2b5b89..6f091837c9 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -91,7 +91,7 @@ int i2c_bus_busy(I2CBus *bus)
  * without releasing the bus.  If that fails, the bus is still
  * in a transaction.
  */
-int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
+int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv)
 {
     BusChild *kid;
     I2CSlaveClass *sc;
@@ -144,7 +144,7 @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
 
         if (sc->event) {
             trace_i2c_event("start", s->address);
-            rv = sc->event(s, recv ? I2C_START_RECV : I2C_START_SEND);
+            rv = sc->event(s, is_recv ? I2C_START_RECV : I2C_START_SEND);
             if (rv && !bus->broadcast) {
                 if (bus_scanned) {
                     /* First call, terminate the transfer. */
-- 
2.21.3



  parent reply	other threads:[~2020-06-23  6:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23  6:31 [PATCH v2 0/3] i2c: Match parameters of i2c_start_transfer and i2c_send_recv Philippe Mathieu-Daudé
2020-06-23  6:31 ` [PATCH v2 1/3] " Philippe Mathieu-Daudé
2020-06-23  6:31 ` Philippe Mathieu-Daudé [this message]
2020-06-23  6:31 ` [RFC PATCH v2 3/3] hw/misc/auxbus: Fix MOT/classic I2C mode Philippe Mathieu-Daudé
2020-06-23 11:06   ` BALATON Zoltan
2020-07-04 16:54     ` Philippe Mathieu-Daudé
2020-07-04 16:54 ` [PATCH v2 0/3] i2c: Match parameters of i2c_start_transfer and i2c_send_recv Philippe Mathieu-Daudé
2021-06-12 19:33 ` BALATON Zoltan
2021-06-14  9:56   ` Philippe Mathieu-Daudé
2021-06-14 10:02     ` BALATON Zoltan
2021-06-14 16:48       ` Philippe Mathieu-Daudé
2021-06-14 19:34         ` Corey Minyard
2021-06-16 15:09           ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200623063123.20776-3-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=balaton@eik.bme.hu \
    --cc=cminyard@mvista.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.