From 7f3507b606b0f5c0c44cc59eb27e87575cf87701 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sat, 26 Oct 2024 02:58:42 -0600 Subject: conventions: Don't have 2 ways to spell "implements_foo" Stop defining "struct foo" as a synonym for "implements_foo". --- cmd/sbc_harness/hw/rp2040_hwspi.c | 2 +- cmd/sbc_harness/hw/rp2040_hwspi.h | 2 +- cmd/sbc_harness/hw/spi.h | 12 ++++++------ cmd/sbc_harness/hw/w5500.c | 2 +- cmd/sbc_harness/hw/w5500.h | 4 ++-- cmd/srv9p/gnet.c | 12 ++++++------ cmd/srv9p/static9p.h | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) (limited to 'cmd') diff --git a/cmd/sbc_harness/hw/rp2040_hwspi.c b/cmd/sbc_harness/hw/rp2040_hwspi.c index dd9a577..6742c60 100644 --- a/cmd/sbc_harness/hw/rp2040_hwspi.c +++ b/cmd/sbc_harness/hw/rp2040_hwspi.c @@ -1,4 +1,4 @@ -/* hw/rp2040_hwspi.c - `struct spi` implementation for the RP2040's +/* hw/rp2040_hwspi.c - `implements_spi` implementation for the RP2040's * ARM Primecell SSP (PL022) (implementation file) * * Copyright (C) 2024 Luke T. Shumaker diff --git a/cmd/sbc_harness/hw/rp2040_hwspi.h b/cmd/sbc_harness/hw/rp2040_hwspi.h index 8bf783f..8cf8aff 100644 --- a/cmd/sbc_harness/hw/rp2040_hwspi.h +++ b/cmd/sbc_harness/hw/rp2040_hwspi.h @@ -1,4 +1,4 @@ -/* hw/rp2040_hwspi.h - `struct spi` implementation for the RP2040's +/* hw/rp2040_hwspi.h - `implements_spi` implementation for the RP2040's * ARM Primecell SSP (PL022) (header file) * * Copyright (C) 2024 Luke T. Shumaker diff --git a/cmd/sbc_harness/hw/spi.h b/cmd/sbc_harness/hw/spi.h index 653e80f..da588de 100644 --- a/cmd/sbc_harness/hw/spi.h +++ b/cmd/sbc_harness/hw/spi.h @@ -22,7 +22,11 @@ struct bidi_iovec { size_t iov_len; }; -struct spi; +struct spi_vtable; + +typedef struct { + struct spi_vtable *vtable; +} implements_spi; /* This API assumes that an SPI frame is a multiple of 8-bits. * @@ -37,11 +41,7 @@ struct spi; * non-multiple-of-8 number of bits. */ struct spi_vtable { - void (*readwritev)(struct spi *, const struct bidi_iovec *iov, int iovcnt); + void (*readwritev)(implements_spi *, const struct bidi_iovec *iov, int iovcnt); }; -typedef struct spi { - struct spi_vtable *vtable; -} implements_spi; - #endif /* _HW_SPI_H_ */ diff --git a/cmd/sbc_harness/hw/w5500.c b/cmd/sbc_harness/hw/w5500.c index a6cdc8b..5e36bcf 100644 --- a/cmd/sbc_harness/hw/w5500.c +++ b/cmd/sbc_harness/hw/w5500.c @@ -170,7 +170,7 @@ static void w5500_intrhandler(uint gpio, uint32_t UNUSED(event_mask)) { } void _w5500_init(struct w5500 *chip, - struct spi* spi, uint pin_intr, uint pin_reset, + implements_spi *spi, uint pin_intr, uint pin_reset, struct net_eth_addr addr) { assert(chip); assert(spi); diff --git a/cmd/sbc_harness/hw/w5500.h b/cmd/sbc_harness/hw/w5500.h index 1b485dd..2ff04df 100644 --- a/cmd/sbc_harness/hw/w5500.h +++ b/cmd/sbc_harness/hw/w5500.h @@ -35,7 +35,7 @@ struct _w5500_tcp_listener { struct w5500 { /* const-after-init */ - struct spi *spidev; + implements_spi *spidev; uint pin_intr; uint pin_reset; struct net_eth_addr hwaddr; @@ -66,7 +66,7 @@ struct w5500 { _w5500_init(self, spi, pin_intr, pin_reset, eth_addr); \ } while (0) void _w5500_init(struct w5500 *self, - struct spi* spi, uint pin_intr, uint pin_reset, + implements_spi *spi, uint pin_intr, uint pin_reset, struct net_eth_addr addr); /** diff --git a/cmd/srv9p/gnet.c b/cmd/srv9p/gnet.c index 699deaf..f1ea709 100644 --- a/cmd/srv9p/gnet.c +++ b/cmd/srv9p/gnet.c @@ -280,11 +280,11 @@ static int gnet_tcp_close(implements_net_stream_conn *_conn, bool rd, bool wr) { /* UDP init() *****************************************************************/ -static ssize_t gnet_udp_sendto(struct net_packet_conn *self, void *buf, size_t len, +static ssize_t gnet_udp_sendto(implements_net_packet_conn *self, void *buf, size_t len, struct net_ip4_addr addr, uint16_t port); -static ssize_t gnet_udp_recvfrom(struct net_packet_conn *self, void *buf, size_t len, +static ssize_t gnet_udp_recvfrom(implements_net_packet_conn *self, void *buf, size_t len, struct net_ip4_addr *ret_addr, uint16_t *ret_port); -static int gnet_udp_close(struct net_packet_conn *self); +static int gnet_udp_close(implements_net_packet_conn *self); static struct net_packet_conn_vtable gnet_udp_conn_vtable = { .sendto = gnet_udp_sendto, @@ -351,7 +351,7 @@ static void *gnet_pthread_sendto(void *_args) { return NULL; } -static ssize_t gnet_udp_sendto(struct net_packet_conn *_conn, void *buf, size_t count, +static ssize_t gnet_udp_sendto(implements_net_packet_conn *_conn, void *buf, size_t count, struct net_ip4_addr node, uint16_t port) { struct gnet_udp_conn *conn = VCALL_SELF(struct gnet_udp_conn, implements_net_packet_conn, _conn); @@ -418,7 +418,7 @@ static void *gnet_pthread_recvfrom(void *_args) { return NULL; } -static ssize_t gnet_udp_recvfrom(struct net_packet_conn *_conn, void *buf, size_t count, +static ssize_t gnet_udp_recvfrom(implements_net_packet_conn *_conn, void *buf, size_t count, struct net_ip4_addr *ret_node, uint16_t *ret_port) { struct gnet_udp_conn *conn = VCALL_SELF(struct gnet_udp_conn, implements_net_packet_conn, _conn); @@ -444,7 +444,7 @@ static ssize_t gnet_udp_recvfrom(struct net_packet_conn *_conn, void *buf, size_ /* UDP close() ****************************************************************/ -static int gnet_udp_close(struct net_packet_conn *_conn) { +static int gnet_udp_close(implements_net_packet_conn *_conn) { struct gnet_udp_conn *conn = VCALL_SELF(struct gnet_udp_conn, implements_net_packet_conn, _conn); assert(conn); diff --git a/cmd/srv9p/static9p.h b/cmd/srv9p/static9p.h index 98b85a2..e03a480 100644 --- a/cmd/srv9p/static9p.h +++ b/cmd/srv9p/static9p.h @@ -29,7 +29,7 @@ struct static_dir { _static_common; /* NULL-terminated */ - struct lib9p_srv_file *members[]; + implements_lib9p_srv_file *members[]; }; -- cgit v1.2.3-2-g168b