Re: [PATCH net-next] net: hns3: Constify static structs

2020-09-23 Thread David Miller
From: Rikard Falkeborn 
Date: Tue, 22 Sep 2020 00:55:17 +0200

> A number of static variables were not modified. Make them const to allow
> the compiler to put them in read-only memory. In order to do so,
> constify a couple of input pointers as well as some local pointers.
> This moves about 35Kb to read-only memory as seen by the output of the
> size command.
> 
> Before:
>textdata bss dec hex filename
>  404938  111534 640  517112   7e3f8 
> drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge.ko
> 
> After:
>textdata bss dec hex filename
>  439499   76974 640  517113   7e3f9 
> drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge.ko
> 
> Signed-off-by: Rikard Falkeborn 

Applied.


[PATCH net-next] net: hns3: Constify static structs

2020-09-21 Thread Rikard Falkeborn
A number of static variables were not modified. Make them const to allow
the compiler to put them in read-only memory. In order to do so,
constify a couple of input pointers as well as some local pointers.
This moves about 35Kb to read-only memory as seen by the output of the
size command.

Before:
   textdata bss dec hex filename
 404938  111534 640  517112   7e3f8 
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge.ko

After:
   textdata bss dec hex filename
 439499   76974 640  517113   7e3f9 
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge.ko

Signed-off-by: Rikard Falkeborn 
---
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 10 +++
 .../hisilicon/hns3/hns3pf/hclge_debugfs.h | 26 +--
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index 26f6f068b01d..c643c5ab60df 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -8,7 +8,7 @@
 #include "hclge_tm.h"
 #include "hnae3.h"
 
-static struct hclge_dbg_reg_type_info hclge_dbg_reg_info[] = {
+static const struct hclge_dbg_reg_type_info hclge_dbg_reg_info[] = {
{ .reg_type = "bios common",
  .dfx_msg = _dbg_bios_common_reg[0],
  .reg_msg = { .msg_num = ARRAY_SIZE(hclge_dbg_bios_common_reg),
@@ -115,14 +115,14 @@ static int hclge_dbg_cmd_send(struct hclge_dev *hdev,
 }
 
 static void hclge_dbg_dump_reg_common(struct hclge_dev *hdev,
- struct hclge_dbg_reg_type_info *reg_info,
+ const struct hclge_dbg_reg_type_info 
*reg_info,
  const char *cmd_buf)
 {
 #define IDX_OFFSET 1
 
const char *s = _buf[strlen(reg_info->reg_type) + IDX_OFFSET];
-   struct hclge_dbg_dfx_message *dfx_message = reg_info->dfx_msg;
-   struct hclge_dbg_reg_common_msg *reg_msg = _info->reg_msg;
+   const struct hclge_dbg_dfx_message *dfx_message = reg_info->dfx_msg;
+   const struct hclge_dbg_reg_common_msg *reg_msg = _info->reg_msg;
struct hclge_desc *desc_src;
struct hclge_desc *desc;
int entries_per_desc;
@@ -399,7 +399,7 @@ static void hclge_dbg_dump_dcb(struct hclge_dev *hdev, 
const char *cmd_buf)
 
 static void hclge_dbg_dump_reg_cmd(struct hclge_dev *hdev, const char *cmd_buf)
 {
-   struct hclge_dbg_reg_type_info *reg_info;
+   const struct hclge_dbg_reg_type_info *reg_info;
bool has_dump = false;
int i;
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h
index 38b79321c4c4..a9066e6ff697 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h
@@ -81,13 +81,13 @@ struct hclge_dbg_dfx_message {
 #define HCLGE_DBG_MAC_REG_TYPE_LEN 32
 struct hclge_dbg_reg_type_info {
const char *reg_type;
-   struct hclge_dbg_dfx_message *dfx_msg;
+   const struct hclge_dbg_dfx_message *dfx_msg;
struct hclge_dbg_reg_common_msg reg_msg;
 };
 
 #pragma pack()
 
-static struct hclge_dbg_dfx_message hclge_dbg_bios_common_reg[] = {
+static const struct hclge_dbg_dfx_message hclge_dbg_bios_common_reg[] = {
{false, "Reserved"},
{true,  "BP_CPU_STATE"},
{true,  "DFX_MSIX_INFO_NIC_0"},
@@ -103,7 +103,7 @@ static struct hclge_dbg_dfx_message 
hclge_dbg_bios_common_reg[] = {
{false, "Reserved"},
 };
 
-static struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_0[] = {
+static const struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_0[] = {
{false, "Reserved"},
{true,  "SSU_ETS_PORT_STATUS"},
{true,  "SSU_ETS_TCG_STATUS"},
@@ -175,7 +175,7 @@ static struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_0[] = 
{
{false, "Reserved"},
 };
 
-static struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_1[] = {
+static const struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_1[] = {
{true,  "prt_id"},
{true,  "PACKET_TC_CURR_BUFFER_CNT_0"},
{true,  "PACKET_TC_CURR_BUFFER_CNT_1"},
@@ -282,7 +282,7 @@ static struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_1[] = 
{
{false, "Reserved"},
 };
 
-static struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_2[] = {
+static const struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_2[] = {
{true,  "OQ_INDEX"},
{true,  "QUEUE_CNT"},
{false, "Reserved"},
@@ -291,7 +291,7 @@ static struct hclge_dbg_dfx_message hclge_dbg_ssu_reg_2[] = 
{
{false, "Reserved"},
 };
 
-static struct hclge_dbg_dfx_message hclge_dbg_igu_egu_reg[] = {
+static const struct hclge_dbg_dfx_message hclge_dbg_igu_egu_reg[] = {
{true,  "prt_id"},
{true,  "IGU_RX_ERR_PKT"},
{true,  "IGU_RX_NO_SOF_PKT"},
@@ -356,7 +356,7 @@