From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: "Jason Wang" <jasowang@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PULL V2 09/14] hw/net/can: Make CanBusClientInfo::can_receive() return a boolean
Date: Tue, 31 Mar 2020 21:21:34 +0800 [thread overview]
Message-ID: <1585660899-11228-10-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1585660899-11228-1-git-send-email-jasowang@redhat.com>
From: Philippe Mathieu-Daudé <philmd@redhat.com>
The CanBusClientInfo::can_receive handler return whether the
device can or can not receive new frames. Make it obvious by
returning a boolean type.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/allwinner-sun8i-emac.c | 2 +-
hw/net/can/can_sja1000.c | 8 ++++----
hw/net/can/can_sja1000.h | 2 +-
include/net/can_emu.h | 2 +-
net/can/can_socketcan.c | 4 ++--
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index 3fc5e34..033eaa8 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -395,7 +395,7 @@ static void allwinner_sun8i_emac_flush_desc(FrameDescriptor *desc,
cpu_physical_memory_write(phys_addr, desc, sizeof(*desc));
}
-static int allwinner_sun8i_emac_can_receive(NetClientState *nc)
+static bool allwinner_sun8i_emac_can_receive(NetClientState *nc)
{
AwSun8iEmacState *s = qemu_get_nic_opaque(nc);
FrameDescriptor desc;
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
index 39c78fa..ea915a0 100644
--- a/hw/net/can/can_sja1000.c
+++ b/hw/net/can/can_sja1000.c
@@ -733,21 +733,21 @@ uint64_t can_sja_mem_read(CanSJA1000State *s, hwaddr addr, unsigned size)
return temp;
}
-int can_sja_can_receive(CanBusClientState *client)
+bool can_sja_can_receive(CanBusClientState *client)
{
CanSJA1000State *s = container_of(client, CanSJA1000State, bus_client);
if (s->clock & 0x80) { /* PeliCAN Mode */
if (s->mode & 0x01) { /* reset mode. */
- return 0;
+ return false;
}
} else { /* BasicCAN mode */
if (s->control & 0x01) {
- return 0;
+ return false;
}
}
- return 1; /* always return 1, when operation mode */
+ return true; /* always return true, when operation mode */
}
ssize_t can_sja_receive(CanBusClientState *client, const qemu_can_frame *frames,
diff --git a/hw/net/can/can_sja1000.h b/hw/net/can/can_sja1000.h
index 220a622..7ca9cd6 100644
--- a/hw/net/can/can_sja1000.h
+++ b/hw/net/can/can_sja1000.h
@@ -137,7 +137,7 @@ void can_sja_disconnect(CanSJA1000State *s);
int can_sja_init(CanSJA1000State *s, qemu_irq irq);
-int can_sja_can_receive(CanBusClientState *client);
+bool can_sja_can_receive(CanBusClientState *client);
ssize_t can_sja_receive(CanBusClientState *client,
const qemu_can_frame *frames, size_t frames_cnt);
diff --git a/include/net/can_emu.h b/include/net/can_emu.h
index d4fc51b..fce9770 100644
--- a/include/net/can_emu.h
+++ b/include/net/can_emu.h
@@ -83,7 +83,7 @@ typedef struct CanBusClientState CanBusClientState;
typedef struct CanBusState CanBusState;
typedef struct CanBusClientInfo {
- int (*can_receive)(CanBusClientState *);
+ bool (*can_receive)(CanBusClientState *);
ssize_t (*receive)(CanBusClientState *,
const struct qemu_can_frame *frames, size_t frames_cnt);
} CanBusClientInfo;
diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c
index 29bfacd..807f31f 100644
--- a/net/can/can_socketcan.c
+++ b/net/can/can_socketcan.c
@@ -110,9 +110,9 @@ static void can_host_socketcan_read(void *opaque)
}
}
-static int can_host_socketcan_can_receive(CanBusClientState *client)
+static bool can_host_socketcan_can_receive(CanBusClientState *client)
{
- return 1;
+ return true;
}
static ssize_t can_host_socketcan_receive(CanBusClientState *client,
--
2.5.0
next prev parent reply other threads:[~2020-03-31 13:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 13:21 [PULL V2 00/14] Net patches Jason Wang
2020-03-31 13:21 ` [PULL V2 01/14] hw/net/i82596: Correct command bitmask (CID 1419392) Jason Wang
2020-03-31 13:21 ` [PULL V2 02/14] hw/net/i82596.c: Avoid reading off end of buffer in i82596_receive() Jason Wang
2020-03-31 13:21 ` [PULL V2 03/14] Fixed integer overflow in e1000e Jason Wang
2020-03-31 13:21 ` [PULL V2 04/14] hw/net/e1000e_core: Let e1000e_can_receive() return a boolean Jason Wang
2020-03-31 13:21 ` [PULL V2 05/14] hw/net/smc91c111: Let smc91c111_can_receive() " Jason Wang
2020-03-31 13:21 ` [PULL V2 06/14] hw/net/rtl8139: Simplify if/else statement Jason Wang
2020-03-31 13:21 ` [PULL V2 07/14] hw/net/rtl8139: Update coding style to make checkpatch.pl happy Jason Wang
2020-03-31 13:21 ` [PULL V2 08/14] hw/net: Make NetCanReceive() return a boolean Jason Wang
2020-03-31 13:21 ` Jason Wang [this message]
2020-03-31 13:21 ` [PULL V2 10/14] net/colo-compare.c: Expose "compare_timeout" to users Jason Wang
2020-03-31 13:21 ` [PULL V2 11/14] net/colo-compare.c: Expose "expired_scan_cycle" " Jason Wang
2020-03-31 13:21 ` [PULL V2 12/14] net: tulip: check frame size and r/w data length Jason Wang
2020-03-31 13:21 ` [PULL V2 13/14] hw/net/allwinner-sun8i-emac.c: Fix REG_ADDR_HIGH/LOW reads Jason Wang
2020-03-31 13:21 ` [PULL V2 14/14] qtest: add tulip test case Jason Wang
2020-03-31 14:36 ` [PULL V2 00/14] Net patches Peter Maydell
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=1585660899-11228-10-git-send-email-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-devel@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 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).