arch/arm/stm32: Fix Ethernet code style issues

Fixed all the issues reported by checkpatch.sh in stm32_eth_m3m4_v1.c,
stm32f7/stm32_ethernet.c, stm32h5/stm32_ethernet.c, stm32h7/stm32_ethernet.c

Signed-off-by: alexcekay <alexander@auterion.com>
This commit is contained in:
alexcekay 2026-08-27 16:52:59 +02:00 committed by Alan C. Assis
parent 6742f6328c
commit 8affe54985
4 changed files with 77 additions and 62 deletions

View file

@ -1717,7 +1717,7 @@ static void stm32_receive(struct stm32_ethmac_s *priv)
#ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev);
pkt_input(&priv->dev);
#endif
/* Check if the packet is a valid size for the network buffer
@ -2138,7 +2138,7 @@ static int stm32_interrupt(int irq, void *context, void *arg)
* expiration and the deferred interrupt processing.
*/
wd_cancel(&priv->txtimeout);
wd_cancel(&priv->txtimeout);
}
/* Schedule to perform the interrupt processing on the worker thread. */
@ -2277,6 +2277,7 @@ static int stm32_ifup(struct net_driver_s *dev)
/* Transfer time from system low-resolution timer to PTP basetime */
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
up_rtc_settime(&ts);
g_rtc_enabled = true;
@ -2336,6 +2337,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
/* Transfer back to system low-resolution timer */
struct timespec ts;
up_rtc_gettime(&ts);
g_rtc_enabled = false;
clock_settime(CLOCK_REALTIME, &ts);
@ -2832,6 +2834,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = CONFIG_STM32_PHYADDR;
ret = OK;
}
@ -2841,6 +2844,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out);
}
break;
@ -2849,6 +2853,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in);
}
break;
@ -3310,7 +3315,7 @@ static int stm32_phyinit(struct stm32_ethmac_s *priv)
ret = stm32_phywrite(CONFIG_STM32_PHYADDR, MII_MCR, phyval);
if (ret < 0)
{
nerr("ERROR: Failed to write the PHY MCR: %d\n", ret);
nerr("ERROR: Failed to write the PHY MCR: %d\n", ret);
return ret;
}
@ -3776,26 +3781,26 @@ static void stm32_eth_ptp_convert_rxtime(struct stm32_ethmac_s *priv)
&priv->dev.d_rxtime);
#else
{
struct timespec realtime;
uint64_t ptptime;
irqstate_t flags;
{
struct timespec realtime;
uint64_t ptptime;
irqstate_t flags;
/* Sample PTP and CLOCK_REALTIME close to each other */
/* Sample PTP and CLOCK_REALTIME close to each other */
clock_gettime(CLOCK_REALTIME, &realtime);
flags = spin_lock_irqsave(&g_rtc_lock);
ptptime = stm32_eth_ptp_gettime();
spin_unlock_irqrestore(&g_rtc_lock, flags);
clock_gettime(CLOCK_REALTIME, &realtime);
flags = spin_lock_irqsave(&g_rtc_lock);
ptptime = stm32_eth_ptp_gettime();
spin_unlock_irqrestore(&g_rtc_lock, flags);
/* Compute how much time has elapsed since packet reception
* and add that to current time.
*/
/* Compute how much time has elapsed since packet reception
* and add that to current time.
*/
timestamp = ptptime - timestamp;
ptp_to_timespec(timestamp, &rxtime);
clock_timespec_add(&rxtime, &realtime, &priv->dev.d_rxtime);
}
timestamp = ptptime - timestamp;
ptp_to_timespec(timestamp, &rxtime);
clock_timespec_add(&rxtime, &realtime, &priv->dev.d_rxtime);
}
#endif /* CONFIG_STM32_ETH_PTP_RTC_HIRES */
}
#endif /* CONFIG_STM32_ETH_TIMESTAMP_RX */

View file

@ -1763,7 +1763,7 @@ static void stm32_receive(struct stm32_ethmac_s *priv)
#ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev);
pkt_input(&priv->dev);
#endif
/* Check if the packet is a valid size for the network buffer
@ -2196,7 +2196,7 @@ static int stm32_interrupt(int irq, void *context, void *arg)
* expiration and the deferred interrupt processing.
*/
wd_cancel(&priv->txtimeout);
wd_cancel(&priv->txtimeout);
}
DEBUGASSERT(work_available(&priv->irqwork));
@ -2843,55 +2843,58 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
int ret;
switch (cmd)
{
{
#ifdef CONFIG_NETDEV_PHY_IOCTL
#ifdef CONFIG_ARCH_PHY_INTERRUPT
case SIOCMIINOTIFY: /* Set up for PHY event notifications */
{
struct mii_ioctl_notify_s *req =
(struct mii_ioctl_notify_s *)((uintptr_t)arg);
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
if (ret == OK)
case SIOCMIINOTIFY: /* Set up for PHY event notifications */
{
/* Enable PHY link up/down interrupts */
struct mii_ioctl_notify_s *req =
(struct mii_ioctl_notify_s *)((uintptr_t)arg);
ret = stm32_phyintenable(priv);
ret = phy_notify_subscribe(dev->d_ifname, req->pid, &req->event);
if (ret == OK)
{
/* Enable PHY link up/down interrupts */
ret = stm32_phyintenable(priv);
}
}
}
break;
break;
#endif
case SIOCGMIIPHY: /* Get MII PHY address */
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = CONFIG_STM32_PHYADDR;
ret = OK;
}
break;
case SIOCGMIIPHY: /* Get MII PHY address */
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
case SIOCGMIIREG: /* Get register from MII PHY */
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out);
}
break;
req->phy_id = CONFIG_STM32_PHYADDR;
ret = OK;
}
break;
case SIOCSMIIREG: /* Set register in MII PHY */
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in);
}
break;
case SIOCGMIIREG: /* Get register from MII PHY */
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out);
}
break;
case SIOCSMIIREG: /* Set register in MII PHY */
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in);
}
break;
#endif /* CONFIG_NETDEV_PHY_IOCTL */
default:
ret = -ENOTTY;
break;
}
default:
ret = -ENOTTY;
break;
}
return ret;
}
@ -3322,7 +3325,7 @@ static int stm32_phyinit(struct stm32_ethmac_s *priv)
ret = stm32_phywrite(CONFIG_STM32_PHYADDR, MII_MCR, phyval);
if (ret < 0)
{
nerr("ERROR: Failed to write the PHY MCR: %d\n", ret);
nerr("ERROR: Failed to write the PHY MCR: %d\n", ret);
return ret;
}

View file

@ -1711,6 +1711,7 @@ static int stm32_recvframe(struct stm32_ethmac_s *priv)
else
{
bool err = ((rxdesc->des3 & ETH_RDES3_WB_ES) != 0);
priv->segments++;
/* Check if there is only one segment in the frame */
@ -1895,7 +1896,7 @@ static void stm32_receive(struct stm32_ethmac_s *priv)
* tap
*/
pkt_input(&priv->dev);
pkt_input(&priv->dev);
#endif
/* Check if the packet is a valid size for the network buffer
@ -2995,6 +2996,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = CONFIG_STM32_PHYADDR;
ret = OK;
}
@ -3004,6 +3006,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out);
}
break;
@ -3012,6 +3015,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in,
0xffff);
}

View file

@ -1963,7 +1963,7 @@ static void stm32_receive(struct stm32_ethmac_s *priv)
* tap
*/
pkt_input(&priv->dev);
pkt_input(&priv->dev);
#endif
/* Check if the packet is a valid size for the network buffer
@ -3097,6 +3097,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
req->phy_id = CONFIG_STM32_PHYADDR;
ret = OK;
}
@ -3106,6 +3107,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = mdio_read(priv->mdio,
req->phy_id, req->reg_num, &req->val_out);
}
@ -3115,6 +3117,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg)
{
struct mii_ioctl_data_s *req =
(struct mii_ioctl_data_s *)((uintptr_t)arg);
ret = mdio_write(priv->mdio,
req->phy_id, req->reg_num, req->val_in);
}