@@ -326,7 +326,7 @@ void HAL_ETH_TxPtpCallback(uint32_t *buff, ETH_TimeStampTypeDef *timestamp)
326
326
static int eth_tx (const struct device * dev , struct net_pkt * pkt )
327
327
{
328
328
struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
329
- ETH_HandleTypeDef * heth ;
329
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
330
330
int res ;
331
331
size_t total_len ;
332
332
#if defined(CONFIG_ETH_STM32_HAL_API_V2 )
@@ -344,10 +344,6 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
344
344
345
345
__ASSERT_NO_MSG (pkt != NULL );
346
346
__ASSERT_NO_MSG (pkt -> frags != NULL );
347
- __ASSERT_NO_MSG (dev != NULL );
348
- __ASSERT_NO_MSG (dev_data != NULL );
349
-
350
- heth = & dev_data -> heth ;
351
347
352
348
total_len = net_pkt_get_len (pkt );
353
349
if (total_len > (ETH_STM32_TX_BUF_SIZE * ETH_TXBUFNB )) {
@@ -518,8 +514,8 @@ static struct net_if *get_iface(struct eth_stm32_hal_dev_data *ctx)
518
514
519
515
static struct net_pkt * eth_rx (const struct device * dev )
520
516
{
521
- struct eth_stm32_hal_dev_data * dev_data ;
522
- ETH_HandleTypeDef * heth ;
517
+ struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
518
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
523
519
struct net_pkt * pkt ;
524
520
size_t total_len = 0 ;
525
521
#if defined(CONFIG_ETH_STM32_HAL_API_V2 )
@@ -538,14 +534,6 @@ static struct net_pkt *eth_rx(const struct device *dev)
538
534
timestamp .nanosecond = UINT32_MAX ;
539
535
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
540
536
541
- __ASSERT_NO_MSG (dev != NULL );
542
-
543
- dev_data = dev -> data ;
544
-
545
- __ASSERT_NO_MSG (dev_data != NULL );
546
-
547
- heth = & dev_data -> heth ;
548
-
549
537
#if defined(CONFIG_ETH_STM32_HAL_API_V2 )
550
538
if (HAL_ETH_ReadData (heth , & appbuf ) != HAL_OK ) {
551
539
/* no frame available */
@@ -657,21 +645,15 @@ static struct net_pkt *eth_rx(const struct device *dev)
657
645
658
646
static void rx_thread (void * arg1 , void * unused1 , void * unused2 )
659
647
{
660
- const struct device * dev ;
661
- struct eth_stm32_hal_dev_data * dev_data ;
648
+ const struct device * dev = ( const struct device * ) arg1 ;
649
+ struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
662
650
struct net_if * iface ;
663
651
struct net_pkt * pkt ;
664
652
int res ;
665
653
666
- __ASSERT_NO_MSG (arg1 != NULL );
667
654
ARG_UNUSED (unused1 );
668
655
ARG_UNUSED (unused2 );
669
656
670
- dev = (const struct device * )arg1 ;
671
- dev_data = dev -> data ;
672
-
673
- __ASSERT_NO_MSG (dev_data != NULL );
674
-
675
657
while (1 ) {
676
658
res = k_sem_take (& dev_data -> rx_int_sem , K_FOREVER );
677
659
if (res == 0 ) {
@@ -696,18 +678,8 @@ static void rx_thread(void *arg1, void *unused1, void *unused2)
696
678
697
679
static void eth_isr (const struct device * dev )
698
680
{
699
- struct eth_stm32_hal_dev_data * dev_data ;
700
- ETH_HandleTypeDef * heth ;
701
-
702
- __ASSERT_NO_MSG (dev != NULL );
703
-
704
- dev_data = dev -> data ;
705
-
706
- __ASSERT_NO_MSG (dev_data != NULL );
707
-
708
- heth = & dev_data -> heth ;
709
-
710
- __ASSERT_NO_MSG (heth != NULL );
681
+ struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
682
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
711
683
712
684
HAL_ETH_IRQHandler (heth );
713
685
}
@@ -966,13 +938,11 @@ static int eth_initialize(const struct device *dev)
966
938
static void eth_stm32_mcast_filter (const struct device * dev , const struct ethernet_filter * filter )
967
939
{
968
940
struct eth_stm32_hal_dev_data * dev_data = (struct eth_stm32_hal_dev_data * )dev -> data ;
969
- ETH_HandleTypeDef * heth ;
941
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
970
942
uint32_t crc ;
971
943
uint32_t hash_table [2 ];
972
944
uint32_t hash_index ;
973
945
974
- heth = & dev_data -> heth ;
975
-
976
946
crc = __RBIT (crc32_ieee (filter -> mac_address .addr , sizeof (struct net_eth_addr )));
977
947
hash_index = (crc >> 26 ) & 0x3f ;
978
948
@@ -1016,11 +986,8 @@ static void eth_stm32_mcast_filter(const struct device *dev, const struct ethern
1016
986
static int eth_init_api_v2 (const struct device * dev )
1017
987
{
1018
988
HAL_StatusTypeDef hal_ret = HAL_OK ;
1019
- struct eth_stm32_hal_dev_data * dev_data ;
1020
- ETH_HandleTypeDef * heth ;
1021
-
1022
- dev_data = dev -> data ;
1023
- heth = & dev_data -> heth ;
989
+ struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
990
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
1024
991
1025
992
#if DT_HAS_COMPAT_STATUS_OKAY (st_stm32n6_ethernet )
1026
993
for (int ch = 0 ; ch < ETH_DMA_CH_CNT ; ch ++ ) {
@@ -1173,21 +1140,10 @@ static void phy_link_state_changed(const struct device *phy_dev, struct phy_link
1173
1140
1174
1141
static void eth_iface_init (struct net_if * iface )
1175
1142
{
1176
- const struct device * dev ;
1177
- struct eth_stm32_hal_dev_data * dev_data ;
1143
+ const struct device * dev = net_if_get_device (iface );
1144
+ struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
1145
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
1178
1146
bool is_first_init = false;
1179
- ETH_HandleTypeDef * heth ;
1180
-
1181
- __ASSERT_NO_MSG (iface != NULL );
1182
-
1183
- dev = net_if_get_device (iface );
1184
- __ASSERT_NO_MSG (dev != NULL );
1185
-
1186
- dev_data = dev -> data ;
1187
- __ASSERT_NO_MSG (dev_data != NULL );
1188
-
1189
- heth = & dev_data -> heth ;
1190
- __ASSERT_NO_MSG (heth != NULL );
1191
1147
1192
1148
if (dev_data -> iface == NULL ) {
1193
1149
dev_data -> iface = iface ;
@@ -1277,21 +1233,16 @@ static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(const struct device
1277
1233
static int eth_stm32_hal_get_config (const struct device * dev , enum ethernet_config_type type ,
1278
1234
struct ethernet_config * config )
1279
1235
{
1280
- int ret = - ENOTSUP ;
1281
- struct eth_stm32_hal_dev_data * dev_data ;
1282
- ETH_HandleTypeDef * heth ;
1283
-
1284
- dev_data = dev -> data ;
1285
- heth = & dev_data -> heth ;
1236
+ struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
1286
1237
1287
1238
switch (type ) {
1288
1239
case ETHERNET_CONFIG_TYPE_MAC_ADDRESS :
1289
1240
memcpy (config -> mac_address .addr , dev_data -> mac_addr ,
1290
1241
sizeof (config -> mac_address .addr ));
1291
- ret = 0 ;
1292
- break ;
1293
- case ETHERNET_CONFIG_TYPE_PROMISC_MODE :
1242
+ return 0 ;
1294
1243
#if defined(CONFIG_NET_PROMISCUOUS_MODE )
1244
+ case ETHERNET_CONFIG_TYPE_PROMISC_MODE :
1245
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
1295
1246
#if defined(CONFIG_ETH_STM32_HAL_API_V2 )
1296
1247
ETH_MACFilterConfigTypeDef MACFilterConf ;
1297
1248
@@ -1305,26 +1256,21 @@ static int eth_stm32_hal_get_config(const struct device *dev, enum ethernet_conf
1305
1256
config -> promisc_mode = false;
1306
1257
}
1307
1258
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
1308
- ret = 0 ;
1259
+ return 0 ;
1309
1260
#endif /* CONFIG_NET_PROMISCUOUS_MODE */
1310
- break ;
1311
1261
default :
1312
1262
break ;
1313
1263
}
1314
1264
1315
- return ret ;
1265
+ return - ENOTSUP ;
1316
1266
}
1317
1267
1318
1268
static int eth_stm32_hal_set_config (const struct device * dev ,
1319
1269
enum ethernet_config_type type ,
1320
1270
const struct ethernet_config * config )
1321
1271
{
1322
- int ret = - ENOTSUP ;
1323
- struct eth_stm32_hal_dev_data * dev_data ;
1324
- ETH_HandleTypeDef * heth ;
1325
-
1326
- dev_data = dev -> data ;
1327
- heth = & dev_data -> heth ;
1272
+ struct eth_stm32_hal_dev_data * dev_data = dev -> data ;
1273
+ ETH_HandleTypeDef * heth = & dev_data -> heth ;
1328
1274
1329
1275
switch (type ) {
1330
1276
case ETHERNET_CONFIG_TYPE_MAC_ADDRESS :
@@ -1338,10 +1284,9 @@ static int eth_stm32_hal_set_config(const struct device *dev,
1338
1284
net_if_set_link_addr (dev_data -> iface , dev_data -> mac_addr ,
1339
1285
sizeof (dev_data -> mac_addr ),
1340
1286
NET_LINK_ETHERNET );
1341
- ret = 0 ;
1342
- break ;
1343
- case ETHERNET_CONFIG_TYPE_PROMISC_MODE :
1287
+ return 0 ;
1344
1288
#if defined(CONFIG_NET_PROMISCUOUS_MODE )
1289
+ case ETHERNET_CONFIG_TYPE_PROMISC_MODE :
1345
1290
#if defined(CONFIG_ETH_STM32_HAL_API_V2 )
1346
1291
ETH_MACFilterConfigTypeDef MACFilterConf ;
1347
1292
@@ -1357,19 +1302,18 @@ static int eth_stm32_hal_set_config(const struct device *dev,
1357
1302
heth -> Instance -> MACFFR &= ~ETH_MACFFR_PM ;
1358
1303
}
1359
1304
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
1360
- ret = 0 ;
1305
+ return 0 ;
1361
1306
#endif /* CONFIG_NET_PROMISCUOUS_MODE */
1362
- break ;
1363
1307
#if defined(CONFIG_ETH_STM32_MULTICAST_FILTER )
1364
1308
case ETHERNET_CONFIG_TYPE_FILTER :
1365
1309
eth_stm32_mcast_filter (dev , & config -> filter );
1366
- break ;
1310
+ return 0 ;
1367
1311
#endif /* CONFIG_ETH_STM32_MULTICAST_FILTER */
1368
1312
default :
1369
1313
break ;
1370
1314
}
1371
1315
1372
- return ret ;
1316
+ return - ENOTSUP ;
1373
1317
}
1374
1318
1375
1319
static const struct device * eth_stm32_hal_get_phy (const struct device * dev )
0 commit comments