Skip to content

Commit 0291682

Browse files
decsnyaescolar
authored andcommitted
drivers: nxp_enet: Remove unnecessary comments
Some comments in this driver are just redundant - the code spells out exactly what the comment says. And some comment blocks are just unnecessary to have. Finally, remove the TODO comment because this is flagged by static analysis and there are already tracking issues for the zero copy enhancement. Signed-off-by: Declan Snyder <[email protected]>
1 parent 9ac2ee9 commit 0291682

File tree

1 file changed

+15
-85
lines changed

1 file changed

+15
-85
lines changed

drivers/ethernet/eth_nxp_enet.c

Lines changed: 15 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* Copyright 2023 NXP
44
*
5-
* Inspiration from eth_mcux.c, which is:
5+
* Inspiration from eth_mcux.c, which was:
66
* Copyright (c) 2016-2017 ARM Ltd
77
* Copyright (c) 2016 Linaro Ltd
88
* Copyright (c) 2018 Intel Corporation
@@ -19,47 +19,35 @@
1919
#include <zephyr/logging/log.h>
2020
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
2121

22-
/*
23-
************
24-
* Includes *
25-
************
26-
*/
27-
2822
#include <zephyr/device.h>
2923
#include <zephyr/sys/util.h>
3024
#include <zephyr/kernel.h>
3125
#include <zephyr/sys/__assert.h>
26+
3227
#include <zephyr/net/net_pkt.h>
3328
#include <zephyr/net/net_if.h>
3429
#include <zephyr/net/ethernet.h>
30+
#include <zephyr/net/phy.h>
31+
#include <zephyr/net/mii.h>
3532
#include <ethernet/eth_stats.h>
33+
3634
#include <zephyr/drivers/pinctrl.h>
3735
#include <zephyr/drivers/clock_control.h>
38-
#include <zephyr/drivers/ethernet/eth_nxp_enet.h>
39-
#include <zephyr/dt-bindings/ethernet/nxp_enet.h>
40-
#include <zephyr/net/phy.h>
41-
#include <zephyr/net/mii.h>
36+
37+
#ifdef CONFIG_PTP_CLOCK
4238
#include <zephyr/drivers/ptp_clock.h>
43-
#if defined(CONFIG_NET_DSA)
44-
#include <zephyr/net/dsa.h>
4539
#endif
4640

47-
#include "fsl_enet.h"
41+
#ifdef CONFIG_NET_DSA
42+
#include <zephyr/net/dsa.h>
43+
#endif
4844

49-
/*
50-
***********
51-
* Defines *
52-
***********
53-
*/
45+
#include <zephyr/drivers/ethernet/eth_nxp_enet.h>
46+
#include <zephyr/dt-bindings/ethernet/nxp_enet.h>
47+
#include <fsl_enet.h>
5448

5549
#define RING_ID 0
5650

57-
/*
58-
*********************
59-
* Driver Structures *
60-
*********************
61-
*/
62-
6351
struct nxp_enet_mac_config {
6452
ENET_Type *base;
6553
const struct device *clock_dev;
@@ -92,31 +80,10 @@ struct nxp_enet_mac_data {
9280
struct k_sem ptp_ts_sem;
9381
struct k_mutex *ptp_mutex; /* created in PTP driver */
9482
#endif
95-
/* TODO: FIXME. This Ethernet frame sized buffer is used for
96-
* interfacing with MCUX. How it works is that hardware uses
97-
* DMA scatter buffers to receive a frame, and then public
98-
* MCUX call gathers them into this buffer (there's no other
99-
* public interface). All this happens only for this driver
100-
* to scatter this buffer again into Zephyr fragment buffers.
101-
* This is not efficient, but proper resolution of this issue
102-
* depends on introduction of zero-copy networking support
103-
* in Zephyr, and adding needed interface to MCUX (or
104-
* bypassing it and writing a more complex driver working
105-
* directly with hardware).
106-
*
107-
* Note that we do not copy FCS into this buffer thus the
108-
* size is 1514 bytes.
109-
*/
110-
uint8_t *tx_frame_buf; /* Max MTU + ethernet header */
111-
uint8_t *rx_frame_buf; /* Max MTU + ethernet header */
83+
uint8_t *tx_frame_buf;
84+
uint8_t *rx_frame_buf;
11285
};
11386

114-
/*
115-
********************
116-
* Helper Functions *
117-
********************
118-
*/
119-
12087
static inline struct net_if *get_iface(struct nxp_enet_mac_data *data)
12188
{
12289
return data->iface;
@@ -187,12 +154,6 @@ static const struct device *eth_nxp_enet_get_ptp_clock(const struct device *dev)
187154
}
188155
#endif /* CONFIG_PTP_CLOCK */
189156

190-
/*
191-
*********************************
192-
* Ethernet driver API Functions *
193-
*********************************
194-
*/
195-
196157
static int eth_nxp_enet_tx(const struct device *dev, struct net_pkt *pkt)
197158
{
198159
const struct nxp_enet_mac_config *config = dev->config;
@@ -207,7 +168,6 @@ static int eth_nxp_enet_tx(const struct device *dev, struct net_pkt *pkt)
207168
/* Enter critical section for TX frame buffer access */
208169
k_mutex_lock(&data->tx_frame_buf_mutex, K_FOREVER);
209170

210-
/* Read network packet from upper layer into frame buffer */
211171
ret = net_pkt_read(pkt, data->tx_frame_buf, total_len);
212172
if (ret) {
213173
k_sem_give(&data->tx_buf_sem);
@@ -321,12 +281,6 @@ static int eth_nxp_enet_set_config(const struct device *dev,
321281
return -ENOTSUP;
322282
}
323283

324-
/*
325-
*****************************
326-
* Ethernet RX Functionality *
327-
*****************************
328-
*/
329-
330284
static int eth_nxp_enet_rx(const struct device *dev)
331285
{
332286
const struct nxp_enet_mac_config *config = dev->config;
@@ -447,12 +401,6 @@ static void eth_nxp_enet_rx_thread(void *arg1, void *unused1, void *unused2)
447401
}
448402
}
449403

450-
/*
451-
****************************
452-
* PHY management functions *
453-
****************************
454-
*/
455-
456404
static int nxp_enet_phy_reset_and_configure(const struct device *phy)
457405
{
458406
int ret;
@@ -511,12 +459,6 @@ static int nxp_enet_phy_init(const struct device *dev)
511459
return ret;
512460
}
513461

514-
/*
515-
****************************
516-
* Callbacks and interrupts *
517-
****************************
518-
*/
519-
520462
void nxp_enet_driver_cb(const struct device *dev, enum nxp_enet_driver dev_type,
521463
enum nxp_enet_callback_reason event, void *data)
522464
{
@@ -599,12 +541,6 @@ static void eth_nxp_enet_isr(const struct device *dev)
599541
irq_unlock(irq_lock_key);
600542
}
601543

602-
/*
603-
******************
604-
* Initialization *
605-
******************
606-
*/
607-
608544
static int eth_nxp_enet_init(const struct device *dev)
609545
{
610546
struct nxp_enet_mac_data *data = dev->data;
@@ -618,7 +554,6 @@ static int eth_nxp_enet_init(const struct device *dev)
618554
return err;
619555
}
620556

621-
/* Initialize kernel objects */
622557
k_mutex_init(&data->rx_frame_buf_mutex);
623558
k_mutex_init(&data->tx_frame_buf_mutex);
624559
k_sem_init(&data->rx_thread_sem, 0, CONFIG_ETH_NXP_ENET_RX_BUFFERS);
@@ -640,14 +575,12 @@ static int eth_nxp_enet_init(const struct device *dev)
640575
0, K_NO_WAIT);
641576
k_thread_name_set(&data->rx_thread, "eth_nxp_enet_rx");
642577

643-
/* Get ENET IP module clock rate */
644578
err = clock_control_get_rate(config->clock_dev, config->clock_subsys,
645579
&enet_module_clock_rate);
646580
if (err) {
647581
return err;
648582
}
649583

650-
/* Use HAL to set up MAC configuration */
651584
ENET_GetDefaultConfig(&enet_config);
652585

653586
if (IS_ENABLED(CONFIG_NET_PROMISCUOUS_MODE)) {
@@ -930,9 +863,6 @@ static const struct ethernet_api api_funcs = {
930863

931864
DT_INST_FOREACH_STATUS_OKAY(NXP_ENET_MAC_INIT)
932865

933-
/*
934-
* ENET module-level management
935-
*/
936866
#undef DT_DRV_COMPAT
937867
#define DT_DRV_COMPAT nxp_enet
938868

0 commit comments

Comments
 (0)