zephyr/subsys/net/l2/ethernet/ethernet_stats.c
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00

56 lines
1.1 KiB
C

/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <logging/log.h>
LOG_MODULE_REGISTER(net_ethernet_stats, CONFIG_NET_L2_ETHERNET_LOG_LEVEL);
#include <kernel.h>
#include <string.h>
#include <errno.h>
#include <net/net_core.h>
#include <net/ethernet.h>
#include "net_stats.h"
#if defined(CONFIG_NET_STATISTICS_USER_API)
static int eth_stats_get(uint32_t mgmt_request, struct net_if *iface,
void *data, size_t len)
{
size_t len_chk = 0;
void *src = NULL;
const struct ethernet_api *eth;
switch (NET_MGMT_GET_COMMAND(mgmt_request)) {
case NET_REQUEST_STATS_CMD_GET_ETHERNET:
if (net_if_l2(iface) != &NET_L2_GET_NAME(ETHERNET)) {
return -ENOENT;
}
eth = net_if_get_device(iface)->api;
if (eth == NULL || eth->get_stats == NULL) {
return -ENOENT;
}
len_chk = sizeof(struct net_stats_eth);
src = eth->get_stats(net_if_get_device(iface));
break;
}
if (len != len_chk || !src) {
return -EINVAL;
}
memcpy(data, src, len);
return 0;
}
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_GET_ETHERNET,
eth_stats_get);
#endif /* CONFIG_NET_STATISTICS_USER_API */