From: Zhengchao Shao <shaozhengchao@huawei.com>
To: <netdev@vger.kernel.org>, <bpf@vger.kernel.org>,
<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>
Cc: <jiri@resnulli.us>, <weiyongjun1@huawei.com>,
<yuehaibing@huawei.com>, <shaozhengchao@huawei.com>
Subject: [PATCH net-next 1/2] team: change return value of init in the team_option structure to void
Date: Fri, 4 Aug 2023 19:28:24 +0800 [thread overview]
Message-ID: <20230804112825.1697920-2-shaozhengchao@huawei.com> (raw)
In-Reply-To: <20230804112825.1697920-1-shaozhengchao@huawei.com>
Because the init function always returns 0, so change return value of init
in the team_option structure to void and remove redundant code.
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
drivers/net/team/team.c | 8 ++------
drivers/net/team/team_mode_activebackup.c | 5 ++---
drivers/net/team/team_mode_loadbalance.c | 15 ++++++---------
include/linux/if_team.h | 2 +-
4 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index d4818be08c03..84a57dcddb8b 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -149,7 +149,6 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
struct team_option_inst *opt_inst;
unsigned int array_size;
unsigned int i;
- int err;
array_size = option->array_size;
if (!array_size)
@@ -165,11 +164,8 @@ static int __team_option_inst_add(struct team *team, struct team_option *option,
opt_inst->changed = true;
opt_inst->removed = false;
list_add_tail(&opt_inst->list, &team->option_inst_list);
- if (option->init) {
- err = option->init(team, &opt_inst->info);
- if (err)
- return err;
- }
+ if (option->init)
+ option->init(team, &opt_inst->info);
}
return 0;
diff --git a/drivers/net/team/team_mode_activebackup.c b/drivers/net/team/team_mode_activebackup.c
index 3147a4fdf8d9..44d604f1c512 100644
--- a/drivers/net/team/team_mode_activebackup.c
+++ b/drivers/net/team/team_mode_activebackup.c
@@ -57,11 +57,10 @@ static void ab_port_leave(struct team *team, struct team_port *port)
}
}
-static int ab_active_port_init(struct team *team,
- struct team_option_inst_info *info)
+static void ab_active_port_init(struct team *team,
+ struct team_option_inst_info *info)
{
ab_priv(team)->ap_opt_inst_info = info;
- return 0;
}
static int ab_active_port_get(struct team *team, struct team_gsetter_ctx *ctx)
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
index 18d99fda997c..50c015cd0682 100644
--- a/drivers/net/team/team_mode_loadbalance.c
+++ b/drivers/net/team/team_mode_loadbalance.c
@@ -361,14 +361,13 @@ static int lb_tx_method_set(struct team *team, struct team_gsetter_ctx *ctx)
return 0;
}
-static int lb_tx_hash_to_port_mapping_init(struct team *team,
- struct team_option_inst_info *info)
+static void lb_tx_hash_to_port_mapping_init(struct team *team,
+ struct team_option_inst_info *info)
{
struct lb_priv *lb_priv = get_lb_priv(team);
unsigned char hash = info->array_index;
LB_HTPM_OPT_INST_INFO_BY_HASH(lb_priv, hash) = info;
- return 0;
}
static int lb_tx_hash_to_port_mapping_get(struct team *team,
@@ -401,14 +400,13 @@ static int lb_tx_hash_to_port_mapping_set(struct team *team,
return -ENODEV;
}
-static int lb_hash_stats_init(struct team *team,
- struct team_option_inst_info *info)
+static void lb_hash_stats_init(struct team *team,
+ struct team_option_inst_info *info)
{
struct lb_priv *lb_priv = get_lb_priv(team);
unsigned char hash = info->array_index;
lb_priv->ex->stats.info[hash].opt_inst_info = info;
- return 0;
}
static int lb_hash_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
@@ -421,14 +419,13 @@ static int lb_hash_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
return 0;
}
-static int lb_port_stats_init(struct team *team,
- struct team_option_inst_info *info)
+static void lb_port_stats_init(struct team *team,
+ struct team_option_inst_info *info)
{
struct team_port *port = info->port;
struct lb_port_priv *lb_port_priv = get_lb_port_priv(port);
lb_port_priv->stats_info.opt_inst_info = info;
- return 0;
}
static int lb_port_stats_get(struct team *team, struct team_gsetter_ctx *ctx)
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 8de6b6e67829..fc01c3cfe86d 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -162,7 +162,7 @@ struct team_option {
bool per_port;
unsigned int array_size; /* != 0 means the option is array */
enum team_option_type type;
- int (*init)(struct team *team, struct team_option_inst_info *info);
+ void (*init)(struct team *team, struct team_option_inst_info *info);
int (*getter)(struct team *team, struct team_gsetter_ctx *ctx);
int (*setter)(struct team *team, struct team_gsetter_ctx *ctx);
};
--
2.34.1
next prev parent reply other threads:[~2023-08-04 11:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 11:28 [PATCH net-next 0/2] team: change return value of init and getter in the team_option structure to void Zhengchao Shao
2023-08-04 11:28 ` Zhengchao Shao [this message]
2023-08-04 11:28 ` [PATCH net-next 2/2] team: change return value of " Zhengchao Shao
2023-08-04 11:44 ` [PATCH net-next 0/2] team: change return value of init and " Jiri Pirko
2023-08-04 12:06 ` shaozhengchao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230804112825.1697920-2-shaozhengchao@huawei.com \
--to=shaozhengchao@huawei.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=weiyongjun1@huawei.com \
--cc=yuehaibing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).