Skip to content

Commit 967f554

Browse files
erwangojhedberg
authored andcommitted
drivers: ethernet: stm32: Rename functions that are not static anymore
To be able to split code, some functions were removed their static attribute, which opens the possibility of name conflict. Rename them by adding eth_stm32_ prefix. Additionally, review their sorting in the header file. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent d1d1e57 commit 967f554

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

drivers/ethernet/eth_stm32_hal_common.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ETH_DMADescTypeDef dma_tx_desc_tab[ETH_TXBUFNB] __eth_stm32_desc;
6161

6262
const struct device *eth_stm32_phy_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, phy_handle));
6363

64-
struct net_if *get_iface(struct eth_stm32_hal_dev_data *ctx)
64+
struct net_if *eth_stm32_get_iface(struct eth_stm32_hal_dev_data *ctx)
6565
{
6666
return ctx->iface;
6767
}
@@ -81,7 +81,7 @@ static void rx_thread(void *arg1, void *unused1, void *unused2)
8181
res = k_sem_take(&dev_data->rx_int_sem, K_FOREVER);
8282
if (res == 0) {
8383
/* semaphore taken and receive packets */
84-
while ((pkt = eth_rx(dev)) != NULL) {
84+
while ((pkt = eth_stm32_rx(dev)) != NULL) {
8585
iface = net_pkt_iface(pkt);
8686
#if defined(CONFIG_NET_DSA_DEPRECATED)
8787
iface = dsa_net_recv(iface, &pkt);
@@ -223,7 +223,7 @@ static int eth_initialize(const struct device *dev)
223223
heth->Init.MACAddr = dev_data->mac_addr;
224224

225225
#if defined(CONFIG_ETH_STM32_HAL_API_V1)
226-
ret = eth_hal_init(dev);
226+
ret = eth_stm32_hal_init(dev);
227227
if (ret) {
228228
LOG_ERR("Failed to initialize HAL");
229229
return -EIO;
@@ -299,7 +299,7 @@ static void phy_link_state_changed(const struct device *phy_dev, struct phy_link
299299
*/
300300
eth_stm32_hal_stop(dev);
301301
if (state->is_up) {
302-
set_mac_config(dev, state);
302+
eth_stm32_set_mac_config(dev, state);
303303
eth_stm32_hal_start(dev);
304304
net_eth_carrier_on(dev_data->iface);
305305
} else {
@@ -325,7 +325,7 @@ static void eth_iface_init(struct net_if *iface)
325325
NET_LINK_ETHERNET);
326326

327327
#if defined(CONFIG_NET_DSA_DEPRECATED)
328-
dsa_register_master_tx(iface, &eth_tx);
328+
dsa_register_master_tx(iface, &eth_stm32_tx);
329329
#endif
330330

331331
ethernet_init(iface);
@@ -335,10 +335,10 @@ static void eth_iface_init(struct net_if *iface)
335335
* properly initialized. In auto-negotiation mode, it reads the speed
336336
* and duplex settings to configure the driver accordingly.
337337
*/
338-
eth_hal_init(dev);
338+
eth_stm32_hal_init(dev);
339339
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
340340

341-
setup_mac_filter(heth);
341+
eth_stm32_setup_mac_filter(heth);
342342

343343
net_if_carrier_off(iface);
344344

@@ -425,7 +425,7 @@ static const struct ethernet_api eth_api = {
425425
#if defined(CONFIG_NET_DSA_DEPRECATED)
426426
.send = dsa_tx,
427427
#else
428-
.send = eth_tx,
428+
.send = eth_stm32_tx,
429429
#endif
430430
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
431431
.get_stats = eth_stm32_hal_get_stats,

drivers/ethernet/eth_stm32_hal_priv.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818

1919
extern const struct device *eth_stm32_phy_dev;
2020

21-
#ifdef CONFIG_PTP_CLOCK_STM32_HAL
22-
const struct device *eth_stm32_get_ptp_clock(const struct device *dev);
23-
bool eth_is_ptp_pkt(struct net_if *iface, struct net_pkt *pkt);
24-
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
25-
2621
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_ethernet)
2722
#define IS_ETH_DMATXDESC_OWN(dma_tx_desc) (dma_tx_desc->DESC3 & ETH_DMATXNDESCRF_OWN)
2823
#define ETH_RXBUFNB ETH_RX_DESC_CNT
@@ -137,20 +132,26 @@ struct eth_stm32_hal_dev_data {
137132
#endif
138133
};
139134

140-
void setup_mac_filter(ETH_HandleTypeDef *heth);
141-
int eth_tx(const struct device *dev, struct net_pkt *pkt);
142-
struct net_pkt *eth_rx(const struct device *dev);
143-
int eth_hal_init(const struct device *dev);
144-
void set_mac_config(const struct device *dev, struct phy_link_state *state);
135+
void eth_stm32_setup_mac_filter(ETH_HandleTypeDef *heth);
136+
void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *state);
137+
int eth_stm32_tx(const struct device *dev, struct net_pkt *pkt);
138+
struct net_pkt *eth_stm32_rx(const struct device *dev);
139+
int eth_stm32_hal_init(const struct device *dev);
145140
int eth_stm32_hal_start(const struct device *dev);
146141
int eth_stm32_hal_stop(const struct device *dev);
147142
int eth_stm32_hal_set_config(const struct device *dev,
148143
enum ethernet_config_type type,
149144
const struct ethernet_config *config);
150-
struct net_if *get_iface(struct eth_stm32_hal_dev_data *ctx);
145+
struct net_if *eth_stm32_get_iface(struct eth_stm32_hal_dev_data *ctx);
146+
151147
#if defined(CONFIG_ETH_STM32_MULTICAST_FILTER)
152148
void eth_stm32_mcast_filter(const struct device *dev,
153149
const struct ethernet_filter *filter);
154150
#endif /* CONFIG_ETH_STM32_MULTICAST_FILTER */
155151

152+
#ifdef CONFIG_PTP_CLOCK_STM32_HAL
153+
const struct device *eth_stm32_get_ptp_clock(const struct device *dev);
154+
bool eth_stm32_is_ptp_pkt(struct net_if *iface, struct net_pkt *pkt);
155+
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
156+
156157
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_ */

drivers/ethernet/eth_stm32_hal_ptp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ LOG_MODULE_REGISTER(eth_stm32_hal_ptp, CONFIG_ETHERNET_LOG_LEVEL);
2929
#define ETH_STM32_PTP_NOT_CONFIGURED HAL_ETH_PTP_NOT_CONFIGURED
3030
#endif /* stm32F7x or sm32F4x */
3131

32-
bool eth_is_ptp_pkt(struct net_if *iface, struct net_pkt *pkt)
32+
bool eth_stm32_is_ptp_pkt(struct net_if *iface, struct net_pkt *pkt)
3333
{
3434
if (ntohs(NET_ETH_HDR(pkt)->type) != NET_ETH_PTYPE_PTP) {
3535
return false;

drivers/ethernet/eth_stm32_hal_v1.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
LOG_MODULE_DECLARE(eth_stm32_hal, CONFIG_ETHERNET_LOG_LEVEL);
2828

29-
void setup_mac_filter(ETH_HandleTypeDef *heth)
29+
void eth_stm32_setup_mac_filter(ETH_HandleTypeDef *heth)
3030
{
3131
__ASSERT_NO_MSG(heth != NULL);
3232
uint32_t tmp = heth->Instance->MACFFR;
@@ -55,7 +55,7 @@ void setup_mac_filter(ETH_HandleTypeDef *heth)
5555
heth->Instance->MACFFR = tmp;
5656
}
5757

58-
int eth_tx(const struct device *dev, struct net_pkt *pkt)
58+
int eth_stm32_tx(const struct device *dev, struct net_pkt *pkt)
5959
{
6060
struct eth_stm32_hal_dev_data *dev_data = dev->data;
6161
ETH_HandleTypeDef *heth = &dev_data->heth;
@@ -116,7 +116,7 @@ int eth_tx(const struct device *dev, struct net_pkt *pkt)
116116
return res;
117117
}
118118

119-
struct net_pkt *eth_rx(const struct device *dev)
119+
struct net_pkt *eth_stm32_rx(const struct device *dev)
120120
{
121121
struct eth_stm32_hal_dev_data *dev_data = dev->data;
122122
ETH_HandleTypeDef *heth = &dev_data->heth;
@@ -135,7 +135,7 @@ struct net_pkt *eth_rx(const struct device *dev)
135135
total_len = heth->RxFrameInfos.length;
136136
dma_buffer = (uint8_t *)heth->RxFrameInfos.buffer;
137137

138-
pkt = net_pkt_rx_alloc_with_buffer(get_iface(dev_data),
138+
pkt = net_pkt_rx_alloc_with_buffer(eth_stm32_get_iface(dev_data),
139139
total_len, AF_UNSPEC, 0, K_MSEC(100));
140140
if (!pkt) {
141141
LOG_ERR("Failed to obtain RX buffer");
@@ -179,13 +179,13 @@ struct net_pkt *eth_rx(const struct device *dev)
179179

180180
out:
181181
if (!pkt) {
182-
eth_stats_update_errors_rx(get_iface(dev_data));
182+
eth_stats_update_errors_rx(eth_stm32_get_iface(dev_data));
183183
}
184184

185185
return pkt;
186186
}
187187

188-
int eth_hal_init(const struct device *dev)
188+
int eth_stm32_hal_init(const struct device *dev)
189189
{
190190
struct eth_stm32_hal_dev_data *dev_data = dev->data;
191191
ETH_HandleTypeDef *heth = &dev_data->heth;
@@ -226,7 +226,7 @@ int eth_hal_init(const struct device *dev)
226226
return ret;
227227
}
228228

229-
void set_mac_config(const struct device *dev, struct phy_link_state *state)
229+
void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *state)
230230
{
231231
struct eth_stm32_hal_dev_data *dev_data = dev->data;
232232
ETH_HandleTypeDef *heth = &dev_data->heth;

drivers/ethernet/eth_stm32_hal_v2.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static inline struct eth_stm32_tx_context *allocate_tx_context(struct net_pkt *p
144144
}
145145
}
146146

147-
void setup_mac_filter(ETH_HandleTypeDef *heth)
147+
void eth_stm32_setup_mac_filter(ETH_HandleTypeDef *heth)
148148
{
149149
__ASSERT_NO_MSG(heth != NULL);
150150
ETH_MACFilterConfigTypeDef MACFilterConf;
@@ -162,7 +162,7 @@ void setup_mac_filter(ETH_HandleTypeDef *heth)
162162
k_sleep(K_MSEC(1));
163163
}
164164

165-
int eth_tx(const struct device *dev, struct net_pkt *pkt)
165+
int eth_stm32_tx(const struct device *dev, struct net_pkt *pkt)
166166
{
167167
struct eth_stm32_hal_dev_data *dev_data = dev->data;
168168
ETH_HandleTypeDef *heth = &dev_data->heth;
@@ -191,7 +191,7 @@ int eth_tx(const struct device *dev, struct net_pkt *pkt)
191191
buf_header = &dma_tx_buffer_header[ctx->first_tx_buffer_index];
192192

193193
#if defined(CONFIG_PTP_CLOCK_STM32_HAL)
194-
timestamped_frame = eth_is_ptp_pkt(net_pkt_iface(pkt), pkt) ||
194+
timestamped_frame = eth_stm32_is_ptp_pkt(net_pkt_iface(pkt), pkt) ||
195195
net_pkt_is_tx_timestamping(pkt);
196196
if (timestamped_frame) {
197197
/* Enable transmit timestamp */
@@ -299,7 +299,7 @@ int eth_tx(const struct device *dev, struct net_pkt *pkt)
299299
return res;
300300
}
301301

302-
struct net_pkt *eth_rx(const struct device *dev)
302+
struct net_pkt *eth_stm32_rx(const struct device *dev)
303303
{
304304
struct eth_stm32_hal_dev_data *dev_data = dev->data;
305305
ETH_HandleTypeDef *heth = &dev_data->heth;
@@ -334,7 +334,7 @@ struct net_pkt *eth_rx(const struct device *dev)
334334
}
335335
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
336336

337-
pkt = net_pkt_rx_alloc_with_buffer(get_iface(dev_data),
337+
pkt = net_pkt_rx_alloc_with_buffer(eth_stm32_get_iface(dev_data),
338338
total_len, AF_UNSPEC, 0, K_MSEC(100));
339339
if (!pkt) {
340340
LOG_ERR("Failed to obtain RX buffer");
@@ -374,7 +374,7 @@ struct net_pkt *eth_rx(const struct device *dev)
374374

375375
out:
376376
if (!pkt) {
377-
eth_stats_update_errors_rx(get_iface(dev_data));
377+
eth_stats_update_errors_rx(eth_stm32_get_iface(dev_data));
378378
}
379379

380380
return pkt;
@@ -474,7 +474,7 @@ void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth)
474474
#endif /* CONFIG_NET_STATISTICS_ETHERNET */
475475
}
476476

477-
int eth_hal_init(const struct device *dev)
477+
int eth_stm32_hal_init(const struct device *dev)
478478
{
479479
HAL_StatusTypeDef hal_ret = HAL_OK;
480480
struct eth_stm32_hal_dev_data *dev_data = dev->data;
@@ -534,7 +534,7 @@ int eth_hal_init(const struct device *dev)
534534
return 0;
535535
}
536536

537-
void set_mac_config(const struct device *dev, struct phy_link_state *state)
537+
void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *state)
538538
{
539539
struct eth_stm32_hal_dev_data *dev_data = dev->data;
540540
ETH_HandleTypeDef *heth = &dev_data->heth;

0 commit comments

Comments
 (0)