Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: hns3: use string choices helper

Use string choices helper for better readability.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250307113733.819448-1-shaojijie@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Jian Shen and committed by
Paolo Abeni
9e328504 e016cf5f

+54 -49
+14 -10
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
··· 3 3 4 4 #include <linux/debugfs.h> 5 5 #include <linux/device.h> 6 + #include <linux/string_choices.h> 6 7 7 8 #include "hnae3.h" 8 9 #include "hns3_debugfs.h" ··· 662 661 HNS3_RING_RX_RING_PKTNUM_RECORD_REG)); 663 662 sprintf(result[j++], "%u", ring->rx_copybreak); 664 663 665 - sprintf(result[j++], "%s", readl_relaxed(ring->tqp->io_base + 666 - HNS3_RING_EN_REG) ? "on" : "off"); 664 + sprintf(result[j++], "%s", 665 + str_on_off(readl_relaxed(ring->tqp->io_base + 666 + HNS3_RING_EN_REG))); 667 667 668 668 if (hnae3_ae_dev_tqp_txrx_indep_supported(ae_dev)) 669 - sprintf(result[j++], "%s", readl_relaxed(ring->tqp->io_base + 670 - HNS3_RING_RX_EN_REG) ? "on" : "off"); 669 + sprintf(result[j++], "%s", 670 + str_on_off(readl_relaxed(ring->tqp->io_base + 671 + HNS3_RING_RX_EN_REG))); 671 672 else 672 673 sprintf(result[j++], "%s", "NA"); 673 674 ··· 767 764 sprintf(result[j++], "%u", readl_relaxed(ring->tqp->io_base + 768 765 HNS3_RING_TX_RING_PKTNUM_RECORD_REG)); 769 766 770 - sprintf(result[j++], "%s", readl_relaxed(ring->tqp->io_base + 771 - HNS3_RING_EN_REG) ? "on" : "off"); 767 + sprintf(result[j++], "%s", 768 + str_on_off(readl_relaxed(ring->tqp->io_base + 769 + HNS3_RING_EN_REG))); 772 770 773 771 if (hnae3_ae_dev_tqp_txrx_indep_supported(ae_dev)) 774 - sprintf(result[j++], "%s", readl_relaxed(ring->tqp->io_base + 775 - HNS3_RING_TX_EN_REG) ? "on" : "off"); 772 + sprintf(result[j++], "%s", 773 + str_on_off(readl_relaxed(ring->tqp->io_base + 774 + HNS3_RING_TX_EN_REG))); 776 775 else 777 776 sprintf(result[j++], "%s", "NA"); 778 777 ··· 1035 1030 hns3_dbg_dev_caps(struct hnae3_handle *h, char *buf, int len, int *pos) 1036 1031 { 1037 1032 struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); 1038 - const char * const str[] = {"no", "yes"}; 1039 1033 unsigned long *caps = ae_dev->caps; 1040 1034 u32 i, state; 1041 1035 ··· 1043 1039 for (i = 0; i < ARRAY_SIZE(hns3_dbg_cap); i++) { 1044 1040 state = test_bit(hns3_dbg_cap[i].cap_bit, caps); 1045 1041 *pos += scnprintf(buf + *pos, len - *pos, "%s: %s\n", 1046 - hns3_dbg_cap[i].name, str[state]); 1042 + hns3_dbg_cap[i].name, str_yes_no(state)); 1047 1043 } 1048 1044 1049 1045 *pos += scnprintf(buf + *pos, len - *pos, "\n");
+2 -1
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
··· 3 3 4 4 #include <linux/etherdevice.h> 5 5 #include <linux/string.h> 6 + #include <linux/string_choices.h> 6 7 #include <linux/phy.h> 7 8 #include <linux/sfp.h> 8 9 ··· 1199 1198 return 0; 1200 1199 1201 1200 netdev_dbg(netdev, "Changing tx push from %s to %s\n", 1202 - old_state ? "on" : "off", tx_push ? "on" : "off"); 1201 + str_on_off(old_state), str_on_off(tx_push)); 1203 1202 1204 1203 if (tx_push) 1205 1204 set_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state);
+31 -32
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
··· 3 3 4 4 #include <linux/device.h> 5 5 #include <linux/sched/clock.h> 6 + #include <linux/string_choices.h> 6 7 7 8 #include "hclge_debugfs.h" 8 9 #include "hclge_err.h" ··· 12 11 #include "hclge_tm.h" 13 12 #include "hnae3.h" 14 13 15 - static const char * const state_str[] = { "off", "on" }; 16 14 static const char * const hclge_mac_state_str[] = { 17 15 "TO_ADD", "TO_DEL", "ACTIVE" 18 16 }; ··· 2573 2573 loopback_en = hnae3_get_bit(le32_to_cpu(req_app->txrx_pad_fcs_loop_en), 2574 2574 HCLGE_MAC_APP_LP_B); 2575 2575 pos += scnprintf(buf + pos, len - pos, "app loopback: %s\n", 2576 - state_str[loopback_en]); 2576 + str_on_off(loopback_en)); 2577 2577 2578 2578 hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_COMMON_LOOPBACK, true); 2579 2579 ret = hclge_cmd_send(&hdev->hw, &desc, 1); ··· 2586 2586 2587 2587 loopback_en = req_common->enable & HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B; 2588 2588 pos += scnprintf(buf + pos, len - pos, "serdes serial loopback: %s\n", 2589 - state_str[loopback_en]); 2589 + str_on_off(loopback_en)); 2590 2590 2591 2591 loopback_en = req_common->enable & 2592 2592 HCLGE_CMD_SERDES_PARALLEL_INNER_LOOP_B ? 1 : 0; 2593 2593 pos += scnprintf(buf + pos, len - pos, "serdes parallel loopback: %s\n", 2594 - state_str[loopback_en]); 2594 + str_on_off(loopback_en)); 2595 2595 2596 2596 if (phydev) { 2597 2597 loopback_en = phydev->loopback_enabled; 2598 2598 pos += scnprintf(buf + pos, len - pos, "phy loopback: %s\n", 2599 - state_str[loopback_en]); 2599 + str_on_off(loopback_en)); 2600 2600 } else if (hnae3_dev_phy_imp_supported(hdev)) { 2601 2601 loopback_en = req_common->enable & 2602 2602 HCLGE_CMD_GE_PHY_INNER_LOOP_B; 2603 2603 pos += scnprintf(buf + pos, len - pos, "phy loopback: %s\n", 2604 - state_str[loopback_en]); 2604 + str_on_off(loopback_en)); 2605 2605 } 2606 2606 2607 2607 return 0; ··· 2894 2894 egress = vlan_fe & HCLGE_FILTER_FE_NIC_EGRESS_B ? 1 : 0; 2895 2895 2896 2896 *pos += scnprintf(buf, len, "I_PORT_VLAN_FILTER: %s\n", 2897 - state_str[ingress]); 2897 + str_on_off(ingress)); 2898 2898 *pos += scnprintf(buf + *pos, len - *pos, "E_PORT_VLAN_FILTER: %s\n", 2899 - state_str[egress]); 2899 + str_on_off(egress)); 2900 2900 2901 2901 hclge_dbg_fill_content(content, sizeof(content), vlan_filter_items, 2902 2902 NULL, ARRAY_SIZE(vlan_filter_items)); ··· 2915 2915 return ret; 2916 2916 j = 0; 2917 2917 result[j++] = hclge_dbg_get_func_id_str(str_id, i); 2918 - result[j++] = state_str[ingress]; 2919 - result[j++] = state_str[egress]; 2920 - result[j++] = 2921 - test_bit(HNAE3_DEV_SUPPORT_PORT_VLAN_BYPASS_B, 2922 - hdev->ae_dev->caps) ? state_str[bypass] : "NA"; 2918 + result[j++] = str_on_off(ingress); 2919 + result[j++] = str_on_off(egress); 2920 + result[j++] = test_bit(HNAE3_DEV_SUPPORT_PORT_VLAN_BYPASS_B, 2921 + hdev->ae_dev->caps) ? 2922 + str_on_off(bypass) : "NA"; 2923 2923 hclge_dbg_fill_content(content, sizeof(content), 2924 2924 vlan_filter_items, result, 2925 2925 ARRAY_SIZE(vlan_filter_items)); ··· 2958 2958 j = 0; 2959 2959 result[j++] = hclge_dbg_get_func_id_str(str_id, i); 2960 2960 result[j++] = str_pvid; 2961 - result[j++] = state_str[vlan_cfg.accept_tag1]; 2962 - result[j++] = state_str[vlan_cfg.accept_tag2]; 2963 - result[j++] = state_str[vlan_cfg.accept_untag1]; 2964 - result[j++] = state_str[vlan_cfg.accept_untag2]; 2965 - result[j++] = state_str[vlan_cfg.insert_tag1]; 2966 - result[j++] = state_str[vlan_cfg.insert_tag2]; 2967 - result[j++] = state_str[vlan_cfg.shift_tag]; 2968 - result[j++] = state_str[vlan_cfg.strip_tag1]; 2969 - result[j++] = state_str[vlan_cfg.strip_tag2]; 2970 - result[j++] = state_str[vlan_cfg.drop_tag1]; 2971 - result[j++] = state_str[vlan_cfg.drop_tag2]; 2972 - result[j++] = state_str[vlan_cfg.pri_only1]; 2973 - result[j++] = state_str[vlan_cfg.pri_only2]; 2961 + result[j++] = str_on_off(vlan_cfg.accept_tag1); 2962 + result[j++] = str_on_off(vlan_cfg.accept_tag2); 2963 + result[j++] = str_on_off(vlan_cfg.accept_untag1); 2964 + result[j++] = str_on_off(vlan_cfg.accept_untag2); 2965 + result[j++] = str_on_off(vlan_cfg.insert_tag1); 2966 + result[j++] = str_on_off(vlan_cfg.insert_tag2); 2967 + result[j++] = str_on_off(vlan_cfg.shift_tag); 2968 + result[j++] = str_on_off(vlan_cfg.strip_tag1); 2969 + result[j++] = str_on_off(vlan_cfg.strip_tag2); 2970 + result[j++] = str_on_off(vlan_cfg.drop_tag1); 2971 + result[j++] = str_on_off(vlan_cfg.drop_tag2); 2972 + result[j++] = str_on_off(vlan_cfg.pri_only1); 2973 + result[j++] = str_on_off(vlan_cfg.pri_only2); 2974 2974 2975 2975 hclge_dbg_fill_content(content, sizeof(content), 2976 2976 vlan_offload_items, result, ··· 3007 3007 pos += scnprintf(buf + pos, len - pos, "phc %s's debug info:\n", 3008 3008 ptp->info.name); 3009 3009 pos += scnprintf(buf + pos, len - pos, "ptp enable: %s\n", 3010 - test_bit(HCLGE_PTP_FLAG_EN, &ptp->flags) ? 3011 - "yes" : "no"); 3010 + str_yes_no(test_bit(HCLGE_PTP_FLAG_EN, &ptp->flags))); 3012 3011 pos += scnprintf(buf + pos, len - pos, "ptp tx enable: %s\n", 3013 - test_bit(HCLGE_PTP_FLAG_TX_EN, &ptp->flags) ? 3014 - "yes" : "no"); 3012 + str_yes_no(test_bit(HCLGE_PTP_FLAG_TX_EN, 3013 + &ptp->flags))); 3015 3014 pos += scnprintf(buf + pos, len - pos, "ptp rx enable: %s\n", 3016 - test_bit(HCLGE_PTP_FLAG_RX_EN, &ptp->flags) ? 3017 - "yes" : "no"); 3015 + str_yes_no(test_bit(HCLGE_PTP_FLAG_RX_EN, 3016 + &ptp->flags))); 3018 3017 3019 3018 last_rx = jiffies_to_msecs(ptp->last_rx); 3020 3019 pos += scnprintf(buf + pos, len - pos, "last rx time: %lu.%lu\n",
+5 -5
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
··· 8000 8000 ret = hclge_tqp_enable(handle, en); 8001 8001 if (ret) 8002 8002 dev_err(&hdev->pdev->dev, "failed to %s tqp in loopback, ret = %d\n", 8003 - en ? "enable" : "disable", ret); 8003 + str_enable_disable(en), ret); 8004 8004 8005 8005 return ret; 8006 8006 } ··· 11200 11200 dev_info(dev, "This is %s PF\n", 11201 11201 hdev->flag & HCLGE_FLAG_MAIN ? "main" : "not main"); 11202 11202 dev_info(dev, "DCB %s\n", 11203 - handle->kinfo.tc_info.dcb_ets_active ? "enable" : "disable"); 11203 + str_enable_disable(handle->kinfo.tc_info.dcb_ets_active)); 11204 11204 dev_info(dev, "MQPRIO %s\n", 11205 - handle->kinfo.tc_info.mqprio_active ? "enable" : "disable"); 11205 + str_enable_disable(handle->kinfo.tc_info.mqprio_active)); 11206 11206 dev_info(dev, "Default tx spare buffer size: %u\n", 11207 11207 hdev->tx_spare_buf_size); 11208 11208 ··· 11976 11976 if (ret) { 11977 11977 dev_err(&hdev->pdev->dev, 11978 11978 "Set vf %d mac spoof check %s failed, ret=%d\n", 11979 - vf, enable ? "on" : "off", ret); 11979 + vf, str_on_off(enable), ret); 11980 11980 return ret; 11981 11981 } 11982 11982 ··· 11984 11984 if (ret) 11985 11985 dev_err(&hdev->pdev->dev, 11986 11986 "Set vf %d vlan spoof check %s failed, ret=%d\n", 11987 - vf, enable ? "on" : "off", ret); 11987 + vf, str_on_off(enable), ret); 11988 11988 11989 11989 return ret; 11990 11990 }
+2 -1
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
··· 2 2 // Copyright (c) 2021 Hisilicon Limited. 3 3 4 4 #include <linux/skbuff.h> 5 + #include <linux/string_choices.h> 5 6 #include "hclge_main.h" 6 7 #include "hnae3.h" 7 8 ··· 227 226 if (ret) 228 227 dev_err(&hdev->pdev->dev, 229 228 "failed to %s ptp interrupt, ret = %d\n", 230 - en ? "enable" : "disable", ret); 229 + str_enable_disable(en), ret); 231 230 232 231 return ret; 233 232 }