Skip to content

Commit ca6e25a

Browse files
erwangojhedberg
authored andcommitted
drivers: ethernet: Move back hal_init_v2 to driver init
Since phy init is not in this function anymore, it can be moved back to driver initialization function. While I'm at, harmonize v1/v2 flavors of the function. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 03eafc5 commit ca6e25a

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

drivers/ethernet/eth_stm32_hal_common.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,11 @@ static int eth_initialize(const struct device *dev)
217217

218218
heth->Init.MACAddr = dev_data->mac_addr;
219219

220-
#if defined(CONFIG_ETH_STM32_HAL_API_V1)
221220
ret = eth_stm32_hal_init(dev);
222221
if (ret) {
223222
LOG_ERR("Failed to initialize HAL");
224223
return -EIO;
225224
}
226-
#endif /* !CONFIG_ETH_STM32_HAL_API_V1 */
227225

228226
LOG_DBG("MAC %02x:%02x:%02x:%02x:%02x:%02x",
229227
dev_data->mac_addr[0], dev_data->mac_addr[1],
@@ -325,14 +323,6 @@ static void eth_iface_init(struct net_if *iface)
325323

326324
ethernet_init(iface);
327325

328-
#if defined(CONFIG_ETH_STM32_HAL_API_V2)
329-
/* This function requires the Ethernet interface to be
330-
* properly initialized. In auto-negotiation mode, it reads the speed
331-
* and duplex settings to configure the driver accordingly.
332-
*/
333-
eth_stm32_hal_init(dev);
334-
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
335-
336326
eth_stm32_setup_mac_filter(heth);
337327

338328
net_if_carrier_off(iface);

drivers/ethernet/eth_stm32_hal_v1.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ int eth_stm32_hal_init(const struct device *dev)
190190
struct eth_stm32_hal_dev_data *dev_data = dev->data;
191191
ETH_HandleTypeDef *heth = &dev_data->heth;
192192
HAL_StatusTypeDef hal_ret = HAL_OK;
193-
int ret = 0;
194193

195194
if (!ETH_STM32_AUTO_NEGOTIATION_ENABLE) {
196195
struct phy_link_state state;
@@ -223,7 +222,7 @@ int eth_stm32_hal_init(const struct device *dev)
223222
HAL_ETH_DMARxDescListInit(heth, dma_rx_desc_tab,
224223
&dma_rx_buffer[0][0], ETH_RXBUFNB);
225224

226-
return ret;
225+
return 0;
227226
}
228227

229228
void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *state)

drivers/ethernet/eth_stm32_hal_v2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth)
476476

477477
int eth_stm32_hal_init(const struct device *dev)
478478
{
479-
HAL_StatusTypeDef hal_ret = HAL_OK;
480479
struct eth_stm32_hal_dev_data *dev_data = dev->data;
481480
ETH_HandleTypeDef *heth = &dev_data->heth;
481+
HAL_StatusTypeDef hal_ret = HAL_OK;
482482

483483
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32n6_ethernet)
484484
for (int ch = 0; ch < ETH_DMA_CH_CNT; ch++) {

0 commit comments

Comments
 (0)