Skip to content

Commit

Permalink
hw/net/can: Make CanBusClientInfo::can_receive() return a boolean
Browse files Browse the repository at this point in the history
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é <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
  • Loading branch information
philmd authored and jasowang committed Mar 31, 2020
1 parent b8c4b67 commit 767cc9a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion hw/net/allwinner-sun8i-emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions hw/net/can/can_sja1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion hw/net/can/can_sja1000.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/net/can_emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions net/can/can_socketcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 767cc9a

Please sign in to comment.