cpufreq/amd-pstate: Fix per-policy boost flag incorrect when fail
[pf-kernel.git] / drivers / net / can / slcan / slcan-ethtool.c
blobf598c653fbfaf7d3b64e9eee023cf73d37929ca8
1 // SPDX-License-Identifier: GPL-2.0+
2 /* Copyright (c) 2022 Amarula Solutions, Dario Binacchi <dario.binacchi@amarulasolutions.com>
4 */
6 #include <linux/can/dev.h>
7 #include <linux/ethtool.h>
8 #include <linux/kernel.h>
9 #include <linux/netdevice.h>
10 #include <linux/platform_device.h>
12 #include "slcan.h"
14 static const char slcan_priv_flags_strings[][ETH_GSTRING_LEN] = {
15 #define SLCAN_PRIV_FLAGS_ERR_RST_ON_OPEN BIT(0)
16 "err-rst-on-open",
19 static void slcan_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
21 switch (stringset) {
22 case ETH_SS_PRIV_FLAGS:
23 memcpy(data, slcan_priv_flags_strings,
24 sizeof(slcan_priv_flags_strings));
28 static u32 slcan_get_priv_flags(struct net_device *ndev)
30 u32 flags = 0;
32 if (slcan_err_rst_on_open(ndev))
33 flags |= SLCAN_PRIV_FLAGS_ERR_RST_ON_OPEN;
35 return flags;
38 static int slcan_set_priv_flags(struct net_device *ndev, u32 flags)
40 bool err_rst_op_open = !!(flags & SLCAN_PRIV_FLAGS_ERR_RST_ON_OPEN);
42 return slcan_enable_err_rst_on_open(ndev, err_rst_op_open);
45 static int slcan_get_sset_count(struct net_device *netdev, int sset)
47 switch (sset) {
48 case ETH_SS_PRIV_FLAGS:
49 return ARRAY_SIZE(slcan_priv_flags_strings);
50 default:
51 return -EOPNOTSUPP;
55 const struct ethtool_ops slcan_ethtool_ops = {
56 .get_strings = slcan_get_strings,
57 .get_priv_flags = slcan_get_priv_flags,
58 .set_priv_flags = slcan_set_priv_flags,
59 .get_sset_count = slcan_get_sset_count,
60 .get_ts_info = ethtool_op_get_ts_info,